summaryrefslogtreecommitdiff
path: root/spec/ruby/core/objectspace/add_finalizer_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/objectspace/add_finalizer_spec.rb')
0 files changed, 0 insertions, 0 deletions
b98fea0710b48e4f313d2f535f4ceb08feb'>Makefile.in10
-rw-r--r--NEWS115
-rw-r--r--README.EXT92
-rw-r--r--array.c25
-rw-r--r--bcc32/Makefile.sub51
-rwxr-xr-xbcc32/configure.bat4
-rwxr-xr-x[-rw-r--r--]bcc32/mkexports.rb2
-rw-r--r--bcc32/setup.mak14
-rw-r--r--bignum.c298
-rw-r--r--bin/irb4
-rw-r--r--bin/rdoc2
-rw-r--r--class.c57
-rw-r--r--common.mk215
-rw-r--r--compar.c4
-rw-r--r--configure.in235
-rw-r--r--defines.h23
-rw-r--r--dir.c1341
-rw-r--r--dln.c33
-rw-r--r--dln.h4
-rw-r--r--doc/NEWS-1.8.0 (renamed from doc/NEWS)0
-rw-r--r--doc/forwardable.rd4
-rw-r--r--doc/forwardable.rd.ja4
-rw-r--r--doc/irb/irb-tools.rd.ja4
-rw-r--r--doc/irb/irb.rd4
-rw-r--r--doc/irb/irb.rd.ja4
-rw-r--r--doc/shell.rd4
-rw-r--r--doc/shell.rd.ja4
-rw-r--r--enum.c4
-rw-r--r--env.h4
-rw-r--r--error.c16
-rw-r--r--eval.c797
-rw-r--r--ext/Setup1
-rw-r--r--ext/Setup.atheos1
-rw-r--r--ext/Setup.dj1
-rw-r--r--ext/Setup.emx1
-rw-r--r--ext/Setup.nt1
-rw-r--r--ext/Setup.x681
-rw-r--r--ext/Win32API/Win32API.c2
-rw-r--r--ext/Win32API/lib/win32/registry.rb2
-rw-r--r--ext/Win32API/lib/win32/resolv.rb2
-rw-r--r--ext/bigdecimal/bigdecimal.c177
-rw-r--r--ext/bigdecimal/bigdecimal.h12
-rw-r--r--ext/bigdecimal/bigdecimal_en.html9
-rw-r--r--ext/bigdecimal/bigdecimal_ja.html7
-rw-r--r--ext/bigdecimal/extconf.rb10
-rw-r--r--ext/curses/curses.c3
-rw-r--r--ext/curses/extconf.rb2
-rw-r--r--ext/dbm/dbm.c4
-rw-r--r--ext/dbm/extconf.rb60
-rw-r--r--ext/digest/bubblebabble/.cvsignore3
-rw-r--r--ext/digest/bubblebabble/bubblebabble.c142
-rw-r--r--ext/digest/bubblebabble/depend3
-rw-r--r--ext/digest/bubblebabble/extconf.rb6
-rw-r--r--ext/digest/defs.h10
-rw-r--r--ext/digest/digest.c697
-rw-r--r--ext/digest/digest.h30
-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/digest.rb48
-rw-r--r--ext/digest/lib/md5.rb19
-rw-r--r--ext/digest/lib/sha1.rb19
-rw-r--r--ext/digest/md5/extconf.rb4
-rw-r--r--ext/digest/md5/md5.c28
-rw-r--r--ext/digest/md5/md5.h11
-rw-r--r--ext/digest/md5/md5init.c25
-rw-r--r--ext/digest/md5/md5ossl.c25
-rw-r--r--ext/digest/md5/md5ossl.h7
-rw-r--r--ext/digest/rmd160/depend2
-rw-r--r--ext/digest/rmd160/extconf.rb6
-rw-r--r--ext/digest/rmd160/rmd160.c11
-rw-r--r--ext/digest/rmd160/rmd160.h18
-rw-r--r--ext/digest/rmd160/rmd160hl.c96
-rw-r--r--ext/digest/rmd160/rmd160init.c28
-rw-r--r--ext/digest/rmd160/rmd160ossl.c43
-rw-r--r--ext/digest/rmd160/rmd160ossl.h6
-rw-r--r--ext/digest/sha1/depend2
-rw-r--r--ext/digest/sha1/extconf.rb6
-rw-r--r--ext/digest/sha1/sha1.c24
-rw-r--r--ext/digest/sha1/sha1.h19
-rw-r--r--ext/digest/sha1/sha1hl.c102
-rw-r--r--ext/digest/sha1/sha1init.c32
-rw-r--r--ext/digest/sha1/sha1ossl.c43
-rw-r--r--ext/digest/sha1/sha1ossl.h9
-rw-r--r--ext/digest/sha2/depend2
-rw-r--r--ext/digest/sha2/extconf.rb5
-rw-r--r--ext/digest/sha2/lib/sha2.rb73
-rw-r--r--ext/digest/sha2/sha2.c26
-rw-r--r--ext/digest/sha2/sha2.h38
-rw-r--r--ext/digest/sha2/sha2hl.c252
-rw-r--r--ext/digest/sha2/sha2init.c25
-rw-r--r--ext/digest/test.sh7
-rw-r--r--ext/dl/dl.c2
-rw-r--r--ext/dl/dl.h2
-rw-r--r--ext/dl/h2rb2
-rw-r--r--ext/dl/handle.c6
-rw-r--r--ext/dl/lib/dl/import.rb4
-rw-r--r--ext/dl/lib/dl/win32.rb2
-rw-r--r--ext/dl/ptr.c43
-rw-r--r--ext/dl/sym.c4
-rw-r--r--ext/enumerator/enumerator.c4
-rw-r--r--ext/enumerator/enumerator.txt2
-rw-r--r--ext/etc/etc.c4
-rw-r--r--ext/extmk.rb143
-rw-r--r--ext/fcntl/fcntl.c2
-rw-r--r--ext/gdbm/gdbm.c418
-rw-r--r--ext/iconv/iconv.c11
-rw-r--r--ext/io/wait/extconf.rb2
-rw-r--r--ext/io/wait/wait.c4
-rw-r--r--ext/nkf/lib/kconv.rb10
-rw-r--r--ext/nkf/nkf-utf8/nkf.c1103
-rw-r--r--ext/nkf/nkf-utf8/utf8tbl.c2
-rw-r--r--ext/nkf/nkf.c14
-rw-r--r--ext/openssl/extconf.rb6
-rw-r--r--ext/openssl/lib/net/ftptls.rb14
-rw-r--r--ext/openssl/lib/net/telnets.rb7
-rw-r--r--ext/openssl/lib/openssl.rb4
-rw-r--r--ext/openssl/lib/openssl/bn.rb4
-rw-r--r--ext/openssl/lib/openssl/buffering.rb4
-rw-r--r--ext/openssl/lib/openssl/cipher.rb4
-rw-r--r--ext/openssl/lib/openssl/digest.rb4
-rw-r--r--ext/openssl/lib/openssl/ssl.rb6
-rw-r--r--ext/openssl/lib/openssl/x509.rb4
-rw-r--r--ext/openssl/openssl_missing.c2
-rw-r--r--ext/openssl/openssl_missing.h2
-rw-r--r--ext/openssl/ossl.c2
-rw-r--r--ext/openssl/ossl.h23
-rw-r--r--ext/openssl/ossl_asn1.c6
-rw-r--r--ext/openssl/ossl_asn1.h2
-rw-r--r--ext/openssl/ossl_bio.c2
-rw-r--r--ext/openssl/ossl_bio.h2
-rw-r--r--ext/openssl/ossl_bn.c6
-rw-r--r--ext/openssl/ossl_bn.h2
-rw-r--r--ext/openssl/ossl_cipher.c6
-rw-r--r--ext/openssl/ossl_cipher.h2
-rw-r--r--ext/openssl/ossl_config.c7
-rw-r--r--ext/openssl/ossl_config.h2
-rw-r--r--ext/openssl/ossl_digest.c6
-rw-r--r--ext/openssl/ossl_digest.h2
-rw-r--r--ext/openssl/ossl_engine.c2
-rw-r--r--ext/openssl/ossl_engine.h2
-rw-r--r--ext/openssl/ossl_hmac.c6
-rw-r--r--ext/openssl/ossl_hmac.h2
-rw-r--r--ext/openssl/ossl_ns_spki.c3
-rw-r--r--ext/openssl/ossl_ns_spki.h2
-rw-r--r--ext/openssl/ossl_ocsp.c4
-rw-r--r--ext/openssl/ossl_ocsp.h2
-rw-r--r--ext/openssl/ossl_pkcs12.c2
-rw-r--r--ext/openssl/ossl_pkcs12.h2
-rw-r--r--ext/openssl/ossl_pkcs5.h6
-rw-r--r--ext/openssl/ossl_pkcs7.c4
-rw-r--r--ext/openssl/ossl_pkcs7.h2
-rw-r--r--ext/openssl/ossl_pkey.c6
-rw-r--r--ext/openssl/ossl_pkey.h2
-rw-r--r--ext/openssl/ossl_pkey_dh.c7
-rw-r--r--ext/openssl/ossl_pkey_dsa.c7
-rw-r--r--ext/openssl/ossl_pkey_rsa.c7
-rw-r--r--ext/openssl/ossl_rand.c6
-rw-r--r--ext/openssl/ossl_rand.h2
-rw-r--r--ext/openssl/ossl_ssl.c6
-rw-r--r--ext/openssl/ossl_ssl.h2
-rw-r--r--ext/openssl/ossl_version.h2
-rw-r--r--ext/openssl/ossl_x509.c2
-rw-r--r--ext/openssl/ossl_x509.h2
-rw-r--r--ext/openssl/ossl_x509attr.c2
-rw-r--r--ext/openssl/ossl_x509cert.c2
-rw-r--r--ext/openssl/ossl_x509crl.c2
-rw-r--r--ext/openssl/ossl_x509ext.c2
-rw-r--r--ext/openssl/ossl_x509name.c6
-rw-r--r--ext/openssl/ossl_x509req.c2
-rw-r--r--ext/openssl/ossl_x509revoked.c2
-rw-r--r--ext/openssl/ossl_x509store.c2
-rw-r--r--ext/openssl/ruby_missing.h2
-rw-r--r--ext/pty/lib/expect.rb2
-rw-r--r--ext/pty/pty.c37
-rw-r--r--ext/purelib.rb3
-rw-r--r--ext/racc/cparse/cparse.c4
-rw-r--r--ext/racc/cparse/extconf.rb2
-rw-r--r--ext/readline/extconf.rb7
-rw-r--r--ext/readline/readline.c23
-rw-r--r--ext/sdbm/_sdbm.c6
-rw-r--r--ext/sdbm/init.c4
-rw-r--r--ext/socket/extconf.rb8
-rw-r--r--ext/socket/getnameinfo.c5
-rw-r--r--ext/socket/socket.c73
-rw-r--r--ext/socket/sockport.h4
-rw-r--r--ext/stringio/README4
-rw-r--r--ext/stringio/stringio.c24
-rw-r--r--ext/strscan/strscan.c6
-rw-r--r--ext/syck/bytecode.c4
-rw-r--r--ext/syck/emitter.c4
-rw-r--r--ext/syck/handler.c4
-rw-r--r--ext/syck/implicit.c4
-rw-r--r--ext/syck/node.c4
-rw-r--r--ext/syck/rubyext.c5
-rw-r--r--ext/syck/syck.c4
-rw-r--r--ext/syck/syck.h6
-rw-r--r--ext/syck/token.c4
-rw-r--r--ext/syck/yaml2byte.c4
-rw-r--r--ext/syslog/extconf.rb2
-rw-r--r--ext/syslog/syslog.c2
-rw-r--r--ext/syslog/syslog.txt2
-rw-r--r--ext/syslog/test.rb2
-rw-r--r--ext/thread/extconf.rb9
-rw-r--r--ext/thread/lib/thread.rb5
-rw-r--r--ext/thread/thread.c1214
-rw-r--r--ext/tk/ChangeLog.tkextlib60
-rw-r--r--ext/tk/README.tcltklib9
-rw-r--r--ext/tk/extconf.rb7
-rw-r--r--ext/tk/lib/tk.rb8
-rw-r--r--ext/tk/lib/tk/after.rb2
-rw-r--r--ext/tk/lib/tk/canvas.rb8
-rw-r--r--ext/tk/lib/tk/entry.rb2
-rw-r--r--ext/tk/lib/tk/font.rb10
-rw-r--r--ext/tk/lib/tk/itemconfig.rb15
-rw-r--r--ext/tk/lib/tk/scrollable.rb11
-rw-r--r--ext/tk/lib/tk/scrollbox.rb2
-rw-r--r--ext/tk/lib/tk/spinbox.rb2
-rw-r--r--ext/tk/lib/tk/text.rb2
-rw-r--r--ext/tk/lib/tk/timer.rb2
-rw-r--r--ext/tk/lib/tk/txtwin_abst.rb2
-rw-r--r--ext/tk/lib/tkclass.rb2
-rw-r--r--ext/tk/lib/tkextlib/SUPPORT_STATUS42
-rw-r--r--ext/tk/lib/tkextlib/blt.rb4
-rw-r--r--ext/tk/lib/tkextlib/blt/container.rb20
-rw-r--r--ext/tk/lib/tkextlib/blt/table.rb102
-rw-r--r--ext/tk/lib/tkextlib/blt/tile/checkbutton.rb4
-rw-r--r--ext/tk/lib/tkextlib/blt/tile/radiobutton.rb4
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/checkbox.rb2
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/radiobox.rb2
-rw-r--r--ext/tk/lib/tkextlib/tcllib/tablelist.rb2
-rw-r--r--ext/tk/lib/tkextlib/tile.rb5
-rw-r--r--ext/tk/lib/tkextlib/tile/dialog.rb2
-rw-r--r--ext/tk/lib/tkextlib/tile/sizegrip.rb25
-rw-r--r--ext/tk/lib/tkextlib/tile/style.rb4
-rw-r--r--ext/tk/lib/tkextlib/tile/tcombobox.rb6
-rw-r--r--ext/tk/lib/tkextlib/tile/tnotebook.rb10
-rw-r--r--ext/tk/lib/tkextlib/tile/treeview.rb1117
-rw-r--r--ext/tk/lib/tkextlib/version.rb6
-rw-r--r--ext/tk/sample/editable_listbox.rb69
-rw-r--r--ext/tk/sample/images/teapot.ppm49
-rw-r--r--ext/tk/sample/irbtkw.rbw124
-rw-r--r--ext/tk/sample/tkextlib/tile/repeater.tcl2
-rw-r--r--ext/tk/sample/tkextlib/tile/themes/keramik/keramik.tcl2
-rw-r--r--ext/tk/sample/tkextlib/tile/themes/keramik/pkgIndex.tcl2
-rw-r--r--ext/tk/sample/tkextlib/tile/themes/kroc/pkgIndex.tcl2
-rw-r--r--ext/tk/sample/tkextlib/tile/themes/plastik/pkgIndex.tcl2
-rw-r--r--ext/tk/sample/tkextlib/tile/themes/plastik/plastik.tcl2
-rw-r--r--ext/tk/sample/tkextlib/tile/toolbutton.tcl2
-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page3/index.html2
-rw-r--r--ext/tk/sample/tktextio.rb547
-rw-r--r--ext/tk/tcltklib.c11
-rw-r--r--ext/tk/tkutil/extconf.rb9
-rw-r--r--ext/tk/tkutil/tkutil.c4
-rw-r--r--ext/win32ole/extconf.rb4
-rw-r--r--ext/win32ole/sample/olegen.rb4
-rw-r--r--ext/win32ole/win32ole.c45
-rw-r--r--ext/zlib/doc/zlib.rd2
-rw-r--r--ext/zlib/extconf.rb2
-rw-r--r--ext/zlib/zlib.c2
-rw-r--r--file.c339
-rw-r--r--gc.c175
-rw-r--r--hash.c99
-rw-r--r--ia64.s33
-rw-r--r--inits.c4
-rwxr-xr-x[-rw-r--r--]instruby.rb295
-rw-r--r--intern.h16
-rw-r--r--io.c51
-rw-r--r--lib/.document3
-rw-r--r--lib/README2
-rw-r--r--lib/abbrev.rb2
-rw-r--r--lib/base64.rb4
-rw-r--r--lib/benchmark.rb9
-rw-r--r--lib/cgi.rb28
-rw-r--r--lib/cgi/session.rb16
-rw-r--r--lib/csv.rb2
-rw-r--r--lib/date.rb864
-rw-r--r--lib/date/format.rb1487
-rw-r--r--lib/delegate.rb1
-rw-r--r--lib/drb/acl.rb2
-rw-r--r--lib/drb/unix.rb2
-rw-r--r--lib/erb.rb2
-rw-r--r--lib/fileutils.rb133
-rw-r--r--lib/forwardable.rb4
-rw-r--r--lib/generator.rb2
-rw-r--r--lib/getopts.rb6
-rw-r--r--lib/ipaddr.rb2
-rw-r--r--lib/irb.rb24
-rw-r--r--lib/irb/cmd/chws.rb4
-rw-r--r--lib/irb/cmd/fork.rb6
-rw-r--r--lib/irb/cmd/help.rb4
-rw-r--r--lib/irb/cmd/load.rb4
-rw-r--r--lib/irb/cmd/nop.rb6
-rw-r--r--lib/irb/cmd/pushws.rb4
-rw-r--r--lib/irb/cmd/subirb.rb4
-rw-r--r--lib/irb/completion.rb6
-rw-r--r--lib/irb/context.rb4
-rw-r--r--lib/irb/ext/change-ws.rb4
-rw-r--r--lib/irb/ext/history.rb6
-rw-r--r--lib/irb/ext/loader.rb6
-rw-r--r--lib/irb/ext/math-mode.rb4
-rw-r--r--lib/irb/ext/multi-irb.rb6
-rw-r--r--lib/irb/ext/save-history.rb6
-rw-r--r--lib/irb/ext/tracer.rb4
-rw-r--r--lib/irb/ext/use-loader.rb4
-rw-r--r--lib/irb/ext/workspaces.rb4
-rw-r--r--lib/irb/extend-command.rb4
-rw-r--r--lib/irb/frame.rb4
-rw-r--r--lib/irb/help.rb4
-rw-r--r--lib/irb/init.rb4
-rw-r--r--lib/irb/input-method.rb6
-rw-r--r--lib/irb/lc/error.rb4
-rw-r--r--lib/irb/lc/help-message4
-rw-r--r--lib/irb/lc/ja/error.rb4
-rw-r--r--lib/irb/lc/ja/help-message4
-rw-r--r--lib/irb/locale.rb12
-rw-r--r--lib/irb/notifier.rb4
-rw-r--r--lib/irb/output-method.rb6
-rw-r--r--lib/irb/ruby-lex.rb6
-rw-r--r--lib/irb/ruby-token.rb4
-rw-r--r--lib/irb/slex.rb6
-rw-r--r--lib/irb/version.rb4
-rw-r--r--lib/irb/workspace.rb4
-rw-r--r--lib/irb/ws-for-case-2.rb4
-rw-r--r--lib/irb/xmp.rb6
-rw-r--r--lib/jcode.rb2
-rw-r--r--lib/logger.rb4
-rw-r--r--lib/mkmf.rb136
-rw-r--r--lib/net/http.rb7
-rw-r--r--lib/net/https.rb4
-rw-r--r--lib/net/imap.rb40
-rw-r--r--lib/net/pop.rb6
-rw-r--r--lib/net/protocol.rb2
-rw-r--r--lib/net/smtp.rb4
-rw-r--r--lib/net/telnet.rb4
-rw-r--r--lib/open-uri.rb10
-rw-r--r--lib/open3.rb45
-rw-r--r--lib/optparse.rb153
-rw-r--r--lib/parsearg.rb6
-rw-r--r--lib/parsedate.rb44
-rw-r--r--lib/ping.rb49
-rw-r--r--lib/prettyprint.rb12
-rw-r--r--lib/pstore.rb21
-rw-r--r--lib/rdoc/generators/ri_generator.rb2
-rw-r--r--lib/rdoc/options.rb15
-rw-r--r--lib/rdoc/parsers/parse_c.rb266
-rw-r--r--lib/rdoc/parsers/parse_rb.rb2
-rw-r--r--lib/rdoc/rdoc.rb54
-rw-r--r--lib/rdoc/ri/ri_formatter.rb4
-rw-r--r--lib/resolv.rb3
-rw-r--r--lib/rexml/comment.rb24
-rw-r--r--lib/rexml/dtd/dtd.rb2
-rw-r--r--lib/rexml/element.rb48
-rw-r--r--lib/rexml/encoding.rb24
-rw-r--r--lib/rexml/encodings/CP-1252.rb110
-rw-r--r--lib/rexml/encodings/ISO-8859-15.rb50
-rw-r--r--lib/rexml/encodings/SHIFT-JIS.rb4
-rw-r--r--lib/rexml/encodings/UNILE.rb2
-rw-r--r--lib/rexml/encodings/UTF-16.rb3
-rw-r--r--lib/rexml/functions.rb26
-rw-r--r--lib/rexml/node.rb6
-rw-r--r--lib/rexml/parsers/baseparser.rb21
-rw-r--r--lib/rexml/parsers/sax2parser.rb4
-rw-r--r--lib/rexml/parsers/treeparser.rb3
-rw-r--r--lib/rexml/parsers/xpathparser.rb8
-rw-r--r--lib/rexml/rexml.rb8
-rw-r--r--lib/rexml/sax2listener.rb2
-rw-r--r--lib/rexml/source.rb31
-rw-r--r--lib/rexml/text.rb47
-rw-r--r--lib/rexml/xpath.rb14
-rw-r--r--lib/rexml/xpath_parser.rb84
-rw-r--r--lib/rinda/tuplespace.rb13
-rw-r--r--lib/rss/0.9.rb1
-rw-r--r--lib/scanf.rb8
-rw-r--r--lib/set.rb17
-rw-r--r--lib/shell/builtin-command.rb4
-rw-r--r--lib/shell/command-processor.rb4
-rw-r--r--lib/shell/error.rb4
-rw-r--r--lib/shell/filter.rb4
-rw-r--r--lib/shell/process-controller.rb4
-rw-r--r--lib/shell/system-command.rb4
-rw-r--r--lib/shell/version.rb4
-rw-r--r--lib/sync.rb6
-rw-r--r--lib/tempfile.rb2
-rw-r--r--lib/test/unit/autorunner.rb24
-rw-r--r--lib/test/unit/collector/dir.rb25
-rw-r--r--lib/test/unit/testcase.rb14
-rw-r--r--lib/thread.rb15
-rw-r--r--lib/time.rb10
-rw-r--r--lib/timeout.rb23
-rw-r--r--lib/tmpdir.rb6
-rw-r--r--lib/uri.rb2
-rw-r--r--lib/uri/common.rb12
-rw-r--r--lib/uri/ftp.rb2
-rw-r--r--lib/uri/generic.rb20
-rw-r--r--lib/uri/http.rb51
-rw-r--r--lib/uri/https.rb6
-rw-r--r--lib/uri/ldap.rb2
-rw-r--r--lib/uri/mailto.rb47
-rw-r--r--lib/weakref.rb30
-rw-r--r--lib/webrick/cgi.rb2
-rw-r--r--lib/webrick/cookie.rb6
-rw-r--r--lib/webrick/httpservlet/abstract.rb2
-rw-r--r--lib/webrick/httpservlet/cgi_runner.rb4
-rw-r--r--lib/webrick/httpservlet/filehandler.rb71
-rw-r--r--lib/webrick/ssl.rb2
-rw-r--r--lib/xmlrpc/base64.rb2
-rw-r--r--lib/xmlrpc/client.rb11
-rw-r--r--lib/xmlrpc/config.rb2
-rw-r--r--lib/xmlrpc/create.rb4
-rw-r--r--lib/xmlrpc/datetime.rb2
-rw-r--r--lib/xmlrpc/httpserver.rb2
-rw-r--r--lib/xmlrpc/marshal.rb2
-rw-r--r--lib/xmlrpc/parser.rb6
-rw-r--r--lib/xmlrpc/server.rb8
-rw-r--r--lib/xmlrpc/utils.rb4
-rw-r--r--lib/yaml.rb2
-rw-r--r--lib/yaml/basenode.rb2
-rw-r--r--lib/yaml/tag.rb2
-rw-r--r--lib/yaml/types.rb2
-rw-r--r--main.c13
-rw-r--r--marshal.c16
-rw-r--r--math.c4
-rwxr-xr-xmdoc2man.rb2
-rw-r--r--misc/inf-ruby.el10
-rw-r--r--misc/ruby-mode.el12
-rw-r--r--missing.h4
-rw-r--r--missing/acosh.c4
-rw-r--r--missing/flock.c5
-rw-r--r--missing/isinf.c7
-rw-r--r--missing/strftime.c58
-rw-r--r--missing/strtod.c2
-rwxr-xr-x[-rw-r--r--]mkconfig.rb37
-rw-r--r--node.h104
-rw-r--r--numeric.c197
-rw-r--r--object.c140
-rw-r--r--pack.c9
-rw-r--r--parse.y107
-rw-r--r--prec.c4
-rw-r--r--process.c135
-rw-r--r--random.c11
-rw-r--r--range.c9
-rw-r--r--re.c38
-rw-r--r--re.h4
-rw-r--r--regex.c55
-rw-r--r--ruby.c208
-rw-r--r--ruby.h37
-rw-r--r--rubyio.h4
-rw-r--r--rubysig.h4
-rwxr-xr-x[-rw-r--r--]rubytest.rb0
-rwxr-xr-xrunruby.rb11
-rw-r--r--sample/biorhythm.rb4
-rw-r--r--sample/openssl/c_rehash.rb4
-rw-r--r--sample/test.rb5
-rw-r--r--signal.c139
-rw-r--r--sprintf.c93
-rw-r--r--string.c26
-rw-r--r--struct.c11
-rw-r--r--test/dbm/test_dbm.rb4
-rw-r--r--test/digest/test_digest.rb30
-rw-r--r--test/fileutils/fileasserts.rb8
-rw-r--r--test/fileutils/test_dryrun.rb2
-rw-r--r--test/fileutils/test_fileutils.rb2
-rw-r--r--test/fileutils/test_nowrite.rb2
-rw-r--r--test/fileutils/test_verbose.rb2
-rw-r--r--test/gdbm/test_gdbm.rb4
-rw-r--r--test/net/imap/test_imap.rb11
-rw-r--r--test/optparse/test_getopts.rb31
-rw-r--r--test/rdoc/parsers/test_parse_c.rb261
-rw-r--r--test/rinda/test_rinda.rb14
-rw-r--r--test/ruby/test_beginendblock.rb38
-rw-r--r--test/ruby/test_bignum.rb8
-rw-r--r--test/ruby/test_hash.rb564
-rw-r--r--test/ruby/test_iterator.rb12
-rw-r--r--test/ruby/test_marshal.rb20
-rw-r--r--test/ruby/test_objectspace.rb2
-rw-r--r--test/ruby/test_super.rb17
-rw-r--r--test/ruby/test_system.rb5
-rw-r--r--test/runner.rb2
-rw-r--r--test/strscan/test_stringscanner.rb13
-rw-r--r--test/testunit/collector/test_dir.rb29
-rw-r--r--test/thread/test_thread.rb67
-rw-r--r--test/webrick/.htaccess1
-rw-r--r--test/webrick/test_cgi.rb9
-rw-r--r--test/webrick/test_cookie.rb31
-rw-r--r--test/webrick/test_filehandler.rb135
-rw-r--r--test/webrick/utils.rb12
-rwxr-xr-xtest/webrick/webrick_long_filename.cgi36
-rw-r--r--test/yaml/test_yaml.rb2
-rw-r--r--time.c17
-rw-r--r--util.c10
-rw-r--r--util.h4
-rw-r--r--variable.c17
-rw-r--r--version.c4
-rw-r--r--version.h16
-rw-r--r--win32/Makefile.sub22
-rwxr-xr-xwin32/configure.bat4
-rw-r--r--win32/dir.h4
-rwxr-xr-x[-rw-r--r--]win32/mkexports.rb17
-rwxr-xr-x[-rw-r--r--]win32/resource.rb20
-rw-r--r--win32/setup.mak17
-rw-r--r--win32/win32.c250
-rw-r--r--win32/win32.h2
-rw-r--r--wince/Makefile.sub10
-rw-r--r--wince/setup.mak2
-rw-r--r--x68/_dtos18.c2
-rw-r--r--x68/_round.c2
-rw-r--r--x68/fconvert.c2
-rw-r--r--x68/select.c2
511 files changed, 14417 insertions, 8485 deletions
diff --git a/.cvsignore b/.cvsignore
index 9fd96ca149..a72211d03f 100644
--- a/.cvsignore
+++ b/.cvsignore
@@ -3,12 +3,14 @@
*.rej
*.sav
*~
+.*.list
+.*.time
.ccmalloc
.ppack
.ext
.git
.svn
-.rbconfig.time
+.pc
COPYING.LIB
ChangeLog.pre-alpha
ChangeLog.pre1_1
@@ -26,32 +28,20 @@ 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
+patches
ppack
preview
rbconfig.rb
-rename2.h
repack
riscos
rubicon
ruby
ruby-man.rd.gz
-rubyunit
-st.c.power
-this that
tmp
web
y.output
diff --git a/ChangeLog b/ChangeLog
index d65ecbff6c..0c86195d49 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,1201 +1,1872 @@
-Sun Jun 15 22:05:45 2008 Akinori MUSHA <knu@iDaemons.org>
+Wed May 30 05:17:55 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * ext/syck/rubyext.c: Node#value defined twice.
+ * eval.c (rb_eval): get rid of SEGV at ZSUPER in a block
+ [ruby-dev:30836]
- * lib/yaml/: several method redefinitions causing warnings.
+Wed May 30 04:29:43 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sun Jun 15 22:03:36 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * eval.c (thread_timer): timer thread should not receive any
+ signals. submitted by Sylvain Joyeux. [ruby-core:08546]
- * marshal.c (w_object): add volatile to avoid potential GC bug. a
- patch from Tomoyuki Chikanaga <chikanag at nippon-control-system.co.jp>
- in [ruby-dev:34311].
+Wed May 30 04:18:37 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sun Jun 15 21:57:19 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * eval.c (rb_eval_cmd): just return if no exceptions.
+ [ruby-dev:30820]
- * re.c (rb_reg_quote): should always copy the quoting string.
- [ruby-core:16235]
+Tue May 29 11:01:06 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sun Jun 15 21:26:54 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * win32/win32.c (rb_w32_opendir): store attributes of the second
+ entries or later too.
- * lib/net/pop.rb (Net::POP3::do_finish): clear @n_mails and
- @n_bytes as well. [ruby-core:16144]
+ * win32/win32.c (rb_w32_opendir, rb_w32_readdir): eliminate magic
+ numbers.
-Sun Jun 15 21:07:37 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Jun 7 20:10:51 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/resolv.rb (Resolv::Config.default_config_hash): requires
- win32/resolv to use Win32::Resolv. [ruby-dev:34138]
+ * eval.c, intern.h, ext/thread/thread.c: should not free queue
+ while any live threads are waiting.
+ [ruby-dev:30653]
-Sun Jun 15 20:52:45 2008 Akinori MUSHA <knu@iDaemons.org>
+Thu Jun 7 14:53:46 2007 URABE Shyouhei <shyouhei@ruby-lang.org>
- * parse.y (yycompile): Always prepare a new array for each file's
- SCRIPT_LINES__ storage, instead of appending source lines every
- time a file is re-loaded; submitted by Rocky Bernstein in
- #18517.
+ * eval.c (method_inspect): show proper class name.
+ [ruby-talk:248647], Thanks Calamitas.
-Sun Jun 15 20:28:45 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun May 27 05:24:56 2007 URABE Shyouhei <shyouhei@ruby-lang.org>
- * lib/resolv.rb (Resolv::Hosts): should not use win32/resolv on cygwin.
- [ruby-dev:29945], [ruby-dev:34095]
+ * runruby.rb: eliminate uninitialized variable.
+ [ruby-core:11255]
- * lib/win32/registry.rb (Win32::Registry.expand_environ): try upcased
- name too for cygwin. [ruby-dev:29945]
+Sun May 27 05:19:03 2007 URABE Shyouhei <shyouhei@ruby-lang.org>
- * lib/win32/resolv.rb (Win32::Resolv.get_hosts_path): use expand_path.
+ * eval.c (mnew): call of super via a method object should work again.
+ [ruby-talk:248647], Thanks Calamitas.
-Sun Jun 15 20:27:21 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * test/ruby/test_method.rb (TestMethod::test_method_super): test for
+ above fix.
- * misc/ruby-mode.el (ruby-mode): should use `run-mode-hooks' instead
- of calling `run-hooks' directly to run the mode hook. patch from
- Chiyuan Zhang <pluskid AT gmail.com> in [ruby-core:15915]
+Wed May 23 07:29:53 2007 URABE Shyouhei <shyouhei@ruby-lang.org>
-Sun Jun 15 20:07:30 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * process.c (proc_exec_v): terminate timer thread in advance.
+ [ruby-dev:30581], Thanks H. Holon.
- * numeric.c (fix_coerce): try conversion before type check.
- [ruby-core:15838]
+Wed May 23 06:51:46 2007 URABE Shyouhei <shyouhei@ruby-lang.org>
-Sun Jun 15 19:55:46 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * lib/cgi.rb (CGI#[]): get rid of exceptions being raised.
+ [ruby-dev:30740], Thanks Kentaro KAWAMOTO.
- * bignum.c (BIGZEROP): fix for longer Bignum zeros. [ruby-Bugs-17454]
+Wed May 23 05:49:49 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sun Jun 15 19:53:16 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/extmk.rb, ext/purelib.rb, lib/mkmf.rb, runruby.rb: clear default
+ load path to get rid of load pre-installed extensions/libraries.
+ [ruby-core:11017]
- * bignum.c (big2str_find_n1): check integer overflow.
+Wed May 23 06:14:15 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sun Jun 15 19:51:37 2008 Tanaka Akira <akr@fsij.org>
+ * win32/win32.c (move_to_next_entry): loc also must move forward.
+ [ruby-talk:251987]
- * gc.c (STACK_LENGTH) [SPARC] : 0x80 offset removed. [ruby-dev:33857]
+Wed May 23 05:55:04 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-Sun Jun 15 19:49:10 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * win32/win32.c (init_stdhandle): stderr should be without buffering,
+ but mswin32 use buffering when stderr is not connected to tty.
- * ext/readline/readline.c (readline_event): prevent polling. based on
- a patch from error errorsson in [ruby-Bugs-17675].
+Wed May 23 05:35:42 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sun Jun 15 19:24:42 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * bignum.c (rb_big_pow): truncate all zero BDIGITs. [ruby-dev:30733]
- * parse.y (yycompile): clear ruby_eval_tree_begin if parse failed.
+Wed May 23 05:17:33 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-Sun Jun 15 19:23:23 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/iconv/iconv.c (iconv_s_conv): rdoc fix.
- * parse.y (yycompile): clear ruby_eval_tree_begin too before parse.
+Wed May 23 05:10:02 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sun Jun 15 19:21:26 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * eval.c (rb_thread_priority): rdoc fix; the initial value is
+ inherited from the creating thread. [ruby-core:10607]
- * ext/pty/lib/expect.rb (IO#expect): check if peer is closed.
- [ruby-Bugs-17940]
+Wed May 23 04:22:57 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sun Jun 15 19:19:21 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * dir.c (do_stat, do_lstat, do_opendir): should not warn ENOTDIR.
+ [ruby-talk:248288]
- * ext/iconv/iconv.c (iconv_convert): check upper bound. a patch from
- Daniel Luz at [ruby-Bugs-17910].
+Wed May 23 03:50:35 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sun Jun 15 19:07:41 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * lib/mkmf.rb (libpathflag): not to append RPATHFLAG to current
+ directory.
- * configure.in (ftruncate): check if available.
+ * lib/mkmf.rb (init_mkmf): add current directory to default
+ library path with highest priority. [ruby-core:10960]
- * file.c (rb_file_truncate): check if ftruncate instead of truncate.
+ * lib/mkmf.rb (LINK_SO): LIBPATH to be placed before DLDFLAGS.
-Sun Jun 15 18:59:04 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed May 23 03:33:55 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * configure.in (sigsetmask): check when signal semantics is not POSIX.
+ * lib/monitor.rb (ConditionVariable#wait, mon_enter, mon_exit_for_cond):
+ ensures Thread.critical to be false. [ruby-talk:248300]
- * signal.c (USE_TRAP_MASK): set true if sigprocmask or sigsetmask is
- available.
+Wed May 23 03:25:13 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sat Jun 14 16:12:17 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * util.c (ruby_strtod): exponent is radix 10. [ruby-talk:248272]
- * lib/timeout.rb (Timeout::timeout): made sensitive to location on the
- stack. [ruby-core:15458]
+Wed May 23 03:12:17 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Fri Jun 13 13:10:12 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * configure.in (LDFLAGS): prepend -L. instead appending it to
+ XLDFLAGS. [ruby-core:10933]
- * ext/dl/ptr.c (dlmem_each_i): typo fixed. a patch from IKOMA
-Sun Jun 15 21:01:56 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * configure.in (Makefile): remove $U for automake from MISSING.
+ [ruby-talk:248171]
- * class.c (clone_method): should copy cref as well.
- [ruby-core:15833]
+Wed May 23 02:09:32 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
- Yoshiki <ikoma@mb.i-chubu.ne.jp> in [ruby-dev:33776].
+ * eval.c (rb_yield_0): should not clear state on TAG_NEXT when
+ it's invoked from within lambda body. [ruby-talk:248136]
-Fri Jun 13 12:10:58 2008 URABE Shyouhei <shyouhei@ice.uec.ac.jp>
+ * eval.c (proc_invoke): handle TAG_NEXT which would be caused by
+ next in the lambda body as well.
- * gc.c (rb_newobj): prohibit call of rb_newobj() during gc.
- Submitted by Sylvain Joyeux [ruby-core:12099].
+Wed May 23 01:55:49 2007 NAKAMURA Usaku <usa@ruby-lang.org>
- * ext/dl/ptr.c: do not use LONG2NUM() inside dlptr_free().
- Slightly modified fix bassed on a patch by Sylvain Joyeux
- [ruby-core:12099] [ ruby-bugs-11859 ] [ ruby-bugs-11882 ]
- [ ruby-patches-13151 ].
+ * win32/win32.c (rb_w32_fclose, rb_w32_close): need to save errno
+ before calling original fclose()/close().
-Fri Jun 13 12:09:02 2008 NARUSE, Yui <naruse@ruby-lang.org>
+Wed May 23 01:42:29 2007 Shugo Maeda <shugo@ruby-lang.org>
- * lib/benchmark.rb (Job::Benchmark#item): fix typo.
+ * lib/net/imap.rb (disconnect): call shutdown for
+ SSLSocket. Thanks, Technorama Ltd.
-Fri Jun 13 12:03:31 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed May 23 01:28:14 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * ext/bigdecimal/bigdecimal.c (BigDecimal_to_f): use strtod() for more
- precision. [ruby-talk:290296]
+ * error.c (rb_notimplement), io.c (pipe_open): removed definite
+ articles and UNIX manual section from messages. [ruby-dev:30690]
- * ext/bigdecimal/bigdecimal.c (BASE_FIG): made constant.
+ * io.c (pipe_open): raise NotImplementedError for command "-" on
+ platforms where fork(2) is not available. [ruby-dev:30681]
- * ext/bigdecimal/extconf.rb: ditto. [ruby-dev:33658]
+Wed May 23 00:03:42 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-Fri Jun 13 11:58:34 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/socket/socket.c (s_recv, s_recvfrom): some systems (such as
+ windows) doesn't set fromlen if the socket is connection-oriented.
+ reported by Bram Whillock in [ruby-core:10512] [ruby-Bugs#9061]
- * lib/irb.rb (IRB::Irb::eval_input): rescues Interrupt and other than
- SystemExit and SignalException. [ruby-core:15359]
+Sat Mar 24 23:40:29 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Fri Jun 13 11:56:28 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * node.h (struct rb_thread.locals): explicit as struct.
+ [ruby-core:10585]
- * lib/benchmark.rb (Benchmark::realtime): make Benchmark#realtime
- a bit faster. a patch from Alexander Dymo <dymo@ukrpost.ua> in
- [ruby-core:15337].
+ * eval.c, node.h (enum rb_thread_status, struct rb_thread,
+ rb_curr_thread, rb_main_thread): prefixed. [ruby-core:10586]
-Fri Jun 13 11:42:52 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * file.c (chompdirsep): made an unprefixed name static.
- * io.c (rb_open_file): should check NUL in path.
- <http://www.rubyist.net/~matz/20080125.html#c01>.
+ * io.c (io_fread): ditto.
- * io.c (rb_io_s_popen): ditto.
+Tue May 22 23:27:16 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * io.c (rb_io_reopen): ditto.
+ * eval.c (ruby_cleanup): exit by SystemExit and SignalException in END
+ block. [ruby-core:10609]
- * io.c (next_argv): ditto.
+ * test/ruby/test_beginendblock.rb (test_should_propagate_exit_code):
+ test for exit in END block. [ruby-core:10760]
- * io.c (rb_io_s_foreach): ditto.
+ * test/ruby/test_beginendblock.rb (test_should_propagate_signaled):
+ test for signal in END block.
- * io.c (rb_io_s_readlines): ditto.
+Tue May 22 23:14:19 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * io.c (rb_io_s_read): ditto.
+ * eval.c (rb_provided): check for extension library if SOEXT is
+ explicitly given. [ruby-dev:30657]
-Wed Jun 11 15:06:00 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Tue May 22 21:29:08 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/uri/generic.rb (URI::Generic::inspect): use Kernel#to_s instead
- object_id with printf. [ruby-dev:33347]
+ * bignum.c (rb_big2str0): round up for the most significant digit.
+ [ruby-core:10686]
-Wed Jun 11 14:58:49 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Tue May 22 20:53:02 2007 Akinori MUSHA <knu@iDaemons.org>
- * configure.in: Remove wrong assumptions about Cygwin. a patch from
- Corinna Vinschen in [ruby-Bugs-17018].
+ * ext/thread/thread.c (remove_one): Preserve List invariants;
+ submitted by: MenTaLguY <mental AT rydia.net>
+ in [ruby-core:10598] and [ruby-bugs:PR#9388].
-Mon Jun 9 18:03:32 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Tue Mar 20 15:37:24 2007 URABE Shyouhei <shyouhei@ruby-lang.org>
- * eval.c (eval): check if backtrace is empty. [ruby-core:15040]
+ * distruby.rb: Add zip generation.
-Sun Jun 8 06:07:02 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Mar 16 21:48:11 2007 Akinori MUSHA <knu@iDaemons.org>
- * eval.c (rb_define_alloc_func, rb_undef_alloc_func): should
- define/undef on a signleton class. [ruby-core:09959]
+ * ext/dl/dl.c (rb_ary2cary): Fix a bug in type validation;
+ submitted by sheepman <sheepman AT sheepman.sakura.ne.jp>
+ in [ruby-dev:30554].
-Sun Jun 8 06:03:45 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Mar 16 18:28:06 2007 Akinori MUSHA <knu@iDaemons.org>
- * time.c (time_arg): use converted object. [ruby-core:14759]
+ * ext/etc/etc.c (etc_getgrgid): Fix a bug in Etc::getgrgid()
+ always returning the (real) group entry of the running process;
+ reported by: UEDA Hiroyuki <ueda AT netforest.ad.jp>
+ in [ruby-dev:30586].
-Sun Jun 8 06:01:25 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Mar 16 16:33:58 2007 Akinori MUSHA <knu@iDaemons.org>
- * io.c (fptr_finalize): clear errno first. [ruby-talk:284492]
+ * ext/thread/thread.c (unlock_mutex_inner): Make sure that the
+ given mutex is actually owned by the caller; submitted by:
+ Sylvain Joyeux <sylvain.joyeux AT m4x.org> in [ruby-core:10598].
-Sun Jun 8 05:53:46 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Mar 16 16:21:35 2007 Akinori MUSHA <knu@iDaemons.org>
- * configure.in (TIMEZONE_VOID): check whether timezone requires zero
- arguments. [ruby-dev:32631]
+ * ext/thread/thread.c (wait_condvar, lock_mutex): Fix a problem in
+ ConditionVariable#wait that occurs when two threads that are
+ trying to access the condition variable are also in concurrence
+ for the given mutex; submitted by: Sylvain Joyeux
+ <sylvain.joyeux AT m4x.org> and MenTaLguY <mental AT rydia.net>
+ in [ruby-core:10598].
-Sun Jun 8 05:35:32 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Mar 16 16:17:27 2007 Akinori MUSHA <knu@iDaemons.org>
- * parse.y (f_rest_arg): check if duplicated. [ruby-core:14140]
+ * test/thread/test_thread.rb: Add a test script for the `thread'
+ library. This should result in failure as of now with
+ ext/thread; submitted by: Sylvain Joyeux <sylvain.joyeux AT
+ m4x.org> in [ruby-core:10598].
-Sun Jun 8 05:21:46 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed Mar 14 12:30:00 2007 Shigeo Kobayashi <shigeo@tinyforest.jp>
- * configure.in (RUBY_CHECK_VARTYPE): check if a variable is defined
- and its type.
+ * ext/bigdecimal/bigdecimal.c: BigDecimal("-.31") is now
+ treated as ("-0.31") not as ("0.31").
- * configure.in (timezone, altzone): check for recent cygwin.
+Tue Mar 13 04:04:04 2007 Akinori MUSHA <knu@iDaemons.org>
- * missing/strftime.c (strftime): fix for timezone. [ruby-dev:32536]
+ * stable version 1.8.6 released.
- * lib/mkmf.rb (try_var): should fail for functions.
+Tue Mar 13 02:54:17 2007 Akinori MUSHA <knu@iDaemons.org>
- * ext/readline/extconf.rb: should use have_func for functions instead
- of have_var.
+ * lib/cgi.rb (CGI::header): IIS >= 5.0 does not need the nph
+ assumption any more; submitted by MIYASAKA Masaru <alkaid AT
+ coral.ocn.ne.jp> in [ruby-dev:30537].
-Sun Jun 8 05:09:29 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+Mon Mar 12 11:07:44 2007 Akinori MUSHA <knu@iDaemons.org>
- * lib/uri/common.rb (URI::REGEXP::PATTERN): typo in REG_NAME
- regular expression. a patch from Ueda Satoshi
- <s-ueda AT livedoor.jp>. [ruby-dev:32514]
+ * ext/openssl/ossl_asn1.c (Init_ossl_asn1): Let rdoc know about
+ externally defined modules; submitted by Technorama
+ Ltd. <oss-ruby AT technorama.net> in [ruby-bugs:PR#4704].
-Sun Jun 8 05:05:05 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/openssl/ossl_bn.c (Init_ossl_bn): Ditto.
- * lib/cgi.rb (read_multipart): exclude blanks from header values.
- [ruby-list:44327]
+ * ext/openssl/ossl_cipher.c (Init_ossl_cipher): Ditto.
-Sun Jun 8 05:00:44 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/openssl/ossl_digest.c (Init_ossl_digest): Ditto.
- * bignum.c (rb_cstr_to_inum): trailing spaces may exist at sqeezing
- preceeding 0s. [ruby-core:13873]
+ * ext/openssl/ossl_hmac.c (Init_ossl_hmac): Ditto.
-Sun Jun 8 04:56:55 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/openssl/ossl_pkey.c (Init_ossl_pkey): Ditto.
- * eval.c (error_print): put newline unless multiple line message ends
- with a newline. [ruby-dev:32429]
+ * ext/openssl/ossl_pkey_dh.c (Init_ossl_dh): Ditto.
-Sun Jun 8 04:54:36 2008 James Edward Gray II <jeg2@ruby-lang.org>
+ * ext/openssl/ossl_pkey_dsa.c (Init_ossl_dsa): Ditto.
- Merged 14070 from trunk.
-
- * lib/xmlrpc/server.rb (XMLRPC::Server#server): Improve signal handling so
- pressing control-c in the controlling terminal or sending SIGTERM stops
- the XML-RPC server.
+ * ext/openssl/ossl_pkey_rsa.c (Init_ossl_rsa): Ditto.
-Sun Jun 8 04:46:45 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/openssl/ossl_rand.c (Init_ossl_rand): Ditto.
- * parse.y (newline_node): set line from outermost node before removing
- NODE_BEGIN. [ruby-dev:32406]
+ * ext/openssl/ossl_ssl.c (Init_ossl_ssl): Ditto.
-Sun Jun 8 04:37:34 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Mon Mar 12 01:23:50 2007 Akinori MUSHA <knu@iDaemons.org>
- * parse.y (stmt): remove unnecessary NODE_BEGIN. [ruby-core:13814]
+ * ext/dl/sym.c (rb_dlsym_inspect): Use "0x%x" rather for pointers.
+ This might not be very right but it is commonly used in other
+ parts of the code; submitted by sheepman <sheepman AT
+ sheepman.sakura.ne.jp> in [ruby-dev:30532].
-Sun Jun 8 04:18:50 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ext/dl/ptr.c (rb_dlptr_inspect): Ditto.
- * object.c (nil_plus): remove unused function. [ruby-core:13737]
+ * ext/dl/lib/dl/import.rb (DL::Importable::Internal::import,
+ DL::Importable::Internal::callback): Avoid race condition for an
+ instance variable; submitted by sheepman <sheepman AT
+ sheepman.sakura.ne.jp> in [ruby-dev:30530].
-Sun Jun 8 04:15:40 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Mar 11 19:04:29 2007 Akinori MUSHA <knu@iDaemons.org>
- * eval.c (rb_alias): do not call hook functions until initialization
- finishes. [ruby-talk:279538]
+ * misc/README: Add a note about ruby-electric.el.
-Sun Jun 8 04:12:50 2008 Masaki Suketa <masaki.suketa@nifty.ne.jp>
+ * misc/ruby-mode.el (ruby-non-block-do-re): Fix
+ ruby-non-block-do-re. [ruby-core:03719]
- * ext/win32ole/win32ole.c (ole_invoke): bug fix. [ruby-talk:279100]
+ * misc/inf-ruby.el: Synchronize the comment section with trunk.
-Sun Jun 8 03:54:52 2008 NAKAMURA Usaku <usa@ruby-lang.org>
+ * misc/README, misc/rdebug.el: Add rdebug.el, Emacs ruby-debug
+ interface based on rubydb3x.el; submitted by Martin Nordholts
+ <enselic AT gmail.com> in [ruby-bugs:PR#9023].
- * ext/curses/extconf.rb: check macro if cannot find func.
- [ruby-list:44224]
+Sun Mar 11 17:51:46 2007 Akinori MUSHA <knu@iDaemons.org>
-Sun Jun 8 03:50:40 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ext/dl/mkcallback.rb (mkfunc): Make sure that a callback
+ function is found in the function table before trying to call
+ it; submitted by sheepman <sheepman AT sheepman.sakura.ne.jp>
+ in [ruby-dev:30524].
- * lib/cgi/session.rb (CGI::Session::FileStore::restore): use
- lockfile for exclusive locks. a patch from <tommy AT tmtm.org>.
- [ruby-dev:32296]
+Sun Mar 11 17:30:53 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sun Jun 8 03:46:55 2008 Tanaka Akira <akr@fsij.org>
+ * eval.c (error_handle): no message when exiting by signal.
- * missing/isinf.c (isinf): don't define if the macro is defined.
+ * eval.c (ruby_cleanup): re-send signal. [ruby-dev:30516]
-Sun Jun 8 03:34:23 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * eval.c (rb_thread_interrupt): instantiate SignalException.
- * numeric.c (round): fallback definition.
+ * eval.c (rb_thread_signal_raise): now takes signal number instead
+ of signal name.
- * numeric.c (flo_divmod, flo_round): use round() always.
- [ruby-dev:32269]
+ * intern.h (rb_thread_signal_raise, ruby_default_signal): prototypes.
-Sun Jun 8 03:34:23 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * signal.c (esignal_init): takes a signal number and an optional
+ signal name.
- * numeric.c (flodivmod): work around for infinity.
+ * signal.c (interrupt_init): pass SIGINT always.
- * numeric.c (flo_divmod): work around for platforms have no round().
- [ruby-dev:32247]
+ * signal.c (ruby_default_signal): invoke system default signal
+ handler.
-Sun Jun 8 03:34:23 2008 URABE Shyouhei <shyouhei@ice.uec.ac.jp>
+ * signal.c (rb_signal_exec, trap): handle SIGTERM. [ruby-dev:30505]
- * numeric.c (flo_divmod): round to the nearest integer.
- [ ruby-Bugs-14540 ]
+Tue Mar 6 19:03:42 2007 Akinori MUSHA <knu@iDaemons.org>
-Sun Jun 8 03:08:11 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ext/digest/lib/md5.rb (MD5::new, MD5::md5): Do not modify
+ Digest::MD5.
- * lib/rexml/encodings/SHIFT-JIS.rb (REXML::Encoding): place -x for
- nkf conversion. a patch from <moonwolf AT moonwolf.com>.
- [ruby-dev:32183]
+ * ext/digest/lib/sha1.rb (SHA1::new, SHA1::sha1): Ditto.
-Sun Jun 8 03:05:59 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * lib/shell/process-controller.rb: fix thread synchronization
+ problem for [ruby-dev:30477].
- * lib/optparse.rb (OptionParser::Switch::summarize): fix for long form
- option with very long argument. a patch from Kobayashi Noritada
- <nori1 AT dolphin.c.u-tokyo.ac.jp> in [ruby-list:44179].
+ * ext/digest/lib/md5.rb (MD5::new, MD5::md5): Catch up with
+ Digest's API changes; noted by: Kazuhiro Yoshida <moriq AT
+ moriq.com> in [ruby-dev:30500].
-Sun Jun 8 03:03:27 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/digest/lib/sha1.rb (SHA1::new, SHA1::sha1): Ditto.
+
+ * time.c (time_to_s): Back out the format changes; discussed
+ in [ruby-dev:30495].
- * numeric.c (fix_pow): returns infinity for 0**-1. [ruby-dev:32084]
+ * ext/tk/sample/irbtkw.rbw: fails to exit process.
-Sun Jun 8 02:57:32 2008 James Edward Gray II <jeg2@ruby-lang.org>
+Mon Mar 5 20:26:10 2007 Akinori MUSHA <knu@iDaemons.org>
- Merged 13781 from trunk.
+ * time.c (time_to_s): Correct the wrong format which did not
+ really conform to RFC 2822; pointed out by: OHARA Shigeki <os at
+ iij.ad.jp> in [ruby-dev:30487].
- * lib/net/telnet.rb (Net::Telnet#login): Allowing "passphrase" in
- addition to "password" for Telnet login prompts. [ruby-Bugs-10746]
+Sun Mar 4 23:53:27 2007 Minero Aoki <aamine@loveruby.net>
-Wed Oct 25 06:46:21 2007 James Edward Gray II <jeg2@ruby-lang.org>
+ * lib/fileutils.rb (mv): could not move a directory between
+ different filesystems. [ruby-dev:30411]
- Merged 13779 from trunk.
+Sun Mar 4 23:46:40 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/net/telnet.rb (Net::Telnet#login): Making the password prompt
- pattern case insensitive. [ruby-Bugs-10746]
+ * file.c (rb_file_s_utime): allow nil to set the current time.
-Sun Jun 8 02:54:30 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * lib/fileutils.rb (touch): ditto, and added :mtime and :nocreate
+ options. fixed: [ruby-talk:219037]
- * io.c (rb_io_tell, rb_io_seek): check errno too. [ruby-dev:32093]
+Sun Mar 4 23:19:00 2007 WATANABE Hirofumi <eban@ruby-lang.org>
-Sun Jun 8 01:51:52 2008 James Edward Gray II <jeg2@ruby-lang.org>
+ * util.c (push_element): should return a int value.
- Merged 13767, 13768, 13769, and 13770 from trunk.
+Sun Mar 4 01:06:55 2007 Akinori MUSHA <knu@iDaemons.org>
- * lib/xmlrpc/parser.rb (XMLRPC::Convert::dateTime): Fixing a bug that
- caused time zone conversion to fail for some ISO 8601 date formats.
- [ruby-Bugs-12677]
+ * lib/set.rb (Set#^, Set#&): Correct documentation. Those methods
+ return sets, not arrays; noted by Oliver Frank Wittich <nietz AT
+ mangabrain.de>.
- * lib/xmlrpc/client.rb (XMLRPC::Client#do_rpc): Explicitly start
- the HTTP connection to support keepalive requests. [ruby-Bugs-9353]
+Sat Mar 3 21:41:31 2007 Akinori MUSHA <knu@iDaemons.org>
- * lib/xmlrpc/client.rb (XMLRPC::Client#do_rpc): Improving the error
- message for Content-Type check failures. [ruby-core:12163]
+ * eval.c (stack_check): Unset inline to fix build with GCC 3.4.6;
+ submitted by: NISHIMATSU Takeshi <t_nissie AT yahoo.co.jp> in
+ [ruby-list:43218].
+ cf. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24556
- * lib/xmlrpc/utils.rb (XMLRPC::ParseContentType#parse_content_type):
- Making Content-Type checks case insensitive. [ruby-Bugs-3367]
+Sat Mar 3 19:07:05 2007 Akinori MUSHA <knu@iDaemons.org>
-Sun Jun 8 01:45:27 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/thread/thread.c (push_list): Use ALLOC().
- * marshal.c (r_bytes0): refined length check. [ruby-dev:32059]
+ * ext/thread/thread.c (rb_mutex_alloc): Ditto.
-Sun Jun 8 01:45:27 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/thread/thread.c (rb_condvar_alloc): Ditto.
- * marshal.c (r_bytes0): check if source has enough data.
- [ruby-dev:32054]
+Sat Mar 3 18:56:40 2007 Akinori MUSHA <knu@iDaemons.org>
-Sun Jun 8 01:37:58 2008 Tanaka Akira <akr@fsij.org>
+ * NEWS: Add a note for String#intern.
- * ext/socket/socket.c (s_accept_nonblock): make accepted fd
- nonblocking. [ruby-talk:274079]
+Sat Mar 3 18:36:35 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sun Jun 8 01:28:42 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * eval.c (rb_provided): return true only for features loaded from
+ .rb files, and not search actual library type. [ruby-dev:30414]
- * win32/mkexports.rb: deal with __fastcall name decorations.
- [ruby-list:44111]
+ * eval.c (rb_feature_p): check loading_tbl if the given ext is
+ empty. [ruby-dev:30452]
-Sun Jun 8 01:23:29 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * eval.c (rb_feature_p): fix possible buffer overrun.
- * lib/rexml/source.rb (REXML::SourceFactory::SourceFactory): typo
- fixed. [ruby-list:44099]
+Sat Mar 3 16:30:39 2007 Akinori MUSHA <knu@iDaemons.org>
-Sun Jun 8 01:17:45 2008 NAKAMURA Usaku <usa@ruby-lang.org>
+ * env.h (SCOPE_CLONE): Introduce a new scope flag to prevent a
+ local_tbl region from getting freed many times; submitted by
+ Chikanaga Tomoyuki <chikanag AT nippon-control-system.co.jp> in
+ [ruby-dev:30460].
- * {bcc32,win32}/Makefile.sub (COMMON_MACROS): workaround for old SDK's
- bug. [ruby-core:12584]
+ * eval.c (proc_invoke): Ditto.
-Sun Jun 8 00:56:44 2008 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ * gc.c (obj_free): Ditto.
- * lib/net/http.rb, lib/open-uri.rb: remove
- Net::HTTP#enable_post_connection_check. [ruby-dev:31960]
+ * parse.y (top_local_setup_gen): Ditto.
- * lib/net/imap.rb: hostname should be verified against server's
- indentity as persented in the server's certificate. [ruby-dev:31960]
+Sat Mar 3 16:09:27 2007 Akinori MUSHA <knu@iDaemons.org>
- * ext/openssl/lib/net/telnets.rb, ext/openssl/lib/net/ftptls.rb: ditto.
+ * object.c (rb_obj_ivar_set): RDoc updated according to a
+ suggestion from Brian Candler <B.Candler AT pobox.com>.
+ [ruby-core:10469]
-Thu Jun 5 16:19:27 2008 NAKAMURA Usaku <usa@ruby-lang.org>
+Sat Mar 3 15:41:33 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * win32/win32.c (make_cmdvector): adjust escaped successive
- double-quote handling. (merge from trunk)
+ * parse.y (stmt, arg): should not omit lhs of OP_ASGN1 even if
+ empty. [ruby-dev:30452]
-Thu Jun 5 12:24:25 2008 NAKAMURA Usaku <usa@ruby-lang.org>
+Thu Mar 1 04:08:30 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * win32/win32.c (init_env): initialize HOME and USER environment
- variables unless set. [ruby-core:12328] (merge from trunk)
+ * mkconfig.rb (patchlevel): read from version.h.
- * win32/win32.c (NtInitialize, getlogin): ditto.
+Thu Mar 1 03:42:09 2007 Akinori MUSHA <knu@iDaemons.org>
- * configure.in, win32/Makefile.sub (LIBS): need to link shell32
- library for SH* functions on mswin32 and mingw32.
+ * ext/digest/digest.c (get_digest_base_metadata): Allow inheriting
+ Digest::Base subclasses, which was unintentionally made
+ impossible while restructuring Digest classes.
-Thu Jun 5 12:21:06 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+Wed Feb 28 22:10:55 2007 Akinori MUSHA <knu@iDaemons.org>
- * gc.c (id2ref): valid id should not refer T_VALUE nor T_ICLASS.
- [ruby-dev:31911]
+ * doc/NEWS-1.8.0: Rename NEWS to NEWS-1.8.0. This is way too old
+ NEWS.
-Wed Jun 4 16:39:56 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * NEWS: Add NEWS, a document file to keep user visible feature
+ changes between releases.
- * Makefile.in (ext/extinit.o): use $(OUTFLAG) as well as other
- objects. [ruby-Bugs-14228]
+ * configure.in (ac_cv_func_fcntl): fcntl support for MinGW.
-Tue Jun 3 16:13:40 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * missing/flock.c: workaround for MinGW.
- * parse.y (yyerror): limit error message length. [ruby-dev:31848]
+ * ext/openssl/extconf.rb: no need to check unistd.h and sys/time.h.
+ they are already checked at configure.
+ reported by KOBAYASHI Yasuhiro [ruby-list:43225]
- * regex.c (re_mbc_startpos): separated from re_adjust_startpos.
+ * lib/mkmf.rb ($DEFLIBPATH): default library paths ($(topdir), etc)
+ should be the first elements of library paths list.
+ reported by KOBAYASHI Yasuhiro [ruby-list:43225]
-Tue Jun 3 15:27:11 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * test/{dbm,gdbm}/test_{dbm,gdbm}.rb: shouldn't use host_os. use
+ target_os instead. reported by KOBAYASHI Yasuhiro [ruby-list:43225]
- * gc.c (os_obj_of, os_each_obj): hide objects to be finalized.
- [ruby-dev:31810]
+ * mkconfig.rb (RbConfig): add CONFIG['PATCHLEVEL']
-Wed Jun 4 19:15:57 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * common.mk: new target dist
- * eval.c (remove_method): should not remove undef place holder.
- [ruby-dev:31817]
+ * distruby.rb: new file
-Tue Jun 3 15:05:48 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * configure.in (--enable-auto-image-base): avoid the neccessity to
+ rebase the shared libs as much as possible;
+ submitted by Corinna Vinschen <spam at vinschen.de> in
+ [ruby-talk:240964].
- * process.c (struct rb_exec_arg): proc should be a VALUE.
+Wed Feb 28 20:51:32 2007 URABE Shyouhei <shyouhei@ruby-lang.org>
- * process.c (rb_f_exec): suppress a warning.
+ * pack.c (pack_unpack): properly ignore non-base64 octets such as
+ UTF-8 encoded BOMs; submitted by SOUMA Yutaka <holon@radastery.jp>
+ to fix [ruby-core:10437]
- * process.c (rb_detach_process): cast for the platforms where size of
- pointer differs from size of int.
+Tue Feb 27 21:50:10 2007 WATANABE Hirofumi <eban@ruby-lang.org>
- * process.c (rb_f_exec, rb_f_system): should not exceptions after
- fork. [ruby-core:08262]
+ * util.c (__crt0_glob_function): use ruby_glob() instead of rb_globi().
-Wed May 21 01:32:56 2008 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ * configure.in (ac_cv_func_setrlimit): workaround for djgpp.
- * lib/webrick/httpservlet/filehandler.rb: should normalize path
- name in path_info to prevent script disclosure vulnerability on
- DOSISH filesystems. (fix: CVE-2008-1891)
- Note: NTFS/FAT filesystem should not be published by the platforms
- other than Windows. Pathname interpretation (including short
- filename) is less than perfect.
+Tue Feb 27 20:49:19 2007 Akinori MUSHA <knu@iDaemons.org>
- * lib/webrick/httpservlet/abstract.rb
- (WEBrick::HTTPServlet::AbstracServlet#redirect_to_directory_uri):
- should escape the value of Location: header.
+ * lib/base64.rb (Base64::b64encode): Fix documentation; submitted
+ by David Symonds <dsymonds@gmail.com> in [ruby-core:10432].
- * lib/webrick/httpservlet/cgi_runner.rb: accept interpreter
- command line arguments.
+ * regex.c (calculate_must_string, slow_search, re_search): Silence
+ warnings regarding char * vs. unsigned char * mismatch;
+ submitted by Lyle Johnson <lyle.johnson@gmail.com>
+ in [ruby-core:10416].
-Sun May 18 01:57:44 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/bigdecimal/bigdecimal.c (BigDecimal_load): Ditto.
- * file.c (isdirsep): backslash is valid path separator on cygwin too.
- backported from 1.8 HEAD.
+ * ext/digest/sha1/sha1ossl.c (SHA1_Finish): Ditto.
-Sat May 17 23:53:57 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/digest/rmd160/rmd160ossl.c (RMD160_Finish): Ditto.
- * file.c (file_expand_path): fix for short file name on Cygwin.
+ * ext/digest/digest.c (rb_digest_base_finish,
+ rb_digest_base_update): Ditto.
-Sat May 17 23:50:29 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/nkf/nkf.c (rb_str_resize, rb_nkf_kconv, rb_nkf_guess1,
+ rb_nkf_guess2): Ditto.
- * file.c (OpenFile): prevent conflict on Windows.
+ * ext/thread/thread.c (wait_list_cleanup, rb_mutex_try_lock):
+ Eliminate rb_thread_critical switching where unnecessary;
+ implied by shugo in [ruby-dev:30412].
- * file.c (USE_NTFS): fixed merge miss.
+ * ext/thread/thread.c (set_critical): Merge in
+ thread_exclusive_ensure().
-Sat May 17 12:36:46 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/thread/thread.c: Consistently use 0 and 1 for
+ rb_thread_critical values.
- * file.c (file_expand_path): rb_str_set_len is not backported.
+ * ext/thread/thread.c: Use xmalloc()/xfree() instead of
+ malloc()/free(); pointed out by shugo in [ruby-dev:30412].
-Sat May 17 12:15:48 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * lib/test/unit/autorunner.rb (Test::Unit::AutoRunner::initialize):
+ Initialize @workdir properly to silence a warning under -w.
+ Submitted by <tommy at tmtm.org> in [ruby-dev:30400].
- * file.c (file_expand_path): support for alternative data stream
- and ignored trailing garbages of NTFS.
+Sun Feb 25 02:50:51 2007 Akinori MUSHA <knu@iDaemons.org>
- * file.c (rb_file_s_basename): ditto.
+ * defines.h: Pull the RUBY_MBCHAR_MAXSIZE definition from trunk,
+ which is necessary for dir.c to compile on djgpp and emx.
- * file.c (rb_file_s_extname): ditto.
+Sat Feb 24 17:04:01 2007 Tadayoshi Funaba <tadf@dotrb.org>
-Mon Mar 3 23:36:41 2008 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ * lib/date/format.rb: updated based on date2 4.0.3.
- * lib/webrick/httpservlet/filehandler.rb: should normalize path
- separators in path_info to prevent directory traversal attacks
- on DOSISH platforms.
- reported by Digital Security Research Group [DSECRG-08-026].
+Sat Feb 24 17:01:02 2007 Minero Aoki <aamine@loveruby.net>
- * lib/webrick/httpservlet/filehandler.rb: pathnames which have
- not to be published should be checked case-insensitively.
+ * ext/racc/cparse/cparse.c (cparse_params_mark): remove useless
+ rb_gc_mark. Thanks Tomoyuki Chikanaga. [ruby-dev:30405]
-Sun Sep 23 21:57:25 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Sat Feb 24 16:53:09 2007 NAKAMURA Usaku <usa@ruby-lang.org>
- * lib/net/http.rb: an SSL verification (the server hostname should
- be matched with its certificate's commonName) is added.
- this verification can be skipped by
- "Net::HTTP#enable_post_connection_check=(false)".
- suggested by Chris Clark <cclark at isecpartners.com>
+ * signal.c (sighandler): need to tell to be interrupted to main
+ context when handler is installed.
- * lib/net/open-uri.rb: use Net::HTTP#enable_post_connection_check to
- perform SSL post connection check.
+ * win32/win32.[ch] (rb_win32_interrupted): new function to listen
+ interrupt.
- * ext/openssl/lib/openssl/ssl.c
- (OpenSSL::SSL::SSLSocket#post_connection_check): refine error message.
+ * win32/win32.c (set_pioinfo_extra): new function for VC++8 SP1
+ workaround. [ruby-core:10259]
-Sun Sep 23 06:08:38 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * win32/win32.c (NtInitialize): call above function.
- * ext/stringio/stringio.c (strio_init): separate from strio_initialize
- to share with strio_reopen properly. [ruby-Bugs-13919]
+Fri Feb 23 13:04:43 2007 Akinori MUSHA <knu@iDaemons.org>
-Sun Sep 23 05:42:35 2007 URABE Shyouhei <shyouhei@ruby-lang.org>
+ * numeric.c (fix_cmp, fix_equal): Remove FIX2LONG() to optimize.
+ suggested in
+ http://t-a-w.blogspot.com/2007/02/making-ruby-faster.html.
+ [ruby-talk:240223]
- * lib/rdoc/options.rb (Options::check_diagram): dot -V output
- changed. [ ruby-Bugs-11978 ], Thanks Florian Frank.
+Fri Feb 23 12:47:13 2007 James Edward Gray II <james@grayproductions.net>
-Mon Sep 17 04:47:02 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/xmlrpc/client.rb (XMLRPC::Client::do_rpc): Make the
+ Content-Length parameter optional for responses in
+ xmlrpc/client.rb; suggested by Daniel Berger
+ <Daniel.Berger@qwest.com> and approved by the maintainer.
- * ruby.c (proc_options): -W should be allowed in RUBYOPT
- environment variable. [ruby-core:12118]
+ * lib/xmlrpc/create.rb (XMLRPC::Create::conv2value): Add DateTime
+ support to xmlrpc; approved by the maintainer.
-Mon Sep 17 04:31:46 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Mon Feb 19 18:33:30 2007 Akinori MUSHA <knu@iDaemons.org>
- * range.c (range_step): fixed integer overflow. [ruby-dev:31763]
+ * ext/socket/socket.c (unix_peeraddr): wrong syscall name in error
+ message for #peeraddr. a patch from Sam Roberts
+ <sroberts at uniserve.com>. [ruby-core:10366]
-Fri Sep 7 14:57:36 2007 URABE Shyouhei <shyouhei@ice.uec.ac.jp>
+Mon Feb 19 18:27:42 2007 Akinori MUSHA <knu@iDaemons.org>
- * ruby.c (rubylib_mangled_path): eliminate RSTRING_PTR
- [ruby-dev:31679]
+ * configure.in, defines.h, eval.c (rb_feature_p, rb_provided,
+ load_wait, search_required, rb_require_safe), ext/extmk.rb: Fix
+ a bug where a statically linked extension cannot be autoloaded.
+ [ruby-dev:30023] / [ruby-dev:30239]
- * ruby.c(push_include_cygwin): ditto.
+Thu Feb 15 20:31:07 2007 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/uri/ftp.rb: Revert the previous change pending discussion.
+
+Fri Feb 16 11:18:21 2007 Eric Hodel <drbrain@segment7.net>
-Fri Sep 7 14:32:38 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/.document: Apply patch for irb, e2mmap and README by Hugh Sasse
+ <hgs at dmu.ac.uk> from [ruby-core:10135]
- * array.c (rb_ary_subseq): need integer overflow check.
- [ruby-dev:31736]
+ * lib/prettyprint.rb: Suppress RDoc for PrettyPrint test suite.
- * array.c (rb_ary_splice): ditto. [ruby-dev:31737]
+Thu Feb 15 18:10:09 2007 Akinori MUSHA <knu@iDaemons.org>
- * array.c (rb_ary_fill): ditto. [ruby-dev:31738]
+ * dir.c (glob_helper): Fix the function declaration.
- * string.c (rb_str_splice): integer overflow for length.
- [ruby-dev:31739]
+Thu Feb 15 16:55:33 2007 Akinori MUSHA <knu@iDaemons.org>
-Fri Sep 7 14:27:33 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * version.h: Branch off ruby_1_8_6 from ruby_1_8 in preparation
+ for the forthcoming 1.8.6 release.
- * eval.c (mnew): should preserve noex as safe_level.
+Thu Feb 15 16:44:14 2007 Akinori MUSHA <knu@iDaemons.org>
- * eval.c (rb_call0): tighten security check condition..
+ * lib/uri/generic.rb (URI::Generic::userinfo): Considering how
+ `scheme://user:@...', `scheme://:password@...' and
+ `scheme://:@...' are parsed, an empty user name or password
+ should be allowed and represented as it is.
-Fri Sep 7 14:19:16 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Feb 15 11:46:05 2007 KIMURA Koichi <hogemuta@gmail.com>
- * configure.in (group_member): check if presents.
+ * dir.c, win32/win32.c, win32/dir.h, ruby.h, intern.h: Bring
+ encoding aware globbing support in from trunk. Dir.[] and
+ Dir.glob() can now take many patterns in an array. Minor fixes
+ will follow.
- * configure.in (XCFLAGS): add _GNU_SOURCE on linux.
+Thu Feb 15 11:00:26 2007 Akinori MUSHA <knu@iDaemons.org>
- * file.c (group_member): use system routine if available.
+ * lib/uri/generic.rb (URI::Generic::userinfo): should support
+ empty password. [ruby-core:10290]
-Fri Sep 7 14:14:19 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/uri/generic.rb (URI::Generic::set_password): password can be
+ cleared by nil. [ruby-core:10290]
- * include/ruby/defines.h (flush_register_windows): call "ta 0x03"
- even on Linux/Sparc. [ruby-dev:31674]
+ * lib/uri/common.rb (escape): regard second string argument as a
+ character set properly. [ruby-dev:27692]
-Fri Sep 7 14:12:37 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
+ * lib/uri/ftp.rb: Attempt to conform to RFC 1738 with regard to
+ relative/absolute paths.
- * ext/win32ole/win32ole.c (ole_type_progid, reg_enum_key,
- reg_get_val, ole_wc2mb): fix the bug. Thanks, arton.
- [ruby-dev:31576]
+ * lib/uri: Lovely RDOC patches from mathew (metaATpoboxDOTcom).
-Fri Sep 7 14:02:10 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Feb 15 10:57:38 2007 Tietew <tietew@tietew.net>>
- * process.c (detach_process_watcher): should not pass the pointer
- to an auto variable to the thread to be created. pointed and
- fix by KUBO Takehiro <kubo at jiubao.org> [ruby-dev:30618]
+ * lib/cgi.rb (CGI::unescapeHTML): invalid decoding for single
+ unescaped ampersand. a patch from Tietew
+ <tietew+ruby-dev at tietew.net> in [ruby-dev:30292].
+ fixed: [ruby-dev:30289]
-Fri Sep 7 13:52:36 2007 Tanaka Akira <akr@fsij.org>
+Thu Feb 15 10:48:40 2007 MenTaLguY <mental@rydia.net>
- * bignum.c (big_lshift): make shift offset long type.
- (big_rshift): ditto.
- (rb_big_lshift): ditto.
- (big_rshift): ditto.
- [ruby-dev:31434]
+ * ext/thread/thread.c: Handle interrupted waits correctly.
+ [ruby-bugs:PR#8663]
-Thu Aug 16 08:44:55 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed Feb 14 19:22:15 2007 Akinori MUSHA <knu@iDaemons.org>
- * hash.c (rb_hash_delete_key): delete the entry without calling block.
+ * ext/digest/lib/digest.rb (Digest::self.const_missing): Drop
+ autoloads for sha2 classes in favor of handling in
+ const_missing(), to work around a problem exposed on OS X.
- * hash.c (rb_hash_shift): should consider iter_lev too.
+Tue Feb 13 02:21:12 2007 Sam Roberts <sroberts@uniserve.com>
- * hash.c (delete_if_i): use rb_hash_delete_key() so that the block
- isn't called twice. [ruby-core:11556]
+ * io.c (rb_f_syscall): Fix buffer overflow with syscall
+ arguments. [ruby-bugs:PR#8541]
-Thu Aug 16 08:43:50 2007 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Sun Feb 11 07:46:45 2007 Akinori MUSHA <knu@iDaemons.org>
- * lib/rinda/tuplespace.rb: fix Rinda::TupleSpace keeper thread bug.
- the thread is started too early. [ruby-talk:264062]
+ * lib/cgi.rb (CGI::QueryExtension::read_multipart): Properly parse
+ a quoted-string in a Content-Disposition value.
- * test/rinda/test_rinda.rb: ditto.
+Sun Feb 11 06:27:54 2007 Akinori MUSHA <knu@iDaemons.org>
-Thu Aug 16 08:40:38 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * configure.in, ext/thread/extconf.rb, lib/thread.rb: Add a
+ configure option `--disable-fastthread', to choose the original,
+ pure ruby version of the "thread" library instead of the new,
+ much faster implementation in ext/thread.
- * ext/pty/pty.c (establishShell): handshaking before close slave
- device. [ruby-talk:263410]
+Sun Feb 11 06:22:20 2007 Akinori MUSHA <knu@iDaemons.org>
-Thu Aug 16 08:29:39 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/Setup: Add thread except for platforms without threads
+ support.
- * configure.in (ac_cv_func_isinf): set yes also on OpenSolaris.
- [ruby-Bugs-12859]
+Sun Feb 11 06:15:16 2007 Akinori MUSHA <knu@iDaemons.org>
-Thu Aug 16 08:28:16 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/thread/lib/thread.rb: Add a replacement of thread.rb that
+ loads this extension.
- * lib/rexml/encodings/{ISO-8859-15,CP-1252}.rb: fixed invalid syntax.
+Sun Feb 11 05:39:47 2007 Akinori MUSHA <knu@iDaemons.org>
-Thu Aug 16 08:26:08 2007 Tadayoshi Funaba <tadf@dotrb.org>
+ * lib/thread.rb: Remove an ineffective part of the code.
- * lib/README: fixed a typo.
+Sun Feb 11 05:32:54 2007 Akinori MUSHA <knu@iDaemons.org>
-Thu Aug 16 08:20:50 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/thread/thread.c (rb_thread_exclusive): Implement
+ Thread.exclusive.
- * ext/extmk.rb (extmake): save all CONFIG values.
+Sun Feb 11 05:26:51 2007 Akinori MUSHA <knu@iDaemons.org>
- * ext/extmk.rb (extmake): remove mkmf.log at clean, and extconf.h at
- distclean, respectively.
+ * ext/thread/thread.c: Get rid of use of a dummy function.
- * ext/extmk.rb: remove rdoc at clean, and installed list file at
- distclean, respectively.
+Sun Feb 11 01:45:31 2007 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Thu Aug 16 07:58:18 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/thread/thread.c (Init_thread): Define missing aliases:
+ Queue#enq and SizedQueue#enq.
- * sprintf.c (rb_f_sprintf): should not check positional number as
- width. [ruby-core:11838]
+Sat Feb 10 09:27:35 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-Thu Aug 16 07:52:24 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/win32ole/win32ole.c (ole_variant2val): fix compile error
+ on VC++.
- * dln.c (conv_to_posix_path): removed.
+Sat Feb 10 07:41:52 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
- * ruby.c (rubylib_mangled_path, rubylib_mangled_path2): return
- VALUE instead of a pointer to static buffer.
+ * ext/win32ole/win32ole.c (ole_variant2val): fix the bug when
+ SAFEARRAY pointer is NULL.
- * ruby.c (push_include_cygwin): fixed buffer overflow.
- [ruby-dev:31297]
+Sat Feb 10 00:13:11 2007 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ruby.c (ruby_init_loadpath): not convert built-in paths.
+ * ext/tk/lib/tk.rb: fix typo (TkConfigMethod::__confinfo_cmd,
+ __conv_keyonly_opts).
-Thu Aug 16 07:51:37 2007 Akinori MUSHA <knu@iDaemons.org>
+Fri Feb 9 20:44:53 2007 Akinori MUSHA <knu@iDaemons.org>
- * defines.h: Pull the RUBY_MBCHAR_MAXSIZE definition from trunk,
- which is necessary for dir.c to compile on djgpp and emx.
+ * ext/thread: Make style fixes (mostly de-K&R'ism) to match the
+ rest of the source code.
-Thu Aug 16 07:42:10 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/thread: Make USE_MEM_POOLS an extconf option.
- * intern.h (is_ruby_native_thread): removed since declared as an int
- function in ruby.h already.
+Fri Feb 9 20:43:01 2007 Akinori MUSHA <knu@iDaemons.org>
-Thu Aug 16 07:40:41 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/thread: Import the "fastthread" implementation by MenTaLguY
+ in the original form. This module is not hooked into the build
+ yet since it needs some style fixes and adjustments.
- * file.c (rb_file_s_rename): deleted code to get rid of a bug of
- old Cygwin.
+Fri Feb 9 15:46:09 2007 Akinori MUSHA <knu@iDaemons.org>
- * file.c (rb_file_truncate): added prototype of GetLastError()
- on cygwin. [ruby-dev:31239]
+ * ext/bigdecimal: Synchronize with trunk. Better function
+ prototypes, removal of a useless method `!=', and document
+ updates.
- * intern.h (is_ruby_native_thread): prototype.
+Tue Feb 06 22:06:45 2007 NARUSE, Yui <naruse@ruby-lang.org>
- * missing/strftime.c (strftime): fix printf format and actual
- arguments.
+ * ext/nkf/nkf-utf8/{nkf.c,utf8tbl.c}:
+ imported nkf 2007-01-28.
+ * Fixed: can't decode MIME encode JIS string.
+ * Fixed: Fullwitdh-halfwidth conversion.
+ * Support DoCoMo's and Softbank's EMOJI
+ * Support CP932, CP5022x, eucJP-ms UDC
+ * Support UTF-32 encoding
+ * Support beyond BMP
+ [ruby-dev:29700] [ruby-dev:29922] [ruby-dev:30144]
- * ext/Win32API/Win32API.c (Win32API_initialize): ditto.
+Wed Jan 31 14:52:09 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
- * ext/tk/tcltklib.c (ip_finalize): ditto.
+ * eval.c (rb_iterate): need to PUSH_ITER in proper order.
+ [ruby-core:10125]
- * ext/dl/ptr.c (rb_dlptr_inspect): ditto. [ruby-dev:31268]
+ * test/ruby/test_iterator.rb (TestIterator::test_block_given_within_iterator):
+ add new test. [ruby-core:10125]
- * ext/dl/sym.c (rb_dlsym_inspect): ditto.
+Tue Jan 30 14:58:51 2007 NAKAMURA Usaku <usa@ruby-lang.org>
- * ext/socket/getnameinfo.c: include stdio.h always.
+ * string.c (rb_str_sub_bang): calling rb_str_modify() should be just
+ before actually modifying the string.
+ fixed: [ruby-dev:30211] (originally reported by zunda)
- * ext/win32ole/win32ole.c (ole_hresult2msg, folevariable_name,
- folevariable_ole_type, folevariable_ole_type_detail,
- folevariable_value, folemethod_visible): missing return value.
+Tue Jan 30 12:05:35 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Thu Aug 16 07:32:13 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * mkconfig.rb: autoconf 2.61 support. [ruby-core:10016]
- * lib/mkmf.rb (create_makefile): make OBJS depend on RUBY_EXTCONF_H
- only if extconf.h is created.
+Sat Jan 27 15:20:11 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-Thu Aug 16 07:29:33 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * parse.y (dyna_var_lookup): should not alter dvar->val not to
+ destroy living value. [ruby-core:10076]
- * {win32,wince,bcc32}/setup.mak (-version-): no RUBY_EXTERN magic.
+ * parse.y (dyna_init): ditto.
-Thu Aug 16 06:43:03 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Jan 26 12:03:39 2007 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * lib/mkmf.rb (init_mkmf): should remove mkmf.log too.
+ * ext/tk/lib/tk.rb (TkConfigMethod#__confinfo_cmd,
+ __conv_keyonly_optkeys): make them private [ruby-dev:30074].
-Thu Aug 16 06:40:58 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/tk/lib/tk/txtwin_abst.rb: fix typo [ruby-dev:30073].
- * ext/openssl/ossl_config.c (ossl_config_set_section): do not
- initialize aggregations with dynamic values. [ruby-talk:259306]
+ * ext/tk/lib/tk/canvas.rb (TkCanvas#scan_dragto): lack of an argument.
-Thu Aug 16 06:39:19 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/tk/lib/tk/canvas.rb: clarify the including module name
+ [ruby-dev:30080].
- * eval.c (get_backtrace): check the result more.
- [ruby-dev:31261] [ruby-bugs-12398]
+ * ext/tk/lib/tk/scrollable.rb: change primary name of modules
+ [ruby-dev:30080].
-Thu Aug 16 06:32:25 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed Jan 24 18:05:39 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
- * bignum.c (rb_big_lshift, rb_big_rshift): separated functions
- to get rid of infinite recursion. fixed calculation in edge
- cases. [ruby-dev:31244]
+ * misc/ruby-mode.el (ruby-font-lock-syntactic-keywords): fix
+ regexp font-lock bug. [ruby-talk:235758]
- * numeric.c (rb_fix_lshift, rb_fix_rshift): ditto.
+Tue Jan 23 11:02:33 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/webrick/httprequest.rb (WEBrick::HTTPRequest::read_line):
-Thu Aug 16 06:26:58 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Tue Jan 23 18:26:12 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
- * bignum.c (rb_big_pow): refine overflow check. [ruby-dev:31242]
+ * lib/cgi.rb (CGI::QueryExtension::read_multipart): use == instead
+ of ===. [ruby-dev:30176]
-Thu Aug 16 06:25:48 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Tue Jan 23 10:48:17 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
- * time.c (time_succ): Time#succ should return a time object in the
- same timezone mode to the original. [ruby-talk:260256]
+ * hash.c: added documentation for Hash about how it uses eql? and
+ hash methods for the keys. [ruby-core:09995]
-Thu Aug 16 06:24:39 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Mon Jan 22 14:57:25 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
- * numeric.c (fix_pow): integer power calculation: 0**n => 0,
- 1**n => 1, -1**n => 1 (n: even) / -1 (n: odd).
+ * ext/socket/socket.c: fix errors in socket sample code.
+ [ruby-core:09992]
-Thu Aug 16 06:11:34 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sat Jan 13 23:54:48 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
- * lib/base64.rb (Base64::b64encode): should not specify /o option
- for regular expression. [ruby-dev:31221]
+ * ext/win32ole/win32ole.c (ole_free, ole_type_free,
+ olemethod_free, olevariable_free, oleparam_free,
+ ole_event_free): fix memory leak. [ruby-core:09846]
-Thu Aug 16 06:08:53 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Jan 12 11:13:55 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * sprintf.c (rb_f_sprintf): more checks for format argument.
- [ruby-core:11569], [ruby-core:11570], [ruby-core:11571],
- [ruby-core:11573]
+ * ext/etc/etc.c (etc_getpwuid, etc_getgrgid): fix to correctly
+ convert uid/gid from VALUE. (backport of r11521)
-Thu Aug 16 05:39:31 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed Jan 10 18:57:57 2007 Minero Aoki <aamine@loveruby.net>
- * bignum.c (bignorm): do not empty Bignum. [ruby-dev:31229]
+ * ext/strscan/strscan.c (strscan_do_scan): should set kcode option
+ before match. [ruby-dev:29914]
-Thu Aug 16 05:12:05 2007 pegacorn <subscriber.jp AT gmail.com>
+ * test/strscan/test_stringscanner.rb: test it.
- * ext/openssl/ossl.h: include ossl_pkcs5.h. [ruby-dev:31231]
+ * re.c: export kcode_set_option and kcode_reset_option (with "rb_"
+ prefix).
- * ext/openssl/ossl_pkcs5.h: new file for PKCS5. [ruby-dev:31231]
+ * intern.h: ditto.
- * ext/openssl/ossl_x509name.c (ossl_x509name_to_s): use ossl_raise()
- instead of rb_raise(). [ruby-dev:31222]
+Tue Jan 9 17:45:17 2007 NAKAMURA Usaku <usa@ruby-lang.org>
- * ext/sdbm/_sdbm.c: DOSISH platforms need io.h. [ruby-dev:31232]
+ * file.c (rb_find_file): should not call fpath_check() with NULL.
+ fixed: [ruby-core:09867]
- * ext/syck/syck.h: include stdlib.h for malloc() and free().
- [ruby-dev:31232]
+Tue Jan 9 03:54:38 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
- * ext/syck/syck.h (syck_parser_set_input_type): prototype added.
- [ruby-dev:31231]
+ * string.c (rb_str_upto): String#upto from empty string makes
+ inifinite loop. [ruby-core:09864]
- * win32/win32.c: include mbstring.h for _mbspbrk(). [ruby-dev:31232]
+Sun Jan 7 12:13:26 2007 Eric Hodel <drbrain@segment7.net>
- * win32.h (rb_w32_getcwd): prototype added. [ruby-dev:31232]
+ * lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser#find_class_comment):
+ Look for class and module comments above rb_define_class and
+ rb_define_module. Patch by Daniel Berger <djberg96 at gmail.com>
-Thu Aug 16 05:02:39 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jan 7 10:32:12 2007 Eric Hodel <drbrain@segment7.net>
- * bignum.c (rb_cstr_to_inum): check leading non-digits.
- [ruby-core:11691]
+ * lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser#handle_constants):
+ Properly handle escaping of : in comments.
+ * test/rdoc/parsers/test_parse_c.rb:
+ Test RDoc::C_Parser#do_classes and Rdoc::C_Parser#find_class_comment.
-Thu Aug 16 05:00:01 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sun Jan 7 09:33:02 2007 Tadayoshi Funaba <tadf@dotrb.org>
- * numeric.c (fix_pow): 0**2 should not raise floating point
- exception. [ruby-dev:31216]
+ * lib/date/format.rb: updated based on date2 4.0.1.
-Thu Aug 16 04:56:35 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed Jan 3 11:36:51 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
- * win32/win32.c (CreateChild): enclose command line except for
- command.com which can not handle quotes. [ruby-talk:258939]
+ * io.c (ruby_dup): start GC on ENOMEM as well.
-Thu Aug 16 04:54:45 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Mon Jan 1 06:13:11 2007 Eric Hodel <drbrain@segment7.net>
- * lib/mkmf.rb (link_command, cc_command, cpp_command): do not expand
- ::CONFIG which is an alias of MAKEFILE_CONFIG.
+ * lib/rdoc/parsers/c_parser.rb: Make Rdoc accessible. Update constant
+ value information.
-Thu Aug 16 04:53:21 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Mon Jan 1 06:13:11 2007 Eric Hodel <drbrain@segment7.net>
- * struct.c (rb_struct_init_copy): disallow changing the size.
- [ruby-dev:31168]
+ * ext/bigdecimal/bigdecimal.c: Update constant comments to provide
+ values for RDoc.
-Thu Aug 16 04:52:11 2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
+Mon Jan 1 06:05:55 2007 Eric Hodel <drbrain@segment7.net>
- * random.c: documentation fix. srand(0) initializes PRNG with '0',
- not with random_seed.
+ * lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser#handle_constansts):
+ Allow RDoc comment to give friendly value for rb_define_const. Patch
+ by Daniel Berger <djberg96 at gmail.com>, [ruby-patches-7499].
+ * lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser#handle_constansts): Fix
+ whitespace handling in constant comments.
-Thu Aug 16 04:49:10 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Dec 31 00:31:16 2006 Tadayoshi Funaba <tadf@dotrb.org>
- * bcc32/{Makefile.sub,setup.mak}: remove surplus slash from srcdir.
+ * lib/date.rb, lib/date/format.rb: updated based on date2 4.0.
-Thu Aug 16 04:40:37 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Dec 14 18:29:13 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * sprintf.c (rb_f_sprintf): sign bit extension should not be done
- if FPLUS flag is specified. [ruby-list:39224]
+ * ext/readline/readline.c: NetBSD editline does not have
+ rl_username_completion_function() and rl_completion_matches().
+ a patch from Takahiro Kambe <taca at back-street.net>.
+ [ruby-dev:30008]
-Thu Aug 16 04:39:15 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Thu Dec 14 18:20:43 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * array.c (rb_ary_initialize): should call rb_ary_modify() first.
- [ruby-core:11562]
+ * lib/irb/locale.rb (IRB::Locale::puts): typo fixed. a patch from
+ NAKAMURA Usaku <usa@ruby-lang.org>. [ruby-dev:30012]
-Thu Aug 16 04:38:39 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Mon Dec 11 11:58:36 2006 Akinori MUSHA <knu@iDaemons.org>
- * parse.y (yylex): return non-valid token for an invalid
- instance/class variable name. a patch from from Yusuke ENDOH
- <mame AT tsg.ne.jp>. [ruby-dev:31095]
+ * ext/digest/sha2/lib/sha2.rb: Moved one level up from under
+ the superfluous subdirectory digest/.
-Thu Aug 16 04:36:41 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Mon Dec 11 11:46:18 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * parse.y (dsym): return non-null NODE even if yyerror(). based on a
- patch from from Yusuke ENDOH <mame AT tsg.ne.jp>. [ruby-dev:31085]
+ * variable.c (rb_define_const): typo fixed.
-Thu Aug 16 04:34:56 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Mon Dec 11 09:36:29 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * process.c (proc_exec_v, rb_proc_exec): preserve errno.
+ * string.c (rb_str_aset): index double decode problem.
+ [ruby-core:09695]
-Thu Aug 16 04:30:45 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sat Dec 9 21:39:24 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * variable.c (rb_path2class): get rid of dangling pointer caused by
- optimized out value.
+ * eval.c (ruby_cleanup): keep the exception till after END blocks.
+ [ruby-core:09675]
-Thu Aug 16 04:24:28 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+Sat Dec 9 11:22:00 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * ext/dl/lib/dl/win32.rb: seems that dl doesn't accept void argument.
- fixed [ruby-bugs:PR#5489].
+ * lib/irb/locale.rb (IRB::Locale::search_file): ues File.exist?
+ instead of File.exists?. a patch from Yutaka Kanemoto
+ <kinpoco at gmail.com> in [ruby-dev:30000].
-Thu Aug 16 04:23:44 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Dec 7 09:29:02 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser): handle more
- extensions. [ruby-dev:30972]
+ * lib/weakref.rb (WeakRef::__setobj__): should support
+ marshaling. [ruby-talk:228508]
-Thu Aug 16 04:14:17 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * lib/delegate.rb (Delegator::marshal_load): need to call
+ __setobj__.
- * process.c (ruby_setreuid, ruby_setregid): rename to get rid of name
- clash.
-Thu Aug 16 04:11:17 2007 Ryan Davis <ryand@zenspider.com>
+Wed Dec 6 23:56:14 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/rexml/dtd/dtd.rb: Fixed typo in code. Fixes bug #10420
+ * Makefile.in, common.mk (NULLCMD): moved for platforms that empty
+ command does not run. fixed: [ruby-dev:29994]
-Thu Aug 16 04:08:20 2007 Shugo Maeda <shugo@ruby-lang.org>
+Wed Dec 6 17:17:26 2006 WATANABE Hirofumi <eban@ruby-lang.org>
- * lib/net/imap.rb (ResponseParser#next_token): fixed
- error message. (backported from HEAD)
+ * configure.in (SITE_DIR): fixed to emtpy RUBY_SITE_LIB in config.h on
+ NetBSD. fixed: [ruby-dev:29358]
- * lib/net/imap.rb (ResponseParser#parse_error): fixed
- the condition not to refer @token.symbol unexpectedly.
- Thanks, Dick Monahan. (backported from HEAD)
+Tue Dec 5 00:59:05 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-Thu Aug 16 04:05:20 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * misc/ruby-mode.el (ruby-parse-partial): need to parse "/=" as
+ self assignment operator, not regex. [ruby-talk:227324]
- * marshal.c (w_extended): erroneous check condition when dump
- method is defined. [ruby-core:10646]
+Mon Dec 4 10:48:03 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-Sat Jun 9 10:40:00 2007 URABE Shyouhei <shyouhei@ruby-lang.org>
+ * ruby.h (OFFT2NUM): use LONG2NUM() if sizeof(long) equals to
+ sizeof(off_t).
- * stable version 1.8.5-p52 released.
+Mon Dec 4 10:43:46 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-Thu Jun 7 14:53:46 2007 URABE Shyouhei <shyouhei@ruby-lang.org>
+ * parse.y (dyna_init_gen): dvar initialization only if dvar is
+ assigned inner block. [ruby-talk:227402]
- * eval.c (method_inspect): show proper class name.
- [ruby-talk:248647], Thanks Calamitas.
+Mon Dec 4 08:32:49 2006 Shugo Maeda <shugo@ruby-lang.org>
-Mon May 28 19:37:24 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+ * lib/cgi.rb (CGI::QueryExtension::read_multipart): should quote
+ boundary. JVN#84798830
- * win32/win32.c (move_to_next_entry): revert r12338. not necessary
- on ruby_1_8_5.
+Sat Dec 2 07:09:04 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
-Sun May 27 05:52:37 2007 URABE Shyouhei <shyouhei@ruby-lang.org>
+ * ext/openssl/ossl_ocsp.c: OpenSSL::OCSP::OSCPError should be
+ subclass of OpenSSL::OpenSSLError. [ruby-dev:29980]
- * eval.c (mnew): call of super via a method object should work again.
- [ruby-talk:248647], Thanks Calamitas.
+Fri Dec 1 17:01:49 2006 NAKAMURA Usaku <usa@ruby-lang.org>
- * test/ruby/test_method.rb (TestMethod::test_method_super): test for
- above fix.
+ * gc.c (ruby_init_stack): decrease "stack level too deep" in Windows.
+ merge from trunk.
-Wed May 23 06:51:46 2007 URABE Shyouhei <shyouhei@ruby-lang.org>
+Fri Dec 1 16:31:53 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * lib/cgi.rb (CGI#[]): get rid of exceptions being raised.
- [ruby-dev:30740], Thanks Kentaro KAWAMOTO.
+ * ext/tk/tcltklib.c: shouldn't run the killed thread at callback.
+ [ruby-talk: 227408]
-Wed May 23 06:14:15 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Mon Nov 27 17:18:27 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * win32/win32.c (move_to_next_entry): loc also must move forward.
- [ruby-talk:251987]
+ * sprintf.c (rb_f_sprintf): need not to truncate string if no
+ width specifier given for %s. [ruby-dev:29952]
-Wed May 23 05:55:04 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+Sun Nov 26 16:36:46 2006 URABE Shyouhei <shyouhei@ruby-lang.org>
- * win32/win32.c (init_stdhandle): stderr should be without buffering,
- but mswin32 use buffering when stderr is not connected to tty.
+ * version.h: addition of RUBY_PATCHLEVEL.
+ * version.c: ditto.
-Wed May 23 03:33:55 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Nov 24 10:17:51 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * lib/monitor.rb (ConditionVariable#wait, mon_enter, mon_exit_for_cond):
- ensures Thread.critical to be false. [ruby-talk:248300]
+ * bignum.c (bignorm): avoid segmentation. a patch from Hiroyuki
+ Ito <ZXB01226@nifty.com>. [ruby-list:43012]
-Wed May 23 03:25:13 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Nov 23 10:38:40 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * util.c (ruby_strtod): exponent is radix 10. [ruby-talk:248272]
+ * eval.c (rb_mod_define_method): set implicit visibility only when
+ it's called for the target class (ruby_cbase).
-Wed May 23 02:09:32 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Wed Nov 22 16:00:49 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * eval.c (rb_yield_0): should not clear state on TAG_NEXT when
- it's invoked from within lambda body. [ruby-talk:248136]
+ * ext/tk/extconf.rb: support --with-X11/--without-X11 option.
- * eval.c (proc_invoke): handle TAG_NEXT which would be caused by
- next in the lambda body as well.
+ * ext/tk/README.tcltklib: add description about --with-X11-* option
+ [ruby-talk:225166] and --with-X11/--without-X11 option.
-Wed May 23 01:55:49 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+ * ext/tk/tkutil/extconf.rb: able to be called manually
+ [ruby-talk:225950].
- * win32/win32.c (rb_w32_fclose, rb_w32_close): need to save errno
- before calling original fclose()/close().
+Wed Nov 15 23:22:54 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Wed May 23 01:42:29 2007 Shugo Maeda <shugo@ruby-lang.org>
+ * file.c (test_grpowned, rb_stat_grpowned): should honor
+ supplementary group IDs. [ruby-core:09546]
- * lib/net/imap.rb (disconnect): call shutdown for
- SSLSocket. Thanks, Technorama Ltd.
+Thu Nov 9 03:15:22 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-Wed May 23 01:28:14 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * eval.c (BEGIN_CALLARGS): ruby_block may be NULL even when
+ ITER_PRE.
- * error.c (rb_notimplement), io.c (pipe_open): removed definite
- articles and UNIX manual section from messages. [ruby-dev:30690]
+Tue Nov 7 18:34:34 2006 Akinori MUSHA <knu@iDaemons.org>
- * io.c (pipe_open): raise NotImplementedError for command "-" on
- platforms where fork(2) is not available. [ruby-dev:30681]
+ * ext/digest/lib/digest/hmac.rb: Keep this out of the 1.8 tree
+ until we reach a consensus that HMAC should be put under Digest.
-Wed May 23 00:06:19 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+Tue Nov 7 18:05:01 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/socket/socket.c (s_recv, s_recvfrom): some systems (such as
- windows) doesn't set fromlen if the socket is connection-oriented.
- reported by Bram Whillock in [ruby-core:10512] [ruby-Bugs#9061]
+ * ext/tk/lib/tk/itemconfig.rb: minor bug fix.
-Tue Mar 20 15:37:24 2007 URABE Shyouhei <shyouhei@ruby-lang.org>
+Mon Nov 6 20:11:20 2006 Kouhei Sutou <kou@cozmixng.org>
- * distruby.rb: Add zip generation.
+ * lib/rss/0.9.rb (RSS::Rss): removed needless include.
-Fri Mar 16 21:48:11 2007 Akinori MUSHA <knu@iDaemons.org>
+Mon Nov 6 15:41:55 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/dl/dl.c (rb_ary2cary): Fix a bug in type validation;
- submitted by sheepman <sheepman AT sheepman.sakura.ne.jp>
- in [ruby-dev:30554].
+ * ext/tk/lib/tk/itemconfig.rb: ext/tk/lib/tk/itemconfig.rb: bug
+ fix on 'itemconfiginfo' method, and modify to make it easy to
+ override 'itemconfiginfo' method.
-Fri Mar 16 18:28:06 2007 Akinori MUSHA <knu@iDaemons.org>
+ * ext/tk/lib/tkextlib/tile/treeview.rb : support Tile 0.7.8.
- * ext/etc/etc.c (etc_getgrgid): Fix a bug in Etc::getgrgid()
- always returning the (real) group entry of the running process;
- reported by: UEDA Hiroyuki <ueda AT netforest.ad.jp>
- in [ruby-dev:30586].
+ * ext/tk/lib/tkextlib/version.rb : [new] add Tk::Tkextlib_RELEASE_DATE
+ to get the information from scripts.
-Wed Mar 14 12:30:00 2007 Shigeo Kobayashi <shigeo@tinyforest.jp>
+ * ext/tk/lib/tk.rb: load 'tkextlib/version.rb', and update RELEASE_DATE
- * ext/bigdecimal/bigdecimal.c: BigDecimal("-.31") is now
- treated as ("-0.31") not as ("0.31").
+ * ext/tk/lib/tkextlib/SUPPORT_STATUS: update.
-Fri Mar 16 18:05:40 2007 Akinori MUSHA <knu@iDaemons.org>
+ * ext/tk/sample/editable_listbox.rb: [new] the listbox with editable
+ items. It's one of the example about usage of Place geometry manager.
- * lib/cgi.rb (CGI::header): IIS >= 5.0 does not need the nph
- assumption any more; submitted by MIYASAKA Masaru <alkaid AT
- coral.ocn.ne.jp> in [ruby-dev:30537].
+ * ext/tk/sample/tktextio.rb: improve the functions of TkTextIO class.
+ Those are required by 'irbtkw.rbw'.
-Tue Mar 13 17:29:43 2007 URABE Shyouhei <shyouhei@ruby-lang.org>
+ * ext/tk/sample/irbtkw.rbw: [new] IRB on Ruby/Tk. It doesn't need any
+ real console. IRB works on a text widget without I/O blocking. That
+ is, thread switching on IRB will work properly, even if on Windows.
- * stable version 1.8.5-p35 released.
+Sun Nov 5 19:53:49 2006 Tadayoshi Funaba <tadf@dotrb.org>
-Tue Mar 13 14:42:10 2007 URABE Shyouhei <shyouhei@ruby-lang.org>
+ * lib/date.rb: updated based on date2 3.9.7.
- * test/fileutils/fileasserts.rb: Fix wrong error message.
+Sat Nov 4 13:13:57 2006 Shugo Maeda <shugo@ruby-lang.org>
- * lib/fileutils.rb (FileUtils::mv): Type Error; should utilize
- Strings instead of Symbols here.
+ * lib/net/imap.rb: accept NOMODSEQ. [ruby-core:9002]
+ (backported from HEAD)
-Mon Mar 12 17:22:44 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+Fri Nov 3 00:16:37 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * lib/fileutils.rb (FileUtils::mv): fix incomplete backport of
- FileUtils.mv changes at r11988
+ * ext/socket/socket.c (ruby_getnameinfo__aix): AF_INET6 workaround
+ for AIX. a patch from Yutaka Kanemoto <kinpoco AT gmail.com>.
+ [ruby-dev:29744]
-Mon Mar 12 16:09:28 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Nov 2 15:43:39 2006 NAKAMURA Usaku <usa@ruby-lang.org>
- * mkconfig.rb (patchlevel): read from version.h.
+ * parse.y (primary): should set NODE even when compstmt is NULL.
+ merge from trunk. fixed: [ruby-dev:29732]
-Sun Mar 11 18:57:50 2007 Akinori MUSHA <knu@iDaemons.org>
+Thu Nov 2 14:48:30 2006 Akinori MUSHA <knu@iDaemons.org>
- * misc/README: Add a note about ruby-electric.el.
+ * lib/set.rb (Set#^): Fix XOR operation against a container that
+ holds duplicate values. [issue: #6444]
- * misc/ruby-mode.el (ruby-non-block-do-re): Fix
- ruby-non-block-do-re. [ruby-core:03719]
+Wed Nov 1 02:41:38 2006 Akinori MUSHA <knu@iDaemons.org>
- * misc/inf-ruby.el: Synchronize the comment section with trunk.
+ * ext/digest/lib/digest/hmac.rb (Digest::HMAC::update): Minor
+ optimization.
- * misc/README, misc/rdebug.el: Add rdebug.el, Emacs ruby-debug
- interface based on rubydb3x.el; submitted by Martin Nordholts
- <enselic AT gmail.com> in [ruby-bugs:PR#9023].
+ * ext/digest/digest.c (rb_digest_instance_equal): Allow comparing
+ a digest instance with another of a different class.
-Sun Mar 11 17:45:51 2007 Akinori MUSHA <knu@iDaemons.org>
+Wed Nov 1 01:05:13 2006 NAKAMURA Usaku <usa@ruby-lang.org>
- * ext/dl/mkcallback.rb (mkfunc): Make sure that a callback
- function is found in the function table before trying to call
- it; submitted by sheepman <sheepman AT sheepman.sakura.ne.jp>
- in [ruby-dev:30524].
+ * eval.c (rb_call0): fixed bug of zsuper with both of opt and rest.
+ fixed: [ruby-list:42928]
-Tue Mar 6 18:58:37 2007 Keiju Ishitsuka <keiju@ruby-lang.org>
-
- * lib/shell/process-controller.rb: fix thread synchronization
- problem for [ruby-dev:30477].
-
-Sun Mar 4 23:53:27 2007 Minero Aoki <aamine@loveruby.net>
+ * test/ruby/test_super.rb: add tests to check above bug.
- * lib/fileutils.rb (mv): could not move a directory between
- different filesystems. [ruby-dev:30411]
+Tue Oct 31 17:03:21 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-Sat Mar 3 21:41:31 2007 Akinori MUSHA <knu@iDaemons.org>
+ * time.c (time_dup): duplicate the class of original time.
+ [ruby-core:09357]
- * eval.c (stack_check): Unset inline to fix build with GCC 3.4.6;
- submitted by: NISHIMATSU Takeshi <t_nissie AT yahoo.co.jp> in
- [ruby-list:43218].
- cf. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24556
+ * lib/time.rb (Time::make_time, Time::rfc2822, Time::httpdate):
+ should respect subclasses. [ruby-core:09357]
-Sat Mar 3 16:30:39 2007 Akinori MUSHA <knu@iDaemons.org>
+Mon Oct 30 23:40:52 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * env.h (SCOPE_CLONE): Introduce a new scope flag to prevent a
- local_tbl region from getting freed many times; submitted by
- Chikanaga Tomoyuki <chikanag AT nippon-control-system.co.jp> in
- [ruby-dev:30460].
+ * Makefile.in (miniruby): add XLDFLAGS.
- * eval.c (proc_invoke): Ditto.
+ * configure.in (aix): use -bE option for miniruby. [ruby-dev:29698]
- * gc.c (obj_free): Ditto.
+ * dir.c (glob_helper): get rid of possible memory leak.
- * parse.y (top_local_setup_gen): Ditto.
+ * win32/win32.c (cmdglob, rb_w32_cmdvector, rb_w32_opendir,
+ rb_w32_get_environ): not to use GC before initialization.
-Sat Mar 3 15:41:33 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Mon Oct 30 19:29:20 2006 NAKAMURA Usaku <usa@ruby-lang.org>
- * parse.y (stmt, arg): should not omit lhs of OP_ASGN1 even if
- empty. [ruby-dev:30452]
+ * bignum.c (rb_big2str0): use better approximation.
-Wed Feb 28 20:51:32 2007 URABE Shyouhei <shyouhei@ruby-lang.org>
+Mon Oct 30 18:35:33 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * pack.c (pack_unpack): properly ignore non-base64 octets such as
- UTF-8 encoded BOMs; submitted by SOUMA Yutaka <holon@radastery.jp>
- to fix [ruby-core:10437]
+ * bignum.c (rb_big2str0): wrong allocation length. a patch from
+ U.Nakamura <usa at garbagecollect.jp> [ruby-dev:29710]
-Wed Feb 28 00:08:11 2007 URABE Shyouhei <shyouhei@ice.uec.ac.jp>
+Mon Oct 30 12:34:02 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * mkconfig.rb (RbConfig): add CONFIG['PATCHLEVEL']
+ * eval.c (rb_eval): fix commit miss. [ruby-dev:29707]
- * common.mk: new target dist
+Mon Oct 30 12:20:58 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * distruby.rb: new file
+ * bignum.c (rb_big2str0): a bug in length adjustment.
-Tue Feb 27 21:19:35 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+Mon Oct 30 11:15:40 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * win32/win32.c (set_pioinfo_extra): new function for VC++8 SP1
- workaround. [ruby-core:10259]
+ * sprintf.c (rb_str_format): should preserve leading zero
+ information for negative %b and %x. [ruby-talk:221347]
- * win32/win32.c (NtInitialize): call above function.
+Thu Oct 26 21:05:58 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * ext/openssl/ossl_pkcs7.c (ossl_pkcs7_verify): should clear error.
+ (fix http://bugs.debian.org/394336)
+
+ * ext/openssl/ossl_ns_spki.c (ossl_spki_initialize): ditto.
-Mon Feb 26 09:57:58 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Thu Oct 26 15:21:10 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * ext/digest/digest.c (Init_digest): typo.
+
+Wed Oct 25 17:23:28 2006 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/digest, test/digest/test_digest.rb: Merge from trunk:
+ - Introduce versioning in Digest::Base API, and prefix C
+ constants with RUBY_ and C type names with rb_ to avoid name
+ clash in writing extensions.
+ - Introduce Digest::Class and Digest::Instance for ease of
+ implementing subclasses and add-ons.
+ - Digest::Instance module requires and assumes that any instance
+ be resettable and clonable. An instance method #new() is
+ added so digest instances work just like digest classes.
+ - The constructor does no longer take an initial string to feed;
+ digest() and hexdigest() now do, instead. This allows digest
+ classes to take their own hashing parameters.
+ - Make some changes to digest() and hexdigest() class methods,
+ which now take extra arguments, which are passed through to
+ the constructor in an internal call.
+ - Add #digest_length/size/length() and #block_length(),
+ - Add the Digest::SHA2 class to wrap up SHA2 variants: SHA256,
+ SHA384 and SHA512, hoping this module would make a decent
+ example of a digest subclass written in Ruby.
+ - Rip BubbleBabble support out of the base class and have a
+ separate module named digest/bubblebabble.
+ - Remove RD documents in favor of newly written and embedded
+ RDoc documentation.
+
+Wed Oct 25 08:03:23 2006 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * lib/date/format.rb: updated based on date2 3.9.6.
+ [ruby-core:09323]
+
+Sun Oct 22 14:48:31 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* signal.c (ruby_signal): don't set SA_RESTART. a backport from
the HEAD. [ruby-talk:220937] [ruby-talk:147220]
-Tue Feb 13 02:21:12 2007 Sam Roberts <sroberts@uniserve.com>
+ * signal.c (Init_signal): avoid duplicated installation of SIGCHLD
+ handler.
- * io.c (rb_f_syscall): Fix buffer overflow with syscall
- arguments. [ruby-bugs:PR#8541]
+Sun Oct 22 16:47:56 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sat Feb 10 09:33:47 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
+ * string.c (rb_str_substr): should be infected with only original
+ string, but not the shared string. fixed: [ruby-core:09152]
- * ext/win32ole/win32ole.c (ole_variant2val): sorry, fix the enbug.
+ * string.c (rb_str_new4): keep shared string untainted when orignal
+ string is tainted. fixed: [ruby-dev:29672]
-Sat Feb 10 09:08:01 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
+Sun Oct 22 05:20:34 2006 URABE Shyouhei <shyouhei@ice.uec.ac.jp>
- * ext/win32ole/win32ole.c (ole_variant2val): fix compile error
- on VC++.
+ * configure.in: alloca is broken; use C_ALLOCA instead.
+ [ruby-dev:29416]
-Sat Feb 10 08:38:30 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
+Fri Oct 20 10:47:43 2006 NAKAMURA Usaku <usa@ruby-lang.org>
- * ext/win32ole/win32ole.c (ole_variant2val): fix the bug when
- SAFEARRAY pointer is NULL.
+ * lib/mkmf.rb: fixed the bug of handling COMMON_MACROS.
-Tue Feb 6 20:41:39 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+Fri Oct 20 08:42:38 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * string.c (rb_str_sub_bang): calling rb_str_modify() should be just
- before actually modifying the string.
- fixed: [ruby-dev:30211] (originally reported by zunda)
+ * common.mk (NULLCMD): dummy command.
-Sat Jan 27 15:20:11 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * bcc32/Makefile.sub (post-install-*): Borland make cannot ignore
+ command-less double-colon rules. [ruby-dev:29676]
- * parse.y (dyna_var_lookup): should not alter dvar->val not to
- destroy living value. [ruby-core:10076]
+Fri Oct 20 00:37:07 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * parse.y (dyna_init): ditto.
+ * bcc32/Makefile.sub ($(LIBRUBY_SO)): execute pre-link hook.
-Wed Jan 24 18:05:39 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ext/extmk.rb: workaround for Borland make.
- * misc/ruby-mode.el (ruby-font-lock-syntactic-keywords): fix
- regexp font-lock bug. [ruby-talk:235758]
+Wed Oct 18 23:02:40 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sun Jan 14 07:26:44 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
+ * array.c (rb_ary_shift): shorten copy size. fixed: [ruby-list:42907]
- * ext/win32ole/win32ole.c (ole_free, ole_type_free,
- olemethod_free, olevariable_free, oleparam_free,
- ole_event_free): fix memory leak. [ruby-core:09846]
+ * signal.c (Init_signal): handle SIGTERM. fixed: [ruby-list:42895]
-Tue Jan 9 12:29:20 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * win32/win32.c (rb_w32_utime): allow NULL to set the current time.
+ [ruby-talk:219248]
- * ext/etc/etc.c (etc_getpwuid, etc_getgrgid): fix to correctly
- convert uid/gid from VALUE.
+Wed Oct 18 00:55:33 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * ext/etc/etc.c (etc_getpwuid): ditto.
+ * parse.y (parser_yylex): use particular enums. [ruby-core:09221]
-Mon Dec 25 20:08:28 2006 URABE Shyouhei <shyouhei@ruby-lang.org>
+Mon Oct 16 08:30:43 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * ext/openssl/ossl.h: fixed compilation problem on gcc 3.2.
- [ruby-talk:214786]
+ * mkconfig.rb: *OBJS are not needed for extension libraries.
-Mon Dec 25 10:40:40 2006 URABE Shyouhei <shyouhei@ruby-lang.org>
+ * {bcc32,wince,win32}/Makefile.sub (config.status): fixed typo,
+ missing comma.
- * stable version 1.8.5-p12 released.
+Sun Oct 15 01:03:08 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sat Dec 16 04:02:10 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+ * lib/test/unit/collector/dir.rb (Collector::Dir#collect): append base
+ directory but not prepend.
- * ext/tk/tcltklib.c: shouldn't run the killed thread at callback.
- [ruby-talk: 227408]
+ * lib/test/unit/collector/dir.rb (Collector::Dir#collect_file): do not
+ join with dot. fixed: [ruby-core:09179]
-Fri Dec 15 17:21:14 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sat Oct 14 23:39:50 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * lib/rdoc/ri/ri_options.rb: prevent NameError. [ruby-dev:29597]
+ * parse.y (singleton): no need to re-create NODE_SELF() again.
+ [ruby-core:09177]
-Thu Dec 14 23:37:38 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sat Oct 14 23:25:31 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * dir.c (glob_helper): get rid of possible memory leak.
+ * parse.y (parser_warning, parser_warn): some error message may
+ contain format specifiers. a patch from Akinori MUSHA <knu at
+ iDaemons.org>. [ruby-dev:29657]
- * win32/win32.c (cmdglob, rb_w32_cmdvector, rb_w32_opendir,
- rb_w32_get_environ): not to use GC before initialization.
+ * ext/bigdecimal/bigdecimal.c (VpException): ditto.
-Wed Dec 6 19:53:41 2006 WATANABE Hirofumi <eban@ruby-lang.org>
+ * ext/dl/handle.c (rb_dlhandle_initialize): ditto.
- * configure.in (SITE_DIR): fixed to emtpy RUBY_SITE_LIB in config.h on
- NetBSD. fixed: [ruby-dev:29358]
+ * ext/gdbm/gdbm.c (rb_gdbm_fatal): ditto.
-Mon Dec 4 10:43:46 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sat Oct 14 08:24:45 2006 Akinori MUSHA <knu@iDaemons.org>
- * parse.y (dyna_init_gen): dvar initialization only if dvar is
- assigned inner block. [ruby-talk:227402]
+ * ext/digest/lib/digest/hmac: Back out the addition of digest/hmac
+ for now because the API is too premature for a stable branch.
-Mon Dec 4 10:22:26 2006 URABE Shyouhei <shyouhei@ice.uec.ac.jp>
+Sat Oct 14 00:55:08 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * stable version 1.8.5-p2 released.
+ * bcc32/Makefile.sub (post-install-ext): no longer needed.
-Sun Dec 3 17:11:12 2006 Shugo Maeda <shugo@ruby-lang.org>
+ * bcc32/configure.bat: get rid of a quirk of Borland make, which
+ sets empty macro in command line to "1".
- * lib/cgi.rb (CGI::QueryExtension::read_multipart): should quote
- boundary. JVN#84798830
+Fri Oct 13 22:50:43 2006 Tadayoshi Funaba <tadf@dotrb.org>
-Sun Nov 26 16:36:46 2006 URABE Shyouhei <shyouhei@ruby-lang.org>
+ * lib/date.rb: updated based on date2 3.9.5.
- * version.h: addition of RUBY_PATCHLEVEL.
- * version.c: ditto.
+Fri Oct 13 22:33:28 2006 Minero Aoki <aamine@loveruby.net>
-Fri Nov 24 10:17:51 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/fileutils.rb (FileUtils.cp_r): dereference_root=true is
+ default in Ruby 1.8. This line is wrongly removed in last commit.
- * bignum.c (bignorm): avoid segmentation. a patch from Hiroyuki
- Ito <ZXB01226@nifty.com>. [ruby-list:43012]
+Fri Oct 13 18:19:31 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-Thu Nov 2 15:43:39 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+ * object.c: Class#inherited RDoc added. a patch from Daniel
+ Berger <djberg96 at gmail.com> [ruby-core:08942]
- * parse.y (primary): should set NODE even when compstmt is NULL.
- merge from trunk. fixed: [ruby-dev:29732]
+Fri Oct 13 02:30:12 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * lib/test/unit/collector/dir.rb (Collector::Dir#collect): prepend
+ base directory to load path.
+
+ * lib/test/unit/collector/dir.rb (Collector::Dir#collect_file): should
+ use the given File-like interface, but not File directly.
+
+ * test/testunit/collector/test_dir.rb (TestDir::FileSystem): implement
+ File-like methods correctly.
+
+Fri Oct 13 01:48:42 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/date.rb (Date::self.complete_hash): need to check if g is
+ nil before dereference. [ruby-core:09116]
+
+Fri Oct 13 00:34:26 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (rb_mod_cvar_defined): wrong id check. a patch from
+ Mauricio Fernandez <mfp at acm.org>. [ruby-core:09158]
+
+ * object.c (rb_mod_cvar_get): typo fixed. [ruby-core:09168]
+
+ * object.c (rb_mod_cvar_set): ditto.
+
+Wed Oct 11 22:21:41 2006 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/digest: Merge from trunk; metadata location changed,
+ Digest::Base#reset() added, Digest::Base#equal() changed, and
+ digest/hmac added with some modifications made for ruby 1.8.
+
+Tue Oct 10 17:24:12 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * {bcc32,win32,wince}/Makefile.sub (config.status): shouldn't use
+ copy command instead of install. use -run install.
+
+Tue Oct 10 16:49:16 2006 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/digest/digest.c (hexdigest_str_new, bubblebabble_str_new):
+ Perform StringValue() checks properly.
+
+ * ext/digest/digest.c: Use RSTRING_{PTR,LEN} macros.
+
+Tue Oct 10 13:49:53 2006 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/digest: Merge from trunk; apply all changes since the
+ initial import, except for the removal of compatibility stub
+ libraries (md5.rb and sha1.rb).
+
+Mon Oct 9 23:46:29 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/parsedate.rb: documentation patch from Konrad Meyer
+ <konrad.meyer@gmail.com>. [ruby-doc:1238]
+
+ * lib/open3.rb, lib/ping.rb: ditto.
+
+Mon Oct 9 22:56:12 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/rexml/encoding.rb (REXML::Encoding::check_encoding): spaces
+ are allowed around equal sign. [ruby-core:09032]
+
+ * lib/rexml/parsers/baseparser.rb (REXML::Parsers::BaseParser): ditto.
+
+Sat Oct 7 23:53:08 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_scan): small documentation fix.
+ [ruby-core:09007]
+
+Sat Oct 7 23:44:33 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * bignum.c (rb_big_rshift): a bug in right shift of negative
+ bignums. [ruby-core:09020]
+
+Sat Oct 7 00:27:58 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * class.c (rb_include_module): remove unnecessary check.
+ [ruby-talk:218402]
+
+Fri Oct 6 04:30:30 2006 Akinori MUSHA <knu@iDaemons.org>
+
+ * sample/openssl/c_rehash.rb: Use digest/md5 instead of obsolete md5.
+
+Wed Oct 4 18:47:25 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib/tkextlib/*: bugfix and update
+ (see ext/tk/ChangeLog.tkextlib).
+
+Wed Oct 4 17:25:14 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_call): check protected visibility based on real self,
+ not ruby_frame->self. [ruby-talk:217822]
+
+Wed Oct 4 08:52:30 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * test/optparse/test_getopts.rb: changed the class name of test case
+ to get rid of conflict with test_optparse.rb.
+
+Tue Oct 3 23:32:27 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * lib/test/unit/testcase.rb (Test::Unit::TestCase.suite): test name
+ must be string. fixed: [ruby-core:08978]
+
+Mon Oct 2 23:47:55 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * lib/test/unit/autorunner.rb (Test::Unit::AutoRunner::COLLECTORS):
+ base directory should be lower precedence. fixed: [ruby-dev:29622]
+
+ * lib/test/unit/autorunner.rb (Test::Unit::AutoRunner#options): typo.
+
+ * lib/test/unit/collector/dir.rb (Test::Unit::Collector::Dir#collect_file):
+ load expanded path. fixed: [ruby-dev:29621]
+
+Mon Oct 2 15:49:19 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * instruby.rb: batfile should be CRLF'ed.
+
+Mon Oct 2 01:24:26 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * common.mk (test-all): separate directory where running test cases
+ from source tree.
+
+ * lib/test/unit/autorunner.rb (options): added --basedir, --workdir
+ and --load-path options.
+
+ * lib/test/unit/collector/dir.rb (recursive_collect, collect_file):
+ base directory support.
+
+Sun Oct 1 23:56:52 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * Makefile.in, common.mk, ext/extmk.rb, win{32,ce}/Makefile.in: keep
+ LIBRUBY_SO unless need to be removed.
+
+Sun Oct 1 23:12:19 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * lib/optparse.rb (OptionParser#make_switch): pass arguments directly.
+
+Sat Sep 30 15:12:25 2006 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * lib/date.rb, lib/date/format.rb: updated based on date2 3.9.4.
+
+Fri Sep 29 12:11:04 2006 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * jcode.rb (succ!): call original succ! if $KCODE == 'n'.
+ fixed: [ruby-talk:216845]
+
+Fri Sep 29 11:43:40 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * lib/mkmf.rb (try_func): revert fallback checking undeclared function.
+ fixed: [ruby-core:08949]
+
+Fri Sep 29 09:56:56 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * ext/extmk.rb: extout is needed for also clean.
+ fixed: [ruby-core:08944]
+
+ * lib/optparse.rb (OptionParser::Switch#conv_arg): unsplat by
+ Proc#call if no conversion is given.
+
+Thu Sep 28 23:59:31 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * node.h (struct thread): declare win32_exception_list on cygwin and
+ win32 regardless if it is implemented. Provisional fix for
+ [ruby-core:08917].
+
+Thu Sep 28 20:53:16 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * lib/tmpdir.rb: use return value of getdir.call for length.
+
+Wed Sep 27 01:04:49 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * lib/mkmf.rb (try_func): check function pointer first and macro next.
+
+ * lib/mkmf.rb (have_type): simplified with typedef and sizeof.
+
+Tue Sep 26 23:57:03 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * lib/optparse.rb (OptionParser#getopts): use strings as key.
+ fixed: [ruby-dev:29614]
+
+Tue Sep 26 15:31:26 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * {win32,wince}/Makefile.sub (CPP): check predefined value.
+
+Tue Sep 26 07:55:16 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (rb_ary_shift): should not move memory region if array
+ body is shared. a patch from Kent Sibilev <ksruby at gmail.com>.
+ [ruby-core:08922]
+
+Mon Sep 25 22:26:26 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * file.c (rb_path_end): skip root directory. fixed: [ruby-core:08913]
+
+ * lib/mkmf.rb (init_mkmf): set default $LDFLAGS. Patch by Michal
+ Suchanek <hramrach at centrum.cz>. [ruby-talk:216256]
+
+Mon Sep 25 08:14:43 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (rb_ary_shift): should clear shifting top element.
+ [ruby-talk:216055]
+
+ * array.c (rb_ary_shift): avoid creating shared object if array
+ size is small.
+
+Mon Sep 25 08:11:35 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * random.c (rb_f_rand): RDoc typo fix. a patch from Frederick
+ Cheung <fred at 82ask.com>. [ruby-talk:216047]
+
+Sun Sep 24 22:28:20 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * runruby.rb: extension library scripts moved into common directory.
+
+Sun Sep 24 14:59:50 2006 Tanaka Akira <akr@fsij.org>
+
+ * node.h (struct thread): ia64 support is broken by sandbox patch.
+
+Sun Sep 24 12:11:16 2006 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * lib/date.rb, lib/date/format.rb: updated based on date2 3.9.3.
+
+Sat Sep 23 23:24:57 2006 why the lucky stiff <why@ruby-lang.org>
+
+ * eval.c (rb_thread_save_context, rb_thread_restore_context):
+ sandbox hook to save and restore sandbox state.
+
+ * eval.c (thread_no_ensure): added THREAD_NO_ENSURE thread flag.
+
+ * eval.c (rb_thread_kill_bang): Thread#kill! uses the above flag
+ to circumvent ensure, in order to prevent endless loops.
+ [ruby-core:08768]
+
+ * eval.c (rb_thread_kill): fix Thread#kill docs, which returns
+ the thread object in all cases.
+
+ * node.h: expose the rb_jmpbuf_t and rb_thread_t structs, along
+ with the thread flags. used by the sandbox extension.
+
+ * ruby.h: extern rb_eThreadError, so sandbox can swap it.
Sat Sep 23 21:34:15 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/cgi.rb (CGI::QueryExtension::read_multipart): CGI content
may be empty. a patch from Jamis Buck <jamis at 37signals.com>.
+Sat Sep 23 08:35:53 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/rdoc/ri/ri_options.rb: prevent NameError. [ruby-dev:29597]
+
+Sat Sep 23 01:04:20 2006 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * lib/date.rb, lib/date/format.rb: updated based on date2 3.9.2.
+
+Fri Sep 22 02:06:26 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * .cvsignore: ignore timestamp files and installed list file.
+
+Fri Sep 22 01:36:34 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * instruby.rb: include FileUtils unconditionally.
+
+Thu Sep 21 22:56:20 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * common.mk (no-install): not install rdoc actually.
+
+ * common.mk (install-doc, no-install-doc): use instruby.rb.
+
+ * instruby.rb: rdoc installation.
+
+ * ext/extmk.rb: expand ruby executable names.
+
+Thu Sep 21 13:55:07 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ext/etc/etc.c (etc_getpwuid): uid integer should be wraped in
+ uid_t value. [ruby-core:08897]
+
+ * ext/etc/etc.c (etc_getpwuid): uid_t may be bigger than plain
+ 'int' type.
+
+Wed Sep 20 23:17:41 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * common.mk (pre-install-doc): create data directory before install.
+
+ * lib/mkmf.rb (dir_re): fixed typo.
+
+ * lib/mkmf.rb (install_dirs): remove extra slash.
+
+Wed Sep 20 09:53:38 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * {bcc32,win32,wince}/Makefile.sub (INSTALLED_LIST): need to define
+ this macro to install.
+
+Wed Sep 20 09:43:10 2006 Shugo Maeda <shugo@ruby-lang.org>
+
+ * lib/net/imap.rb: allow extra spaces in responses.
+ Thanks, Tom Soderlund. (backported from HEAD)
+
+Wed Sep 20 09:25:39 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ext/gdbm/gdbm.c: add RDoc documentation. a patch from Peter
+ Adolphs <futzilogik at users dot sourceforge dot net>.
+ [ruby-doc:1223]
+
+Tue Sep 19 01:28:00 2006 Minero Aoki <aamine@loveruby.net>
+
+ * lib/fileutils.rb: backport from HEAD (rev 1.71).
+
+ * lib/fileutils.rb (FileUtils.cp_r): new option
+ :remove_destination.
+
+Tue Sep 19 00:42:15 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * object.c (rb_obj_ivar_defined, rb_mod_cvar_defined): new methods,
+ Kernel#instance_variable_defined? and Module#class_variable_defined?.
+ [ruby-dev:29587]
+
+ * lib/date/format.rb (Date::Bag#method_missing): use new method,
+ instance_variable_defined? to check if an instance variable is
+ defined. fixed: [ruby-dev:29554]
+ -- This didn't fix anything.
+
+Sun Sep 17 23:44:58 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * lib/rdoc/rdoc.rb (RDoc::RDoc#document): scan only files modified
+ after the previous generation.
+
+Sun Sep 17 17:42:13 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * common.mk (install-doc): reverted.
+
+ * instruby.rb: stores file name list without destdir prefix.
+
+ * lib/rdoc/generators/ri_generator.rb: do not chdir twice.
+
+Sat Sep 16 23:14:29 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ext/pty/pty.c (establishShell): remove remaining unused line.
+
+Sat Sep 16 16:40:44 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * Makefile.in, common.in, instruby.rb, ext/extmk.rb, lib/mkmf.rb:
+ use instruby.rb to install extensions instead of ext/extmk.rb.
+
+ * instruby.rb: store installed list into the file.
+
+ * ext/dbm/extconf.rb: allow multiple candidates for dbm-type.
+
+ * ext/io/wait/extconf.rb: suspicious checking_for.
+
+ * ext/pty/pty.c (establishShell): parent pid is not used.
+
+ * ext/pty/pty.c (freeDevice): not used.
+
+ * ext/pty/pty.c (get_device_once): removed garbage right brace.
+
+ * lib/mkmf.rb (checking_for): improved the messages.
+
+Thu Sep 14 16:11:15 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_intern): raise SecurityError only when $SAFE
+ level is greater than zero. [ruby-core:08862]
+
+ * parse.y (rb_interned_p): new function to check if a string is
+ already interned.
+
+ * object.c (str_to_id): use rb_str_intern().
+
+Wed Sep 13 18:43:05 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * README.EXT: English adjustment. [ruby-core:08851] and
+ [ruby-core:08852]
+
+Wed Sep 13 18:25:18 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * misc/ruby-mode.el (ruby-parse-partial): better here-doc support.
+ a patch from Marshall T. Vandegrift <llasram at gmail.com>.
+ [ruby-core:08804]
+
+Wed Sep 13 16:43:36 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_intern): prohibit interning tainted string.
+
+Wed Sep 13 01:14:21 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * lib/optparse.rb (OptionParser#getopts): works with pre-registered
+ options. [ruby-core:08826]
+
+Sun Sep 10 20:27:13 2006 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * lib/date.rb, lib/date/format.rb: updated based on date2 3.9.1.
+
+Tue Jan 10 09:18:03 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * eval.c (stack_extend): fixed prototype.
+
+ * eval.c (rb_require_safe): prevent extension from loading twice.
+ fixed: [ruby-dev:29523]
+
+Sat Sep 9 23:50:38 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * bignum.c (rb_big_mul0): bignum multiplication without
+ normalization.
+
+ * bignum.c (rb_big_pow): use rb_big_mul0(). [ruby-dev:29547]
+
+Sat Sep 9 14:08:38 2006 Eric Hodel <drbrain@segment7.net>
+
+ * lib/test/unit/testcase.rb (Test::Unit::TestCase#run): Rescue
+ Exception in Test::Unit::TestCase#run. [ruby-core:08783]
+
+Sat Sep 9 04:55:59 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * lib/pstore.rb: open all in binary mode, and get rid of the quirk of
+ msvcrt. fixed: [ruby-dev:29518]
+
+Sat Sep 9 04:54:42 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * Makefile.in, win32/Makefile.sub (MINIRUBY): append MINIRUBYOPT.
+
+ * mkconfig.rb, ext/extmk.rb, lib/mkmf.rb, win32/mkexports.rb: suppress
+ warnings with $VERBOSE.
+
+ * ext/extmk.rb: Proc#call does not pass the block in 1.8.
+
+ * win32/resource.rb: add more info.
+
+Fri Sep 8 10:03:59 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * lib/webrick/cookie.rb (WEBrick::Cookie.parse_set_cookies): new
+ method to parse multiple cookies per Set-Cookie header.
+ Thanks to Aaron Patterson <aaron_patterson at speakeasy.net>.
+ [ruby-core:08802]
+
+Fri Sep 8 08:59:30 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * win32/Makefile.sub, win32/configure.bat win32/setup.mak: program
+ name transform.
+
+Fri Sep 8 01:33:08 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ruby.h (RSTRING_PTR): add migration macro.
+
+ * ruby.h (RARRAY_PTR): ditto.
+
+Thu Sep 7 23:27:05 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * file.c (path_check_0, fpath_check): disable path check on cygwin.
+ [ruby-talk:213074]
+
+Wed Sep 06 12:05:19 2006 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * ext/nkf/lib/kconv.rb (Kconv::RegexpEucjp): fix regexp for euc-jp
+ [ruby-dev:29344]
+
+ * ext/nkf/lib/kconv.rb (Kconv::toeuc): remove -m0 [ruby-dev:29505]
+
+Tue Sep 5 06:47:22 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * time.c (time_to_s): variable declaration after an execution
+ statement.
+
+Tue Sep 5 05:56:51 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * numeric.c (flo_hash): improve collision. fixed: [ruby-dev:29352]
+
+Tue Sep 5 05:49:41 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * file.c (path_check_0): check if sticky bit is set on parent
+ directories for executable path. fixed: [ruby-dev:29415]
+
+Tue Sep 5 05:03:46 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * numeric.c (fix_plus): addition in Fixnum will never overflow
+ long. a patch from Ondrej Bilka <neleai at seznam.cz>.
+ [ruby-core:08794]
+
+ * numeric.c (fix_minus): ditto.
+
+ * bignum.c (rb_big_pow): eagerly truncate resulting bignum.
+ [ruby-core:08794]
+
+Mon Sep 4 23:15:34 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * time.c (time_to_s): make it conform to RFC2822 date format.
+ [ruby-dev:29467]
+
Mon Sep 4 21:43:57 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/dbm/extconf.rb: create makefile according to the result of check
for dbm header. fixed: [ruby-dev:29445]
+Mon Sep 4 21:42:35 2006 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * lib/date.rb, lib/date/format.rb: updated based on date2 3.9.
+
+Mon Sep 4 21:14:20 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * time.c (time_strftime): include nul character. fixed: [ruby-dev:29422]
+
+Mon Sep 4 16:29:33 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/cgi.rb (CGI::out): specify -m0 -x option for nkf.
+ [ruby-dev:29284]
+
+Mon Sep 4 16:13:23 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (pipe_open): command name should not contain null bytes.
+ [ruby-dev:29421]
+
+ * process.c (proc_spawn): ditto.
+
+ * process.c (proc_spawn_n): ditto.
+
+ * process.c (rb_f_system): ditto.
+
+Sun Sep 3 15:32:44 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * lib/mkmf.rb: get rid of nil.to_s.
+
+Sun Sep 3 06:24:38 2006 Tanaka Akira <akr@fsij.org>
+
+ * ext/socket/socket.c (ruby_connect): sockerrlen should be socklen_t.
+
+Sun Sep 3 04:40:42 2006 Tanaka Akira <akr@fsij.org>
+
+ * ext/socket/extconf.rb: check arpa/inet.h for ntohs.
+
+ * ext/socket/socket.c: include arpa/inet.h if available.
+
+Sun Sep 3 02:34:55 2006 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+
+ * lib/drb/unix.rb (DRbUNIXSocket#close): don't get path if client mode.
+ [ruby-dev:29417]
+
+Sun Sep 3 01:45:17 2006 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+
+ * lib/drb/acl.rb (ACLEntry#initialize): examine whether '*' is
+ included before IPAddr.new. [ruby-dev:29406]
+
+Sat Sep 2 13:23:01 2006 Tanaka Akira <akr@fsij.org>
+
+ * common.mk (ia64.o): use the compiler driver to assemble ia64.s
+ to use appropriate ABI.
+
+Sat Sep 2 03:36:22 2006 Tanaka Akira <akr@fsij.org>
+
+ * common.mk, configure.in, defines.h, eval.c, gc.c, main.c,
+ numeric.c, ruby.h, ia64.s: backport IA64 HP-UX support.
+
+Fri Sep 1 13:52:57 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib/tk/font.rb: TkFont#current_configinfo() doesn't work
+ on Tcl/Tk8.x.
+
+Thu Aug 31 12:46:55 2006 why the lucky stiff <why@ruby-lang.org>
+
+ * eval.c (ruby_init): rename top_cref to ruby_top_cref and export,
+ along with ruby_cref, for use by the sandbox. [ruby-core:08762]
+
+ * node.h: ditto.
+
Tue Aug 29 19:10:10 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* hash.c (rb_hash_s_create): fixed memory leak, based on the patch
by Kent Sibilev <ksruby at gmail.com>. fixed: [ruby-talk:211233]
+Mon Aug 28 11:36:02 2006 Eric Hodel <drbrain@segment7.net>
+
+ * lib/rdoc/parsers/parse_rb.rb: Fix typo. Submitted by
+ <calamitas at gmail.com>. [ruby-core:08724]
+
+Mon Aug 28 07:53:44 2006 Eric Hodel <drbrain@segment7.net>
+
+ * lib/rdoc/ri/ri_formatter.rb: Don't unescape HTML in HtmlFormatter.
+ Submitted by Kent Sibilev <ksruby at gmail.com>. [ruby-core:08392].
+
+Mon Aug 28 07:25:45 2006 Eric Hodel <drbrain@segment7.net>
+
+ * file.c (File#size?): Fix documentation submitted by Rick Ohnemus.
+ ruby-Bugs-5529. [ruby-core:08725]
+
+Sat Aug 26 08:07:13 2006 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * lib/date.rb, lib/date/format.rb: updated based on date2 3.8.2.
+
+Fri Aug 25 22:32:04 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * lib/rexml/source.rb (REXML::IOSource#initialize): encoding have to
+ be set with the accessor. fixed: [ruby-list:42737]
+
Fri Aug 25 17:15:17 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* stable version 1.8.5 released.
@@ -1208,7 +1879,7 @@ Tue Aug 22 18:47:51 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser::handle_method):
rdoc documents C module methods as instance methods. a patch in
- [ruby-core:08536].
+ [ruby-core:08536].
Sat Aug 19 14:15:02 2006 NAKAMURA Usaku <usa@ruby-lang.org>
@@ -13012,7 +13683,7 @@ Wed Feb 18 17:18:01 2004 WATANABE Hirofumi <eban@ruby-lang.org>
Wed Feb 18 10:40:38 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* sprintf.c (rb_f_sprintf): do not prepend dots for negative
- numbers if FZERO is specified. [ruby-list:39218]
+ numbers if FZERO is specified. [ruby-dev:39218]
Tue Feb 17 23:40:34 2004 Guy Decoux <ts@moulon.inra.fr>
diff --git a/Makefile.in b/Makefile.in
index 8fd59babcd..1e372885b7 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,4 +1,5 @@
SHELL = /bin/sh
+NULLCMD = :
#### Start of system configuration section. ####
@@ -52,7 +53,7 @@ RUBY_SO_NAME=@RUBY_SO_NAME@
EXEEXT = @EXEEXT@
PROGRAM=$(RUBY_INSTALL_NAME)$(EXEEXT)
RUBY = $(RUBY_INSTALL_NAME)
-MINIRUBY = @MINIRUBY@
+MINIRUBY = @MINIRUBY@ $(MINIRUBYOPT)
RUNRUBY = @RUNRUBY@
#### End of system configuration section. ####
@@ -85,7 +86,7 @@ ASFLAGS = @ASFLAGS@
OBJEXT = @OBJEXT@
MANTYPE = @MANTYPE@
-PREINSTALL = @PREINSTALL@
+INSTALLED_LIST= .installed.list
#### End of variables
all:
@@ -97,7 +98,7 @@ all:
miniruby$(EXEEXT):
@$(RM) $@
- $(PURIFY) $(CC) $(MAINOBJ) $(MINIOBJS) $(LIBRUBY_A) $(LIBS) $(OUTFLAG)$@ $(LDFLAGS) $(MAINLIBS)
+ $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINLIBS) $(MAINOBJ) $(MINIOBJS) $(LIBRUBY_A) $(LIBS) $(OUTFLAG)$@
$(PROGRAM):
@$(RM) $@
@@ -112,6 +113,7 @@ $(LIBRUBY_A):
@-$(RANLIB) $@ 2> /dev/null || true
$(LIBRUBY_SO):
+ @-$(PRE_LIBRUBY_UPDATE)
$(LDSHARED) $(DLDFLAGS) $(OBJS) $(DLDOBJS) $(SOLIBS) $(OUTFLAG)$@
@-$(MINIRUBY) -e 'ARGV.each{|link| File.delete link if File.exist? link; \
File.symlink "$(LIBRUBY_SO)", link}' \
@@ -175,4 +177,4 @@ distclean-local::
@$(RM) ext/config.cache $(RBCONFIG)
ext/extinit.$(OBJEXT): ext/extinit.c $(SETUP)
- $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(OUTFLAG)$@ -c ext/extinit.c
+ $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -o$@ -c ext/extinit.c
diff --git a/NEWS b/NEWS
new file mode 100644
index 0000000000..de1dafb533
--- /dev/null
+++ b/NEWS
@@ -0,0 +1,115 @@
+= NEWS
+
+This document is a list of user visible feature changes made between
+releases excluding bug fixes.
+
+Note that each entry is kept so brief that no reason behind or
+reference information is supplied with. For a full list of changes
+with all sufficient information, see the ChangeLog file.
+
+== Changes with Ruby 1.8.5
+
+=== New platforms/build tools support
+
+* IA64 HP-UX
+
+* Visual C++ 8 SP1
+
+* autoconf 2.6x
+
+=== Library updates (outstanding ones only)
+
+* date
+
+ * Updated based on date2 4.0.3.
+
+* digest
+
+ * New internal APIs for C and Ruby.
+
+ * Support for autoloading.
+
+ * See below for new features and compatibility issues.
+
+* nkf
+
+ * Updated based on nkf as of 2007-01-28.
+
+* tk
+
+ * Tk::X_Scrollable (Y_Scrollable) is renamed to Tk::XScrollable
+ (YScrollable). Tk::X_Scrollable (Y_Scrollable) is still available,
+ but it is an alias name.
+
+ * Updated Tile extension support based on Tile 0.7.8.
+
+ * Support --without-X11 configure option for non-X11 versions of
+ Tcl/Tk (e.g. Tcl/Tk Aqua).
+
+ * New sample script: irbtkw.rbw -- IRB on Ruby/Tk. It has no trouble
+ about STDIN blocking on Windows.
+
+=== New methods and features
+
+* builtin classes
+
+ * New method: Kernel#instance_variable_defined?
+
+ * New method: Module#class_variable_defined?
+
+ * New feature: Dir::glob() can now take an array of glob patterns.
+
+* digest
+
+ * New digest class methods: file
+
+ * New digest instance methods: clone, reset, new,
+ inspect, digest_length (alias size or length),
+ block_length()
+
+ * New library: digest/bubblebabble
+
+ * New function: Digest(name)
+
+* fileutils
+
+ * New option for FileUtils.cp_r(): :remove_destination
+
+* thread
+
+ * Replaced with much faster mutex implementation in C.
+ The former implementation is available with a
+ configure option `--disable-fastthread'.
+
+* webrick
+
+ * New method: WEBrick::Cookie.parse_set_cookies()
+
+=== Compatibility issues (excluding feature bug fixes)
+
+* builtin classes
+
+ * String#intern now raises SecurityError when $SAFE level is greater
+ than zero.
+
+* fileutils
+
+ * A minor implementation change breaks Rake <=0.7.1.
+ Updating Rake to 0.7.2 fixes the problem.
+
+* digest
+
+ * The constructor does no longer take an initial
+ string to feed; digest() and hexdigest() now do,
+ instead. The following examples show how to
+ migrate:
+
+ # Before
+ md = Digest::MD5.new("string")
+ # After (works with any version)
+ md = Digest::MD5.new.update("string")
+
+ # Before
+ hd = Digest::MD5.new("string").hexdigest
+ # After (works with any version)
+ hd = Digest::MD5.hexdigest("string")
diff --git a/README.EXT b/README.EXT
index e5d39911ca..2fc2fd606a 100644
--- a/README.EXT
+++ b/README.EXT
@@ -8,8 +8,8 @@ In C, variables have types and data do not have types. In contrast,
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 are represented by C type `VALUE'. Each VALUE data has
-its data-type.
+Data in Ruby are represented by the C type `VALUE'. Each VALUE data
+has its data-type.
To retrieve C data from a VALUE, you need to:
@@ -91,26 +91,26 @@ 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 a 31bit length fixed integer (63bit length on
-some machines), which can be convert to a C integer by using the
+some machines), which can be converted 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.
+be used to retrieve the double float value in the 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.7 or later it is recommended that you use the new macros
+StringValue() and StringValuePtr() to get a char* from a VALUE.
+StringValue(var) replaces var's value with 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 take only the lvalue as their
+argument, to change the value of var in place.
-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.
+In version 1.6 or earlier, STR2CSTR() was used to do the same thing
+but now it is deprecated in version 1.7, because STR2CSTR() has a risk
+of a dangling pointer problem in the to_str() impliclit conversion.
Other data types have corresponding C structures, e.g. struct RArray
-for T_ARRAY etc. The VALUE of the type which has corresponding structure
+for T_ARRAY etc. The VALUE of the type which has the corresponding structure
can be cast to retrieve the pointer to the struct. The casting macro
will be of the form RXXXX for each data type; for instance, RARRAY(obj).
See "ruby.h".
@@ -205,7 +205,7 @@ interpreter. Some (not all) of the useful functions are listed below:
rb_ary_unshift(VALUE ary, VALUE val)
Array operations. The first argument to each functions must be an
- array. They may dump core if other types given.
+ array. They may dump core if other types are given.
2. Extending Ruby with C
@@ -244,7 +244,7 @@ To define methods or singleton methods, use these functions:
VALUE (*func)(), int argc)
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. :-)
+which must be less than 17. But I doubt you'll need that many.
If `argc' is negative, it specifies the calling sequence, not number of
the arguments.
@@ -272,7 +272,7 @@ private methods:
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:
+defined in Math module. It can be called in the following way:
Math.sqrt(4)
@@ -291,7 +291,7 @@ in the Kernel module, can be defined using:
void rb_define_global_function(const char *name, VALUE (*func)(), int argc)
-To define alias to the method,
+To define an alias for the method,
void rb_define_alias(VALUE module, const char* new, const char* old);
@@ -321,7 +321,7 @@ There are several ways to invoke Ruby's features from C code.
2.2.1 Evaluate Ruby Programs in a String
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.
+evaluate the string as Ruby program. This function will do the job:
VALUE rb_eval_string(const char *str)
@@ -434,7 +434,7 @@ 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
+3.3 Encapsulate C data into a Ruby object
To wrap and objectify a C pointer as a Ruby object (so called
DATA), use Data_Wrap_Struct().
@@ -619,7 +619,7 @@ are not exported to the Ruby world. You need to protect them by
If the file named extconf.rb exists, it will be executed to generate
Makefile.
-extconf.rb is the file for check compilation conditions etc. You
+extconf.rb is the file for checking compilation conditions etc. You
need to put
require 'mkmf'
@@ -639,12 +639,12 @@ The value of the variables below will affect the Makefile.
$LDFLAGS: included in LDFLAGS make variable (such as -L)
$objs: list of object file names
-In normal, object files list is automatically generated by searching
-source files, but you need directs them explicitly if any sources will
+Normally, the object files list is automatically generated by searching
+source files, but you must define them explicitly if any sources will
be generated while building.
If a compilation condition is not fulfilled, you should not call
-``create_makefile''. The Makefile will not generated, compilation will
+``create_makefile''. The Makefile will not be generated, compilation will
not be done.
(5) prepare depend (optional)
@@ -654,7 +654,7 @@ check dependencies. You can make this file by invoking
% gcc -MM *.c > depend
-It's no harm. Prepare it.
+It's harmless. Prepare it.
(6) generate Makefile
@@ -673,12 +673,12 @@ Type
make
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.
+put the extension library under the ext directory of the ruby source tree.
(8) debug
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
+statically by adding the directory name in the ext/Setup file so that
you can inspect the extension with the debugger.
(9) done, now you have the extension library
@@ -843,15 +843,15 @@ it can't be seen from Ruby programs.
void rb_define_readonly_variable(const char *name, VALUE *var)
Defines a read-only global variable. Works just like
-rb_define_variable(), except defined variable is read-only.
+rb_define_variable(), except the 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 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:
+referenced. The setter function is called when the variable is set to a
+value. The prototype for getter/setter functions are:
VALUE getter(ID id)
void setter(VALUE val, ID id)
@@ -1011,7 +1011,7 @@ Terminates the interpreter immediately. This function should be
called under the situation caused by the bug in the interpreter. No
exception handling nor ensure execution will be done.
-** Initialize and Starts the Interpreter
+** Initialize and Start the Interpreter
The embedding API functions are below (not needed for extension libraries):
@@ -1031,6 +1031,32 @@ Starts execution of the interpreter.
Specifies the name of the script ($0).
+** Hooks for the Interpreter Events
+
+ void rb_add_event_hook(rb_event_hook_func_t func, rb_event_t events)
+
+Adds a hook function for the specified interpreter events.
+events should be Or'ed value of:
+
+ RUBY_EVENT_LINE
+ RUBY_EVENT_CLASS
+ RUBY_EVENT_END
+ RUBY_EVENT_CALL
+ RUBY_EVENT_RETURN
+ RUBY_EVENT_C_CALL
+ RUBY_EVENT_C_RETURN
+ RUBY_EVENT_RAISE
+ RUBY_EVENT_ALL
+
+The definition of rb_event_hook_func_t is below:
+
+ typedef void (*rb_event_hook_func_t)(rb_event_t event, NODE *node,
+ VALUE self, ID id, VALUE klass)
+
+ int rb_remove_event_hook(rb_event_hook_func_t func)
+
+Removes the specified hook function.
+
Appendix C. Functions Available in extconf.rb
These functions are available in extconf.rb:
@@ -1122,7 +1148,7 @@ Returns an array of the added directories ([include_dir, lib_dir]).
pkg_config(pkg)
-Obtains the information of pkg by pkg-config command. The actual
+Obtains the information for pkg by pkg-config command. The actual
command name can be overriden by --with-pkg-config command line
option.
diff --git a/array.c b/array.c
index baae2706e5..acc59d20b4 100644
--- a/array.c
+++ b/array.c
@@ -2,8 +2,8 @@
array.c -
- $Author: akr $
- $Date: 2006/06/24 14:53:36 $
+ $Author$
+ $Date$
created at: Fri Aug 6 09:46:12 JST 1993
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -272,7 +272,6 @@ 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()) {
@@ -296,6 +295,7 @@ rb_ary_initialize(argc, argv, ary)
if (len > 0 && len * (long)sizeof(VALUE) <= len) {
rb_raise(rb_eArgError, "array size too big");
}
+ rb_ary_modify(ary);
if (len > RARRAY(ary)->aux.capa) {
REALLOC_N(RARRAY(ary)->ptr, VALUE, len);
RARRAY(ary)->aux.capa = len;
@@ -501,8 +501,16 @@ rb_ary_shift(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 */
+ if (RARRAY_LEN(ary) < ARY_DEFAULT_SIZE && !FL_TEST(ary, ELTS_SHARED)) {
+ MEMMOVE(RARRAY_PTR(ary), RARRAY_PTR(ary)+1, VALUE, RARRAY_LEN(ary)-1);
+ }
+ else {
+ if (!FL_TEST(ary, ELTS_SHARED)) {
+ RARRAY(ary)->ptr[0] = Qnil;
+ }
+ ary_make_shared(ary);
+ RARRAY(ary)->ptr++; /* shift ptr */
+ }
RARRAY(ary)->len--;
return top;
@@ -598,7 +606,7 @@ rb_ary_subseq(ary, beg, len)
if (beg > RARRAY(ary)->len) return Qnil;
if (beg < 0 || len < 0) return Qnil;
- if (RARRAY(ary)->len < len || RARRAY(ary)->len < beg + len) {
+ if (beg + len > RARRAY(ary)->len) {
len = RARRAY(ary)->len - beg;
if (len < 0)
len = 0;
@@ -953,7 +961,7 @@ rb_ary_splice(ary, beg, len, rpl)
rb_raise(rb_eIndexError, "index %ld out of array", beg);
}
}
- if (RARRAY(ary)->len < len || RARRAY(ary)->len < beg + len) {
+ if (beg + len > RARRAY(ary)->len) {
len = RARRAY(ary)->len - beg;
}
@@ -2258,9 +2266,6 @@ rb_ary_fill(argc, argv, ary)
}
rb_ary_modify(ary);
end = beg + len;
- if (end < 0) {
- rb_raise(rb_eArgError, "argument too big");
- }
if (end > RARRAY(ary)->len) {
if (end >= RARRAY(ary)->aux.capa) {
REALLOC_N(RARRAY(ary)->ptr, VALUE, end);
diff --git a/bcc32/Makefile.sub b/bcc32/Makefile.sub
index de7a2beeb8..0c2fe7cdf6 100644
--- a/bcc32/Makefile.sub
+++ b/bcc32/Makefile.sub
@@ -135,7 +135,7 @@ MISSING = acosh.obj crypt.obj erf.obj win32.obj
STACK = 0x2000000
!endif
-XCFLAGS = -DRUBY_EXPORT -I. -I$(srcdir) -I$(srcdir)/missing
+XCFLAGS = -DRUBY_EXPORT -I. -I$(srcdir) -I$(srcdir)missing
ARFLAGS = /a
LD = ilink32 -q -Gn
@@ -153,8 +153,8 @@ EXEEXT = .exe
PROGRAM=$(RUBY_INSTALL_NAME)$(EXEEXT)
WPROGRAM=$(RUBYW_INSTALL_NAME)$(EXEEXT)
RUBYDEF = $(RUBY_SO_NAME).def
-MINIRUBY = .\miniruby$(EXEEXT)
-RUNRUBY = .\ruby$(EXEEXT) "$(srcdir)/runruby.rb" --extout="$(EXTOUT)" --
+MINIRUBY = .\miniruby$(EXEEXT) $(MINIRUBYOPT)
+RUNRUBY = .\ruby$(EXEEXT) "$(srcdir)runruby.rb" --extout="$(EXTOUT)" --
ORGLIBPATH = $(LIB)
@@ -169,11 +169,13 @@ PREP = miniruby$(EXEEXT)
OBJEXT = obj
+INSTALLED_LIST= .installed.list
+
WINMAINOBJ = winmain.$(OBJEXT)
MINIOBJS = dmydln.$(OBJEXT)
-.path.c = .;$(srcdir);$(srcdir)/win32;$(srcdir)/missing
-.path.h = .;$(srcdir);$(srcdir)/win32;$(srcdir)/missing
+.path.c = .;$(srcdir);$(srcdir)win32;$(srcdir)missing
+.path.h = .;$(srcdir);$(srcdir)win32;$(srcdir)missing
.path.y = $(srcdir)
.path. = $(srcdir)
@@ -181,14 +183,14 @@ MINIOBJS = dmydln.$(OBJEXT)
$(CC) $(CFLAGS) $(XCFLAGS) -I. $(CPPFLAGS) -c $(<:/=\)
.rc.res:
- $(RC) $(RFLAGS) -I. -I$(<D). $(iconinc) -I$(srcdir)/win32 $(RFLAGS) -fo$@ $(<:/=\)
+ $(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
-all: $(srcdir)/bcc32/Makefile.sub $(srcdir)/common.mk
+all: $(srcdir)bcc32/Makefile.sub $(srcdir)common.mk
ruby: $(PROGRAM)
rubyw: $(WPROGRAM)
@@ -203,8 +205,8 @@ config: config.status
config.status: $(CONFIG_H)
-$(CONFIG_H): $(MKFILES) $(srcdir)/bcc32/Makefile.sub
- @$(srcdir:/=\)\win32\ifchange.bat config.h &&|
+$(CONFIG_H): $(MKFILES) $(srcdir)bcc32/Makefile.sub
+ @$(srcdir:/=\)win32\ifchange.bat config.h &&|
\#define HAVE_SYS_TYPES_H 1
\#define HAVE_SYS_STAT_H 1
\#define HAVE_STDLIB_H 1
@@ -284,7 +286,7 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/bcc32/Makefile.sub
|
@exit > $@
-config.status: $(MKFILES) $(srcdir)/bcc32/Makefile.sub $(srcdir)/common.mk
+config.status: $(MKFILES) $(srcdir)bcc32/Makefile.sub $(srcdir)common.mk
@echo Creating $@
@type > $@ &&|
# Generated automatically by Makefile.sub.
@@ -336,9 +338,6 @@ s,@ARFLAGS@,$(ARFLAGS) ,;t t
s,@LN_S@,$(LN_S),;t t
s,@SET_MAKE@,$(SET_MAKE),;t t
s,@CP@,copy > nul,;t t
-s,@INSTALL@,copy > nul,;t t
-s,@INSTALL_PROG@,$$(INSTALL),;t t
-s,@INSTALL_DATA@,$$(INSTALL),;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
@@ -389,7 +388,7 @@ s,@COMPILE_CXX@,$$(CXX) $$(INCFLAGS) $$(CXXFLAGS) $$(CPPFLAGS) -P -c $$(<:/=\),;
s,@COMPILE_RULES@,{$$(srcdir)}.%s{}.%s: {$$(topdir)}.%s{}.%s: {$$(hdrdir)}.%s{}.%s: .%s.%s:,;t t
s,@RULE_SUBST@,{.;$$(VPATH)}%s,;t t
s,@COMMON_LIBS@,m advapi32 avicap32 avifil32 cap comctl32 comdlg32 dlcapi gdi32 glu32 imagehlp imm32 inetmib1 kernel32 loadperf lsapi32 lz32 mapi32 mgmtapi mpr msacm32 msvfw32 nddeapi netapi32 ole32 oleaut32 oledlg olepro32 opengl32 pdh pkpd32 rasapi32 rasdlg rassapi rpcrt4 setupapi shell32 shfolder snmpapi sporder tapi32 url user32 vdmdbg version win32spl winmm wintrust wsock32,;t t
-s,@COMMON_MACROS@,WIN32_LEAN_AND_MEAN WIN32,;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
@@ -421,23 +420,33 @@ $(LIBRUBY_A): $(OBJS) $(DMYEXT)
$(LIBRUBY_SO): $(LIBRUBY_A) $(DLDOBJS) $(RUBYDEF) $(RUBY_SO_NAME).res
@echo $(DLDOBJS)
+ @$(PRE_LIBRUBY_UPDATE)
$(LIBRUBY_LDSHARED) $(LIBRUBY_DLDFLAGS) $(DLDOBJS:/=\),$(LIBRUBY_SO),nul,$(LIBRUBY_A) $(LIBS),$(RUBYDEF),$(RUBY_SO_NAME).res
$(LIBRUBY): $(LIBRUBY_SO)
$(RUBYDEF): $(LIBRUBY_A) $(PREP)
- $(MINIRUBY) $(srcdir)/bcc32/mkexports.rb -output=$@ -base=$(RUBY_SO_NAME) $(LIBRUBY_A)
+ $(MINIRUBY) $(srcdir)bcc32/mkexports.rb -output=$@ -base=$(RUBY_SO_NAME) $(LIBRUBY_A)
$(RUBY_INSTALL_NAME).rc $(RUBYW_INSTALL_NAME).rc $(RUBY_SO_NAME).rc: rbconfig.rb
- @$(MINIRUBY) $(srcdir)/win32/resource.rb \
+ @$(MINIRUBY) $(srcdir)win32/resource.rb \
-ruby_name=$(RUBY_INSTALL_NAME) \
-rubyw_name=$(RUBYW_INSTALL_NAME) \
-so_name=$(RUBY_SO_NAME) \
- . $(icondirs) $(srcdir)/win32
-
-post-install-ext::
- $(MINIRUBY) -I$(srcdir)lib -rrbconfig -rfileutils \
- -e "FileUtils.rm_f(Dir[ARGV[0]+Config::CONFIG['archdir']+'/**/*.tds'])" "$(DESTDIR:\=/)"
+ . $(icondirs) $(srcdir)win32
+
+post-install-bin::
+ @$(NULLCMD)
+post-install-lib::
+ @$(NULLCMD)
+post-install-ext-comm::
+ @$(NULLCMD)
+post-install-ext-arch::
+ @$(NULLCMD)
+post-install-man::
+ @$(NULLCMD)
+post-install-doc::
+ @$(NULLCMD)
clean-local::
@$(RM) ext\extinit.c ext\extinit.$(OBJEXT) *.tds *.il? $(RUBY_SO_NAME).lib
diff --git a/bcc32/configure.bat b/bcc32/configure.bat
index 123a3f23c8..143ad947f0 100755
--- a/bcc32/configure.bat
+++ b/bcc32/configure.bat
@@ -69,7 +69,7 @@ goto :loop
shift
goto :loop
:extout
- echo>> ~tmp~.mak "EXTOUT=%2" \
+ echo>> ~tmp~.mak -D"EXTOUT=%2" \
shift
shift
goto :loop
@@ -87,6 +87,6 @@ goto :loop
del ~tmp~.mak
goto :exit
:end
-echo>> ~tmp~.mak bcc32dir="$(@D)"
+echo>> ~tmp~.mak -Dbcc32dir="$(@D)"
make -s -f ~tmp~.mak
:exit
diff --git a/bcc32/mkexports.rb b/bcc32/mkexports.rb
index e34b441e2f..dc523e2541 100644..100755
--- a/bcc32/mkexports.rb
+++ b/bcc32/mkexports.rb
@@ -1,5 +1,7 @@
#!./miniruby -s
+$name = $library = $description = nil
+
SYM = {}
STDIN.reopen(open("nul"))
ARGV.each do |obj|
diff --git a/bcc32/setup.mak b/bcc32/setup.mak
index b7a2539d0a..1c922c208f 100644
--- a/bcc32/setup.mak
+++ b/bcc32/setup.mak
@@ -1,13 +1,13 @@
# -*- makefile -*-
!if "$(srcdir)" != ""
-bcc32dir = $(srcdir)/bcc32
+bcc32dir = $(srcdir)bcc32/
!elseif "$(bcc32dir)" == "bcc32/"
-srcdir = .
+srcdir = ./
!elseif "$(bcc32dir:/bcc32/=)/bcc32/" == "$(bcc32dir)"
-srcdir = $(bcc32dir:/bcc32/=)
+srcdir = $(bcc32dir:/bcc32/=/)
!else
-srcdir = $(bcc32dir)/..
+srcdir = $(bcc32dir)../
!endif
!ifndef prefix
prefix = /usr
@@ -62,7 +62,7 @@ if exist usebormm.tds echo MEMLIB = usebormm.lib
@usebormm.bat >> $(MAKEFILE)
@del usebormm.*
- @cpp32 -I$(srcdir) -P- -o$(MAKEFILE) > nul &&|
+ @cpp32 -I$(srcdir) -DRUBY_EXTERN="//" -P- -o$(MAKEFILE) > nul &&|
\#include "version.h"
MAJOR = RUBY_VERSION_MAJOR
MINOR = RUBY_VERSION_MINOR
@@ -122,12 +122,12 @@ $(BANG)endif
\# RUBY_INSTALL_NAME = ruby
\# RUBY_SO_NAME = $$(RT)-$$(RUBY_INSTALL_NAME)$$(MAJOR)$$(MINOR)
\# 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)\"
+\# 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
-$(BANG)include $$(srcdir)/bcc32/Makefile.sub
+$(BANG)include $$(srcdir)bcc32/Makefile.sub
|
@$(srcdir:/=\)\win32\rm.bat config.h config.status
@echo type "`$(MAKE)'" to make ruby for $(OS).
diff --git a/bignum.c b/bignum.c
index ee9c38aff9..0beecd4a75 100644
--- a/bignum.c
+++ b/bignum.c
@@ -2,8 +2,8 @@
bignum.c -
- $Author: shyouhei $
- $Date: 2006/12/06 10:14:12 $
+ $Author$
+ $Date$
created at: Fri Jun 10 00:48:55 JST 1994
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -36,21 +36,7 @@ VALUE rb_cBignum;
#define BIGLO(x) ((BDIGIT)((x) & (BIGRAD-1)))
#define BDIGMAX ((BDIGIT)-1)
-#define BIGZEROP(x) (RBIGNUM(x)->len == 0 || \
- (BDIGITS(x)[0] == 0 && \
- (RBIGNUM(x)->len == 1 || bigzero_p(x))))
-
-static int bigzero_p(VALUE);
-static int
-bigzero_p(x)
- VALUE x;
-{
- long i;
- for (i = 0; i < RBIGNUM(x)->len; ++i) {
- if (BDIGITS(x)[i]) return 0;
- }
- return 1;
-}
+#define BIGZEROP(x) (RBIGNUM(x)->len == 0 || (RBIGNUM(x)->len == 1 && BDIGITS(x)[0] == 0))
static VALUE
bignew_1(klass, len, sign)
@@ -88,7 +74,6 @@ get2comp(x)
BDIGIT *ds = BDIGITS(x);
BDIGIT_DBL num;
- if (!i) return;
while (i--) ds[i] = ~ds[i];
i = 0; num = 1;
do {
@@ -111,35 +96,49 @@ rb_big_2comp(x) /* get 2's complement */
}
static VALUE
-bignorm(x)
+bigtrunc(x)
VALUE x;
{
- if (FIXNUM_P(x)) {
- return x;
- }
- else if (TYPE(x) == T_BIGNUM) {
- long len = RBIGNUM(x)->len;
- BDIGIT *ds = BDIGITS(x);
+ long len = RBIGNUM(x)->len;
+ BDIGIT *ds = BDIGITS(x);
- while (--len && !ds[len]) ;
- RBIGNUM(x)->len = ++len;
+ while (len-- && !ds[len]);
+ RBIGNUM(x)->len = ++len;
+ return x;
+}
- if (len*SIZEOF_BDIGITS <= sizeof(VALUE)) {
- long num = 0;
- while (len--) {
- num = BIGUP(num) + ds[len];
+static VALUE
+bigfixize(VALUE x)
+{
+ long len = RBIGNUM(x)->len;
+ BDIGIT *ds = BDIGITS(x);
+
+ 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 LONG2FIX(num);
}
- if (num >= 0) {
- if (RBIGNUM(x)->sign) {
- if (POSFIXABLE(num)) return LONG2FIX(num);
- }
- else if (NEGFIXABLE(-(long)num)) return LONG2FIX(-(long)num);
+ else {
+ if (NEGFIXABLE(-(long)num)) return LONG2FIX(-(long)num);
}
}
}
return x;
}
+static VALUE
+bignorm(VALUE x)
+{
+ if (!FIXNUM_P(x) && TYPE(x) == T_BIGNUM) {
+ x = bigfixize(bigtrunc(x));
+ }
+ return x;
+}
+
VALUE
rb_big_norm(x)
VALUE x;
@@ -346,13 +345,6 @@ rb_cstr_to_inum(str, base, badcheck)
VALUE z;
BDIGIT *zds;
-#define conv_digit(c) \
- (!ISASCII(c) ? -1 : \
- isdigit(c) ? ((c) - '0') : \
- islower(c) ? ((c) - 'a' + 10) : \
- isupper(c) ? ((c) - 'A' + 10) : \
- -1)
-
if (!str) {
if (badcheck) goto bad;
return INT2FIX(0);
@@ -445,13 +437,7 @@ rb_cstr_to_inum(str, base, badcheck)
}
if (*str == '0') { /* squeeze preceeding 0s */
while (*++str == '0');
- if (!(c = *str) || ISSPACE(c)) --str;
- }
- c = *str;
- c = conv_digit(c);
- if (c < 0 || c >= base) {
- if (badcheck) goto bad;
- return INT2FIX(0);
+ --str;
}
len *= strlen(str)*sizeof(char);
@@ -485,7 +471,7 @@ rb_cstr_to_inum(str, base, badcheck)
z = bignew(len, sign);
zds = BDIGITS(z);
for (i=len;i--;) zds[i]=0;
- while ((c = *str++) != 0) {
+ while (c = *str++) {
if (c == '_') {
if (badcheck) {
if (nondigit) goto bad;
@@ -493,7 +479,19 @@ rb_cstr_to_inum(str, base, badcheck)
}
continue;
}
- else if ((c = conv_digit(c)) < 0) {
+ 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;
@@ -633,15 +631,16 @@ rb_str2inum(str, base)
const char ruby_digitmap[] = "0123456789abcdefghijklmnopqrstuvwxyz";
VALUE
-rb_big2str(x, base)
+rb_big2str0(x, base, trim)
VALUE x;
int base;
+ int trim;
{
volatile VALUE t;
BDIGIT *ds;
long i, j, hbase;
VALUE ss;
- char *s, c;
+ char *s;
if (FIXNUM_P(x)) {
return rb_fix2str(x, base);
@@ -650,37 +649,34 @@ rb_big2str(x, base)
if (BIGZEROP(x)) {
return rb_str_new2("0");
}
- if (i >= LONG_MAX/SIZEOF_BDIGITS/CHAR_BIT) {
- rb_raise(rb_eRangeError, "bignum too big to convert into `string'");
- }
j = SIZEOF_BDIGITS*CHAR_BIT*i;
switch (base) {
case 2: break;
case 3:
- j = j * 647L / 1024;
+ j = j * 53L / 84 + 1;
break;
case 4: case 5: case 6: case 7:
- j /= 2;
+ j = (j + 1) / 2;
break;
case 8: case 9:
- j /= 3;
+ j = (j + 2) / 3;
break;
case 10: case 11: case 12: case 13: case 14: case 15:
- j = j * 241L / 800;
+ j = j * 28L / 93 + 1;
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;
+ j = (j + 3) / 4;
break;
case 32: case 33: case 34: case 35: case 36:
- j /= 5;
+ j = (j + 4) / 5;
break;
default:
rb_raise(rb_eArgError, "illegal radix %d", base);
break;
}
- j += 2;
+ j++; /* space for sign */
hbase = base * base;
#if SIZEOF_BDIGITS > 2
@@ -689,11 +685,11 @@ rb_big2str(x, base)
t = rb_big_clone(x);
ds = BDIGITS(t);
- ss = rb_str_new(0, j);
+ ss = rb_str_new(0, j+1);
s = RSTRING(ss)->ptr;
s[0] = RBIGNUM(x)->sign ? '+' : '-';
- while (i && j) {
+ while (i && j > 1) {
long k = i;
BDIGIT_DBL num = 0;
@@ -702,23 +698,36 @@ rb_big2str(x, base)
ds[k] = (BDIGIT)(num / hbase);
num %= hbase;
}
- if (ds[i-1] == 0) i--;
+ if (trim && ds[i-1] == 0) i--;
k = SIZEOF_BDIGITS;
while (k--) {
- c = (char)(num % base);
- s[--j] = ruby_digitmap[(int)c];
+ s[--j] = ruby_digitmap[num % base];
num /= base;
- if (i == 0 && num == 0) break;
+ if (!trim && j < 1) break;
+ if (trim && i == 0 && num == 0) break;
}
}
- while (s[j] == '0') j++;
- RSTRING(ss)->len -= RBIGNUM(x)->sign?j:j-1;
- memmove(RBIGNUM(x)->sign?s:s+1, s+j, RSTRING(ss)->len);
+ if (trim) {while (s[j] == '0') j++;}
+ i = RSTRING(ss)->len - j;
+ if (RBIGNUM(x)->sign) {
+ memmove(s, s+j, i);
+ RSTRING(ss)->len = i-1;
+ }
+ else {
+ memmove(s+1, s+j, i);
+ RSTRING(ss)->len = i;
+ }
s[RSTRING(ss)->len] = '\0';
return ss;
}
+VALUE
+rb_big2str(VALUE x, int base)
+{
+ return rb_big2str0(x, base, Qtrue);
+}
+
/*
* call-seq:
* big.to_s(base=10) => string
@@ -1077,7 +1086,6 @@ rb_big_neg(x)
if (!RBIGNUM(x)->sign) get2comp(z);
ds = BDIGITS(z);
i = RBIGNUM(x)->len;
- if (!i) return INT2FIX(~0);
while (i--) ds[i] = ~ds[i];
RBIGNUM(z)->sign = !RBIGNUM(z)->sign;
if (RBIGNUM(x)->sign) get2comp(z);
@@ -1229,15 +1237,8 @@ rb_big_minus(x, y)
}
}
-/*
- * call-seq:
- * big * other => Numeric
- *
- * Multiplies big and other, returning the result.
- */
-
VALUE
-rb_big_mul(x, y)
+rb_big_mul0(x, y)
VALUE x, y;
{
long i, j;
@@ -1280,7 +1281,21 @@ rb_big_mul(x, y)
}
}
- return bignorm(z);
+ return z;
+}
+
+/*
+ * call-seq:
+ * big * other => Numeric
+ *
+ * Multiplies big and other, returning the result.
+ */
+
+VALUE
+rb_big_mul(x, y)
+ VALUE x, y;
+{
+ return bignorm(rb_big_mul0(x, y));
}
static void
@@ -1526,20 +1541,6 @@ rb_big_remainder(x, y)
return bignorm(z);
}
-static VALUE big_lshift _((VALUE, unsigned long));
-static VALUE big_rshift _((VALUE, unsigned long));
-
-static VALUE big_shift(x, n)
- VALUE x;
- int n;
-{
- if (n < 0)
- return big_lshift(x, (unsigned int)n);
- else if (n > 0)
- return big_rshift(x, (unsigned int)n);
- return x;
-}
-
/*
* call-seq:
* big.divmod(numeric) => array
@@ -1642,10 +1643,8 @@ rb_big_pow(x, y)
yy = FIX2LONG(y);
if (yy > 0) {
VALUE z = x;
- const long BIGLEN_LIMIT = 1024*1024 / SIZEOF_BDIGITS;
- if ((RBIGNUM(x)->len > BIGLEN_LIMIT) ||
- (RBIGNUM(x)->len > BIGLEN_LIMIT / yy)) {
+ if (RBIGNUM(x)->len * SIZEOF_BDIGITS * yy > 1024*1024) {
rb_warn("in a**b, b may be too big");
d = (double)yy;
break;
@@ -1655,9 +1654,11 @@ rb_big_pow(x, y)
if (yy == 0) break;
while (yy % 2 == 0) {
yy /= 2;
- x = rb_big_mul(x, x);
+ x = rb_big_mul0(x, x);
+ bigtrunc(x);
}
- z = rb_big_mul(z, x);
+ z = rb_big_mul0(z, x);
+ bigtrunc(z);
}
return bignorm(z);
}
@@ -1843,15 +1844,7 @@ rb_big_xor(xx, yy)
return bignorm(z);
}
-static VALUE
-check_shiftdown(VALUE y, VALUE x)
-{
- if (!RBIGNUM(x)->len) return INT2FIX(0);
- if (RBIGNUM(y)->len > SIZEOF_LONG / SIZEOF_BDIGITS) {
- return RBIGNUM(x)->sign ? INT2FIX(0) : INT2FIX(-1);
- }
- return Qnil;
-}
+static VALUE rb_big_rshift _((VALUE,VALUE));
/*
* call-seq:
@@ -1864,46 +1857,15 @@ VALUE
rb_big_lshift(x, y)
VALUE x, y;
{
- long shift;
- int neg = 0;
-
- for (;;) {
- if (FIXNUM_P(y)) {
- shift = FIX2LONG(y);
- if (shift < 0) {
- neg = 1;
- shift = -shift;
- }
- break;
- }
- else if (TYPE(y) == T_BIGNUM) {
- if (!RBIGNUM(y)->sign) {
- VALUE t = check_shiftdown(y, x);
- if (!NIL_P(t)) return t;
- neg = 1;
- }
- shift = big2ulong(y, "long", Qtrue);
- break;
- }
- y = rb_to_int(y);
- }
-
- if (neg) return big_rshift(x, shift);
- return big_lshift(x, shift);
-}
-
-static VALUE
-big_lshift(x, shift)
- VALUE x;
- unsigned long shift;
-{
BDIGIT *xds, *zds;
- long s1 = shift/BITSPERDIG;
+ int shift = NUM2INT(y);
+ int s1 = shift/BITSPERDIG;
int s2 = shift%BITSPERDIG;
VALUE z;
BDIGIT_DBL num = 0;
long len, i;
+ if (shift < 0) return rb_big_rshift(x, INT2FIX(-shift));
len = RBIGNUM(x)->len;
z = bignew(len+s1+1, RBIGNUM(x)->sign);
zds = BDIGITS(z);
@@ -1927,53 +1889,21 @@ big_lshift(x, shift)
* Shifts big right _numeric_ positions (left if _numeric_ is negative).
*/
-VALUE
+static VALUE
rb_big_rshift(x, y)
VALUE x, y;
{
- long shift;
- int neg = 0;
-
- for (;;) {
- if (FIXNUM_P(y)) {
- shift = FIX2LONG(y);
- if (shift < 0) {
- neg = 1;
- shift = -shift;
- }
- break;
- }
- else if (TYPE(y) == T_BIGNUM) {
- if (RBIGNUM(y)->sign) {
- VALUE t = check_shiftdown(y, x);
- if (!NIL_P(t)) return t;
- }
- else {
- neg = 1;
- }
- shift = big2ulong(y, "long", Qtrue);
- break;
- }
- y = rb_to_int(y);
- }
-
- if (neg) return big_lshift(x, shift);
- return big_rshift(x, shift);
-}
-
-static VALUE
-big_rshift(x, shift)
- VALUE x;
- unsigned long shift;
-{
BDIGIT *xds, *zds;
+ int shift = NUM2INT(y);
long s1 = shift/BITSPERDIG;
- int s2 = shift%BITSPERDIG;
+ long s2 = shift%BITSPERDIG;
VALUE z;
BDIGIT_DBL num = 0;
long i, j;
volatile VALUE save_x;
+ if (shift < 0) return rb_big_lshift(x, INT2FIX(-shift));
+
if (s1 > RBIGNUM(x)->len) {
if (RBIGNUM(x)->sign)
return INT2FIX(0);
@@ -1986,6 +1916,10 @@ big_rshift(x, shift)
}
xds = BDIGITS(x);
i = RBIGNUM(x)->len; j = i - s1;
+ if (j == 0) {
+ if (RBIGNUM(x)->sign) return INT2FIX(0);
+ else return INT2FIX(-1);
+ }
z = bignew(j, RBIGNUM(x)->sign);
if (!RBIGNUM(x)->sign) {
num = ((BDIGIT_DBL)~0) << BITSPERDIG;
diff --git a/bin/irb b/bin/irb
index 13474a932b..f277bc4b69 100644
--- a/bin/irb
+++ b/bin/irb
@@ -2,8 +2,8 @@
#
# irb.rb - intaractive ruby
# $Release Version: 0.9.5 $
-# $Revision: 1.2.2.1 $
-# $Date: 2005/04/19 19:24:56 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
diff --git a/bin/rdoc b/bin/rdoc
index d08ce838f6..fe619137fd 100644
--- a/bin/rdoc
+++ b/bin/rdoc
@@ -6,7 +6,7 @@
# Copyright (c) 2003 Dave Thomas
# Released under the same terms as Ruby
#
-# $Revision: 1.1 $
+# $Revision$
## Transitional Hack ####
#
diff --git a/class.c b/class.c
index ca2516d5a1..80dc9e4b2d 100644
--- a/class.c
+++ b/class.c
@@ -2,8 +2,8 @@
class.c -
- $Author: nobu $
- $Date: 2005/09/28 14:42:46 $
+ $Author$
+ $Date$
created at: Tue Aug 10 15:05:44 JST 1993
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -48,26 +48,13 @@ rb_class_new(super)
return rb_class_boot(super);
}
-struct clone_method_data {
- st_table *tbl;
- VALUE klass;
-};
-
static int
-clone_method(mid, body, data)
+clone_method(mid, body, tbl)
ID mid;
NODE *body;
- struct clone_method_data *data;
+ st_table *tbl;
{
- NODE *fbody = body->nd_body;
-
- if (fbody && nd_type(fbody) == NODE_SCOPE) {
- VALUE cref = data->klass ?
- (VALUE)NEW_NODE(NODE_CREF,data->klass,0,fbody->nd_rval) :
- fbody->nd_rval;
- fbody = NEW_NODE(NODE_SCOPE, fbody->nd_tbl, cref, fbody->nd_next);
- }
- st_insert(data->tbl, mid, (st_data_t)NEW_METHOD(fbody, body->nd_noex));
+ st_insert(tbl, mid, (st_data_t)NEW_METHOD(body->nd_body, body->nd_noex));
return ST_CONTINUE;
}
@@ -78,8 +65,7 @@ rb_mod_init_copy(clone, orig)
{
rb_obj_init_copy(clone, orig);
if (!FL_TEST(CLASS_OF(clone), FL_SINGLETON)) {
- RBASIC(clone)->klass = RBASIC(orig)->klass;
- RBASIC(clone)->klass = rb_singleton_class_clone(clone);
+ RBASIC(clone)->klass = rb_singleton_class_clone(orig);
}
RCLASS(clone)->super = RCLASS(orig)->super;
if (RCLASS(orig)->iv_tbl) {
@@ -92,12 +78,9 @@ rb_mod_init_copy(clone, orig)
st_delete(RCLASS(clone)->iv_tbl, (st_data_t*)&id, 0);
}
if (RCLASS(orig)->m_tbl) {
- struct clone_method_data data;
-
- data.tbl = RCLASS(clone)->m_tbl = st_init_numtable();
- data.klass = (VALUE)clone;
-
- st_foreach(RCLASS(orig)->m_tbl, clone_method, (st_data_t)&data);
+ RCLASS(clone)->m_tbl = st_init_numtable();
+ st_foreach(RCLASS(orig)->m_tbl, clone_method,
+ (st_data_t)RCLASS(clone)->m_tbl);
}
return clone;
@@ -143,22 +126,9 @@ rb_singleton_class_clone(obj)
if (RCLASS(klass)->iv_tbl) {
clone->iv_tbl = st_copy(RCLASS(klass)->iv_tbl);
}
- {
- struct clone_method_data data;
-
- data.tbl = clone->m_tbl = st_init_numtable();
- switch (TYPE(obj)) {
- case T_CLASS:
- case T_MODULE:
- data.klass = obj;
- break;
- default:
- data.klass = 0;
- break;
- }
-
- st_foreach(RCLASS(klass)->m_tbl, clone_method, (st_data_t)&data);
- }
+ clone->m_tbl = st_init_numtable();
+ 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;
@@ -409,9 +379,6 @@ rb_include_module(klass, module)
rb_secure(4);
}
- if (NIL_P(module)) return;
- if (klass == module) return;
-
if (TYPE(module) != T_MODULE) {
Check_Type(module, T_MODULE);
}
diff --git a/common.mk b/common.mk
index 3584b83e35..f751fecfb5 100644
--- a/common.mk
+++ b/common.mk
@@ -1,6 +1,6 @@
bin: $(PROGRAM) $(WPROGRAM)
-lib: $(LIBRUBY);
-dll: $(LIBRUBY_SO);
+lib: $(LIBRUBY)
+dll: $(LIBRUBY_SO)
RUBYOPT =
@@ -8,6 +8,8 @@ STATIC_RUBY = static-ruby
EXTCONF = extconf.rb
RBCONFIG = ./.rbconfig.time
+LIBRUBY_EXTS = ./.libruby-with-ext.time
+RDOCOUT = $(EXTOUT)/rdoc
DMYEXT = dmyext.$(OBJEXT)
MAINOBJ = main.$(OBJEXT)
@@ -53,10 +55,18 @@ OBJS = array.$(OBJEXT) \
$(MISSING)
SCRIPT_ARGS = --dest-dir="$(DESTDIR)" \
+ --extout="$(EXTOUT)" \
--make="$(MAKE)" \
--mflags="$(MFLAGS)" \
--make-flags="$(MAKEFLAGS)"
-EXTMK_ARGS = $(SCRIPT_ARGS) --extout="$(EXTOUT)" --extension $(EXTS) --extstatic $(EXTSTATIC) --
+EXTMK_ARGS = $(SCRIPT_ARGS) --extension $(EXTS) --extstatic $(EXTSTATIC) --
+INSTRUBY_ARGS = $(SCRIPT_ARGS) --installed-list $(INSTALLED_LIST)
+
+PRE_LIBRUBY_UPDATE = $(MINIRUBY) -e 'ARGV[1] or File.unlink(ARGV[0]) rescue nil' -- \
+ $(LIBRUBY_EXTS) $(LIBRUBY_SO_UPDATE)
+
+TESTSDIR = $(srcdir)/test
+TESTWORKDIR = testwork
all: $(MKFILES) $(PREP) $(RBCONFIG) $(LIBRUBY)
@$(MINIRUBY) $(srcdir)/ext/extmk.rb $(EXTMK_ARGS)
@@ -68,7 +78,10 @@ $(PROGRAM): $(LIBRUBY) $(MAINOBJ) $(OBJS) $(EXTOBJS) $(SETUP) $(PREP)
$(LIBRUBY_A): $(OBJS) $(DMYEXT) $(ARCHFILE)
-$(LIBRUBY_SO): $(OBJS) $(DLDOBJS) $(LIBRUBY_A) $(PREP)
+$(LIBRUBY_SO): $(OBJS) $(DLDOBJS) $(LIBRUBY_A) $(PREP) $(LIBRUBY_SO_UPDATE)
+
+$(LIBRUBY_EXTS):
+ @exit > $@
$(STATIC_RUBY)$(EXEEXT): $(MAINOBJ) $(DLDOBJS) $(EXTOBJS) $(LIBRUBY_A)
@$(RM) $@
@@ -80,51 +93,177 @@ ruby.imp: $(OBJS)
install: install-nodoc $(RDOCTARGET)
install-all: install-nodoc install-doc
-install-nodoc: install-local install-ext
-install-local: pre-install-local do-install-local post-install-local
-install-ext: pre-install-ext do-install-ext post-install-ext
+install-nodoc: pre-install-nodoc do-install-nodoc post-install-nodoc
+pre-install-nodoc:: pre-install-local pre-install-ext
+do-install-nodoc:
+ $(MINIRUBY) $(srcdir)/instruby.rb $(INSTRUBY_ARGS) --mantype="$(MANTYPE)"
+post-install-nodoc:: post-install-local post-install-ext
-do-install-local: $(RBCONFIG)
- $(MINIRUBY) $(srcdir)/instruby.rb $(SCRIPT_ARGS) --mantype="$(MANTYPE)"
-do-install-ext: $(RBCONFIG)
- $(MINIRUBY) $(srcdir)/ext/extmk.rb $(EXTMK_ARGS) install
+install-local: pre-install-local do-install-local post-install-local
+pre-install-local:: pre-install-bin pre-install-lib pre-install-man
+do-install-local:
+ $(MINIRUBY) $(srcdir)/instruby.rb $(INSTRUBY_ARGS) --install=local --mantype="$(MANTYPE)"
+post-install-local:: post-install-bin post-install-lib post-install-man
-install-bin: $(RBCONFIG)
- $(MINIRUBY) $(srcdir)/instruby.rb $(SCRIPT_ARGS) --install=bin
-install-lib: $(RBCONFIG)
- $(MINIRUBY) $(srcdir)/instruby.rb $(SCRIPT_ARGS) --install=lib
-install-man: $(RBCONFIG)
- $(MINIRUBY) $(srcdir)/instruby.rb $(SCRIPT_ARGS) --install=man --mantype="$(MANTYPE)"
+install-ext: pre-install-ext do-install-ext post-install-ext
+pre-install-ext:: pre-install-ext-arch pre-install-ext-comm
+do-install-ext:
+ $(MINIRUBY) $(srcdir)/instruby.rb $(INSTRUBY_ARGS) --install=ext
+post-install-ext:: post-install-ext-arch post-install-ext-comm
+
+install-arch: pre-install-arch do-install-arch post-install-arch
+pre-install-arch:: pre-install-bin pre-install-ext-arch
+do-install-arch:
+ $(MINIRUBY) $(srcdir)/instruby.rb $(INSTRUBY_ARGS) --install=bin --install=ext-arch
+post-install-arch:: post-install-bin post-install-ext-arch
+
+install-comm: pre-install-comm do-install-comm post-install-comm
+pre-install-comm:: pre-install-lib pre-install-ext-comm pre-install-man
+do-install-comm:
+ $(MINIRUBY) $(srcdir)/instruby.rb $(INSTRUBY_ARGS) --install=lib --install=ext-comm --install=man
+post-install-comm:: post-install-lib post-install-ext-comm post-install-man
+
+install-bin: pre-install-bin do-install-bin post-install-bin
+pre-install-bin:: install-prereq
+do-install-bin:
+ $(MINIRUBY) $(srcdir)/instruby.rb $(INSTRUBY_ARGS) --install=bin
+post-install-bin::
+ @$(NULLCMD)
+
+install-lib: pre-install-lib do-install-lib post-install-lib
+pre-install-lib:: install-prereq
+do-install-lib:
+ $(MINIRUBY) $(srcdir)/instruby.rb $(INSTRUBY_ARGS) --install=lib
+post-install-lib::
+ @$(NULLCMD)
+
+install-ext-comm: pre-install-ext-comm do-install-ext-comm post-install-ext-comm
+pre-install-ext-comm:: install-prereq
+do-install-ext-comm:
+ $(MINIRUBY) $(srcdir)/instruby.rb $(INSTRUBY_ARGS) --install=ext-comm
+post-install-ext-comm::
+ @$(NULLCMD)
+
+install-ext-arch: pre-install-ext-arch do-install-ext-arch post-install-ext-arch
+pre-install-ext-arch:: install-prereq
+do-install-ext-arch:
+ $(MINIRUBY) $(srcdir)/instruby.rb $(INSTRUBY_ARGS) --install=ext-arch
+post-install-ext-arch::
+ @$(NULLCMD)
+
+install-man: pre-install-man do-install-man post-install-man
+pre-install-man:: install-prereq
+do-install-man:
+ $(MINIRUBY) $(srcdir)/instruby.rb $(INSTRUBY_ARGS) --install=man --mantype="$(MANTYPE)"
+post-install-man::
+ @$(NULLCMD)
+
+what-where: no-install
+no-install: no-install-nodoc no-install-doc
+what-where-all: no-install-all
+no-install-all: no-install-nodoc
+
+what-where-nodoc: no-install-nodoc
+no-install-nodoc: pre-no-install-nodoc dont-install-nodoc post-no-install-nodoc
+pre-no-install-nodoc:: pre-no-install-local pre-no-install-ext
+dont-install-nodoc:
+ $(MINIRUBY) $(srcdir)/instruby.rb -n $(INSTRUBY_ARGS) --mantype="$(MANTYPE)"
+post-no-install-nodoc:: post-no-install-local post-no-install-ext
-what-where-all no-install-all: no-install no-install-doc
-what-where no-install: no-install-local no-install-ext
what-where-local: no-install-local
-no-install-local: $(RBCONFIG)
- $(MINIRUBY) $(srcdir)/instruby.rb -n $(SCRIPT_ARGS) --mantype="$(MANTYPE)"
-what-where-ext: no-install-ext
-no-install-ext: $(RBCONFIG)
- $(MINIRUBY) $(srcdir)/ext/extmk.rb -n $(EXTMK_ARGS) install
+no-install-local: pre-no-install-local dont-install-local post-no-install-local
+pre-no-install-local:: pre-no-install-bin pre-no-install-lib pre-no-install-man
+dont-install-local:
+ $(MINIRUBY) $(srcdir)/instruby.rb -n $(INSTRUBY_ARGS) --install=local --mantype="$(MANTYPE)"
+post-no-install-local:: post-no-install-bin post-no-install-lib post-no-install-man
-install-doc: pre-install-doc do-install-doc post-install-doc
+what-where-ext: no-install-ext
+no-install-ext: pre-no-install-ext dont-install-ext post-no-install-ext
+pre-no-install-ext:: pre-no-install-ext-arch pre-no-install-ext-comm
+dont-install-ext:
+ $(MINIRUBY) $(srcdir)/instruby.rb -n $(INSTRUBY_ARGS) --install=ext
+post-no-install-ext:: post-no-install-ext-arch post-no-install-ext-comm
+
+what-where-arch: no-install-arch
+no-install-arch: pre-no-install-arch dont-install-arch post-no-install-arch
+pre-no-install-arch:: pre-no-install-bin pre-no-install-ext-arch
+dont-install-arch:
+ $(MINIRUBY) $(srcdir)/instruby.rb -n $(INSTRUBY_ARGS) --install=bin --install=ext-arch
+post-no-install-arch:: post-no-install-lib post-no-install-man post-no-install-ext-arch
+
+what-where-comm: no-install-comm
+no-install-comm: pre-no-install-comm dont-install-comm post-no-install-comm
+pre-no-install-comm:: pre-no-install-lib pre-no-install-ext-comm pre-no-install-man
+dont-install-comm:
+ $(MINIRUBY) $(srcdir)/instruby.rb -n $(INSTRUBY_ARGS) --install=lib --install=ext-comm --install=man
+post-no-install-comm:: post-no-install-lib post-no-install-ext-comm post-no-install-man
+
+what-where-bin: no-install-bin
+no-install-bin: pre-no-install-bin dont-install-bin post-no-install-bin
+pre-no-install-bin:: install-prereq
+dont-install-bin:
+ $(MINIRUBY) $(srcdir)/instruby.rb -n $(INSTRUBY_ARGS) --install=bin
+post-no-install-bin::
+ @$(NULLCMD)
+
+what-where-lib: no-install-lib
+no-install-lib: pre-no-install-lib dont-install-lib post-no-install-lib
+pre-no-install-lib:: install-prereq
+dont-install-lib:
+ $(MINIRUBY) $(srcdir)/instruby.rb -n $(INSTRUBY_ARGS) --install=lib
+post-no-install-lib::
+ @$(NULLCMD)
+
+what-where-ext-comm: no-install-ext-comm
+no-install-ext-comm: pre-no-install-ext-comm dont-install-ext-comm post-no-install-ext-comm
+pre-no-install-ext-comm:: install-prereq
+dont-install-ext-comm:
+ $(MINIRUBY) $(srcdir)/instruby.rb -n $(INSTRUBY_ARGS) --install=ext-comm
+post-no-install-ext-comm::
+ @$(NULLCMD)
+
+what-where-ext-arch: no-install-ext-arch
+no-install-ext-arch: pre-no-install-ext-arch dont-install-ext-arch post-no-install-ext-arch
+pre-no-install-ext-arch:: install-prereq
+dont-install-ext-arch:
+ $(MINIRUBY) $(srcdir)/instruby.rb -n $(INSTRUBY_ARGS) --install=ext-arch
+post-no-install-ext-arch::
+ @$(NULLCMD)
+
+what-where-man: no-install-man
+no-install-man: pre-no-install-man dont-install-man post-no-install-man
+pre-no-install-man:: install-prereq
+dont-install-man:
+ $(MINIRUBY) $(srcdir)/instruby.rb -n $(INSTRUBY_ARGS) --install=man --mantype="$(MANTYPE)"
+post-no-install-man::
+ @$(NULLCMD)
+
+install-doc: rdoc pre-install-doc do-install-doc post-install-doc
+pre-install-doc:: install-prereq
do-install-doc: $(PROGRAM)
+ $(MINIRUBY) $(srcdir)/instruby.rb $(INSTRUBY_ARGS) --install=rdoc --rdoc-output="$(RDOCOUT)"
+post-install-doc::
+ @$(NULLCMD)
+
+rdoc: $(PROGRAM) PHONY
@echo Generating RDoc documentation
- $(RUNRUBY) "$(srcdir)/bin/rdoc" --all --ri --op "$(RIDATADIR)" "$(srcdir)"
+ $(RUNRUBY) "$(srcdir)/bin/rdoc" --all --ri --op "$(RDOCOUT)" "$(srcdir)"
-pre-install: pre-install-local pre-install-ext
-pre-install-local:: PHONY
- $(PREINSTALL)
-pre-install-ext:: PHONY
-pre-install-doc:: PHONY
+what-where-doc: no-install-doc
+no-install-doc: pre-no-install-doc dont-install-doc post-no-install-doc
+pre-no-install-doc:: install-prereq
+dont-install-doc::
+ $(MINIRUBY) $(srcdir)/instruby.rb -n $(INSTRUBY_ARGS) --install=rdoc --rdoc-output="$(RDOCOUT)"
+post-no-install-doc::
+ @$(NULLCMD)
-post-install: post-install-local post-install-ext
-post-install-local:: PHONY
-post-install-ext:: PHONY
-post-install-doc:: PHONY
+install-prereq:
+ @exit > $(INSTALLED_LIST)
clean: clean-ext clean-local
clean-local::
@$(RM) $(OBJS) $(MAINOBJ) $(WINMAINOBJ) $(LIBRUBY_A) $(LIBRUBY_SO) $(LIBRUBY) $(LIBRUBY_ALIASES)
- @$(RM) $(PROGRAM) $(WPROGRAM) miniruby$(EXEEXT) dmyext.$(OBJEXT) $(ARCHFILE)
+ @$(RM) $(PROGRAM) $(WPROGRAM) miniruby$(EXEEXT) dmyext.$(OBJEXT) $(ARCHFILE) .*.time
clean-ext:
@-$(MINIRUBY) $(srcdir)/ext/extmk.rb $(EXTMK_ARGS) clean
@@ -145,7 +284,7 @@ test: miniruby$(EXEEXT) $(RBCONFIG) $(PROGRAM) PHONY
@$(MINIRUBY) $(srcdir)/rubytest.rb
test-all:
- $(RUNRUBY) -C "$(srcdir)/test" runner.rb --runner=$(TESTUI) $(TESTS)
+ $(RUNRUBY) "$(srcdir)/test/runner.rb" --basedir="$(TESTSDIR)" --runner=$(TESTUI) $(TESTS)
extconf:
$(MINIRUBY) -I$(srcdir)/lib -run -e mkdir -- -p "$(EXTCONFDIR)"
@@ -189,6 +328,8 @@ nt.$(OBJEXT): {$(VPATH)}nt.c
x68.$(OBJEXT): {$(VPATH)}x68.c
os2.$(OBJEXT): {$(VPATH)}os2.c
dl_os2.$(OBJEXT): {$(VPATH)}dl_os2.c
+ia64.$(OBJEXT): {$(VPATH)}ia64.s
+ $(CC) $(CFLAGS) -c $<
# when I use -I., there is confliction at "OpenFile"
# so, set . into environment varible "include"
diff --git a/compar.c b/compar.c
index 3cd3216b77..1488b2c65d 100644
--- a/compar.c
+++ b/compar.c
@@ -2,8 +2,8 @@
compar.c -
- $Author: dave $
- $Date: 2003/12/19 00:01:18 $
+ $Author$
+ $Date$
created at: Thu Aug 26 14:39:48 JST 1993
Copyright (C) 1993-2003 Yukihiro Matsumoto
diff --git a/configure.in b/configure.in
index e31a6fec49..6ced76363f 100644
--- a/configure.in
+++ b/configure.in
@@ -149,6 +149,11 @@ if test x"${build}" != x"${host}"; then
fi
AC_PROG_CC
AC_PROG_GCC_TRADITIONAL
+if test "$GCC" = yes; then
+ linker_flag=-Wl,
+else
+ linker_flag=
+fi
RUBY_PROG_GNU_LD
RUBY_CPPOUTFILE
@@ -286,16 +291,42 @@ if test "$rb_cv_stdarg" = yes; then
AC_DEFINE(HAVE_STDARG_PROTOTYPES)
fi
-AC_CACHE_CHECK([for noreturn], rb_cv_noreturn,
-[rb_cv_noreturn=x
-for mac in "x __attribute__ ((noreturn))" "__declspec(noreturn) x" x; do
+AC_DEFUN([RUBY_FUNC_ATTRIBUTE], [dnl
+m4_ifval([$2], dnl
+ [AS_VAR_PUSHDEF([attrib],[$2])], dnl
+ [AS_VAR_PUSHDEF([attrib],[FUNC_]AS_TR_CPP($1))] dnl
+)dnl
+m4_ifval([$3], dnl
+ [AS_VAR_PUSHDEF([rbcv],[$3])], dnl
+ [AS_VAR_PUSHDEF([rbcv],[rb_cv_func_][$1])]dnl
+)dnl
+AC_CACHE_CHECK(for [$1] function attribute, rbcv,
+[rbcv=x
+if test "${ac_c_werror_flag+set}"; then
+ rb_c_werror_flag="$ac_c_werror_flag"
+else
+ unset rb_c_werror_flag
+fi
+ac_c_werror_flag=yes
+for mac in "__attribute__ (($1)) x" "x __attribute__ (($1))" "__declspec($1) 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)
+ [#define ]attrib[(x) $mac
+ ]attrib[(void conftest_attribute_check(void));], [],
+ [rbcv="$mac"; break])
+done
+if test "${rb_c_werror_flag+set}"; then
+ ac_c_werror_flag="$rb_c_werror_flag"
+else
+ unset ac_c_werror_flag
+fi
+])
+AC_DEFINE_UNQUOTED(attrib[(x)], $rbcv)
+AS_VAR_POPDEF([attrib])
+AS_VAR_POPDEF([rbcv])
+])
+
+RUBY_FUNC_ATTRIBUTE(noreturn, NORETURN)
+RUBY_FUNC_ATTRIBUTE(noinline, NOINLINE)
AC_CACHE_CHECK([for RUBY_EXTERN], rb_cv_ruby_extern,
[rb_cv_ruby_extern=no
@@ -324,6 +355,11 @@ AC_ARG_ENABLE(pthread,
[ --enable-pthread use pthread library.],
[enable_pthread=$enableval], [enable_pthread=no])
+AC_ARG_ENABLE(fastthread,
+ [ --disable-fastthread do not use the fastthread mutex], [
+ : handled by ext/thread/extconf.rb
+ ])
+
dnl Checks for libraries.
case "$target_os" in
nextstep*) ;;
@@ -336,13 +372,16 @@ human*) ac_cv_func_getpgrp_void=yes
ac_cv_func_setitimer=no
;;
beos*) ac_cv_func_link=no;;
-cygwin*) ;;
+cygwin*) rb_cv_have_daylight=no
+ ac_cv_var_tzname=no
+ ac_cv_func__setjmp=no
+ ac_cv_func_setitimer=no
+ ;;
mingw*) if test "$with_winsock2" = yes; then
LIBS="-lws2_32 $LIBS"
else
LIBS="-lwsock32 $LIBS"
fi
- LIBS="-lshell32 $LIBS"
ac_cv_header_a_out_h=no
ac_cv_header_pwd_h=no
ac_cv_header_utime_h=no
@@ -370,6 +409,7 @@ mingw*) if test "$with_winsock2" = yes; then
rb_cv_binary_elf=no
rb_cv_negative_time_t=no
enable_pthread=no
+ ac_cv_func_fcntl=yes
;;
os2-emx*) LIBS="-lm $LIBS"
ac_cv_lib_dir_opendir=no;;
@@ -377,6 +417,7 @@ msdosdjgpp*) LIBS="-lm $LIBS"
ac_cv_func_getpgrp_void=yes
ac_cv_func_setitimer=no
ac_cv_sizeof_rlim_t=4
+ ac_cv_func_setrlimit=no
;;
bsdi*) LIBS="-lm $LIBS"
ac_cv_sizeof_rlim_t=8;;
@@ -419,10 +460,10 @@ bow) ac_cv_func_setitimer=no
;;
superux*) ac_cv_func_setitimer=no
;;
-solaris*2.1*) if test -z "$GCC"; then
- ac_cv_func_isinf=yes
+solaris*2.10) if test -z "$GCC"; then
+ ac_cv_func_isinf=yes
fi
- LIBS="-lm $LIBS"
+ LIBS="-lm $LIBS"
;;
*) LIBS="-lm $LIBS";;
esac
@@ -473,7 +514,17 @@ AC_STRUCT_ST_RDEV
dnl Checks for library functions.
AC_TYPE_GETGROUPS
AC_TYPE_SIGNAL
-AC_FUNC_ALLOCA
+case "${target_cpu}-${target_os}" in
+powerpc-darwin*)
+ AC_LIBSOURCES(alloca.c)
+ AC_SUBST([ALLOCA], [\${LIBOBJDIR}alloca.${ac_objext}])
+ AC_DEFINE(C_ALLOCA)
+ AC_DEFINE_UNQUOTED(alloca, alloca)
+ ;;
+*)
+ AC_FUNC_ALLOCA
+ ;;
+esac
AC_FUNC_MEMCMP
AC_FUNC_FSEEKO
AC_CHECK_FUNCS(ftello)
@@ -481,15 +532,14 @@ AC_REPLACE_FUNCS(dup2 memmove strcasecmp strncasecmp strerror strftime\
strchr strstr strtoul crypt flock vsnprintf\
isnan finite isinf hypot acosh erf)
AC_CHECK_FUNCS(fmod killpg wait4 waitpid syscall chroot fsync getcwd eaccess\
- truncate ftruncate chsize times utimes fcntl lockf lstat symlink link\
+ truncate chsize times utimes fcntl lockf lstat symlink link\
readlink setitimer setruid seteuid setreuid setresuid\
setproctitle setrgid setegid setregid setresgid issetugid pause\
lchown lchmod getpgrp setpgrp getpgid setpgid initgroups\
getgroups setgroups getpriority getrlimit setrlimit sysconf\
- group_member dlopen sigprocmask\
- sigaction _setjmp setsid telldir seekdir fchmod\
- mktime timegm gettimeofday\
- cosh sinh tanh round setuid setgid setenv unsetenv)
+ dlopen sigprocmask\
+ sigaction _setjmp setsid telldir seekdir fchmod mktime timegm\
+ cosh sinh tanh setuid setgid setenv unsetenv)
AC_ARG_ENABLE(setreuid,
[ --enable-setreuid use setreuid()/setregid() according to need even if obsolete.],
[use_setreuid=$enableval])
@@ -515,42 +565,6 @@ 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_DEFUN([RUBY_CHECK_VARTYPE], [dnl
-AC_CACHE_CHECK([for external $1], rb_cv_var_$1,
- [rb_cv_var_$1=no
- AC_TRY_COMPILE([#define _XOPEN_SOURCE 1
- $2
- const volatile void *volatile t;],
- [t = &(&$1)[0];],
- [for t in $3; do
- AC_TRY_COMPILE([#define _XOPEN_SOURCE 1
- $2
- extern $t $1;
- const volatile void *volatile t;],
- [t = &(&$1)[0];],
- [rb_cv_var_$1=$t; break])
- done])])
-if test "[$rb_cv_var_]$1" != no; then
- AC_DEFINE([HAVE_VAR_]m4_toupper($1))
- AC_DEFINE_UNQUOTED([TYPEOF_VAR_]m4_toupper($1), $rb_cv_var_$1)
-fi])
-RUBY_CHECK_VARTYPE(timezone, [#include <time.h>], [long int])
-RUBY_CHECK_VARTYPE(altzone, [#include <time.h>], [long int])
-if test "$rb_cv_var_timezone" = no; then
- AC_CHECK_FUNCS(timezone)
- if test "$ ac_cv_func_timezone" = yes; then
- AC_CACHE_CHECK([whether timezone requires zero arguments], rb_cv_func_timezone_void,
- [AC_TRY_COMPILE([#include <time.h>],
- [(void)timezone(0, 0);],
- [rb_cv_func_timezone_void=no],
- [rb_cv_func_timezone_void=yes])]
- )
- if test $rb_cv_func_timezone_void = yes; then
- AC_DEFINE(TIMEZONE_VOID)
- fi
- fi
-fi
-
AC_CACHE_CHECK(for negative time_t for gmtime(3), rb_cv_negative_time_t,
[AC_TRY_RUN([
#include <time.h>
@@ -592,7 +606,6 @@ fi
if test "$ac_cv_func_sigprocmask" = yes && test "$ac_cv_func_sigaction" = yes; then
AC_DEFINE(POSIX_SIGNAL)
else
- AC_CHECK_FUNCS(sigsetmask)
AC_CACHE_CHECK(for BSD signal semantics, rb_cv_bsd_signal,
[AC_TRY_RUN([
#include <stdio.h>
@@ -615,7 +628,7 @@ main()
],
rb_cv_bsd_signal=yes,
rb_cv_bsd_signal=no,
- rb_cv_bsd_signal=$ac_cv_func_sigsetmask)])
+ rb_cv_bsd_signal=no)])
if test "$rb_cv_bsd_signal" = yes; then
AC_DEFINE(BSD_SIGNAL)
fi
@@ -630,6 +643,21 @@ AC_C_CHAR_UNSIGNED
AC_C_INLINE
AC_C_VOLATILE
+if test x"$target_cpu" = xia64; then
+ AC_LIBOBJ([ia64])
+ AC_CACHE_CHECK(for __libc_ia64_register_backing_store_base,
+ rb_cv___libc_ia64_register_backing_store_base,
+ [rb_cv___libc_ia64_register_backing_store_base=no
+ AC_TRY_LINK(
+ [extern unsigned long __libc_ia64_register_backing_store_base;],
+ [unsigned long p = __libc_ia64_register_backing_store_base;
+ printf("%ld\n", p);],
+ [rb_cv___libc_ia64_register_backing_store_base=yes])])
+ if test $rb_cv___libc_ia64_register_backing_store_base = yes; then
+ AC_DEFINE(HAVE___LIBC_IA64_REGISTER_BACKING_STORE_BASE)
+ fi
+fi
+
AC_CACHE_CHECK(whether right shift preserve sign bit, rb_cv_rshift_sign,
[AC_TRY_RUN([
int
@@ -862,7 +890,7 @@ if test x"$enable_pthread" = xyes; then
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
+ if test x"$rb_with_pthread" = xyes; then
AC_CHECK_FUNCS(getcontext setcontext)
fi
fi
@@ -1029,14 +1057,13 @@ if test "$with_dln_a_out" != yes; then
: ${LIBPATHENV=DYLD_LIBRARY_PATH}
rb_cv_dlopen=yes ;;
aix*) if test "$GCC" = yes; then
- : ${LDSHARED='gcc -shared'}
- DLDFLAGS='-Wl,-G -eInit_$(TARGET)'
- LDFLAGS='-Wl,-brtl -Wl,-bE:ruby.imp'
- else
- : ${LDSHARED='/usr/ccs/bin/ld'}
- DLDFLAGS='-G -eInit_$(TARGET)'
- LDFLAGS="-brtl -bE:ruby.imp"
- fi
+ : ${LDSHARED='$(CC) -shared'}
+ else
+ : ${LDSHARED='/usr/ccs/bin/ld'}
+ fi
+ DLDFLAGS="${linker_flag}-G"' -eInit_$(TARGET)'
+ LDFLAGS="${LDFLAGS} ${linker_flag}-brtl"
+ XLDFLAGS="${linker_flag}-bE:ruby.imp"
: ${ARCHFILE="ruby.imp"}
TRY_LINK='$(CC) $(LDFLAGS) -oconftest $(INCFLAGS) -I$(hdrdir) $(CPPFLAGS)'
TRY_LINK="$TRY_LINK"' $(CFLAGS) $(src) $(LIBPATH) $(LOCAL_LIBS) $(LIBS)'
@@ -1065,7 +1092,7 @@ if test "$with_dln_a_out" != yes; then
rb_cv_dlopen=yes;;
cygwin*|mingw*) : ${LDSHARED="${CC} -shared -s"}
XLDFLAGS="$XLDFLAGS -Wl,--stack,0x02000000"
- DLDFLAGS="${DLDFLAGS} -Wl,--enable-auto-import,--export-all"
+ DLDFLAGS="${DLDFLAGS} -Wl,--enable-auto-image-base,--enable-auto-import,--export-all"
: ${LIBPATHENV=""}
rb_cv_dlopen=yes ;;
hiuxmpp) : ${LDSHARED='ld -r'} ;;
@@ -1082,11 +1109,7 @@ if test "$with_dln_a_out" != yes; then
[enable_rpath=$enableval], [enable_rpath="$rb_cv_binary_elf"])
if test "$enable_rpath" = yes; then
LIBPATHFLAG=" -L'%1\$-s'"
- if test "$GCC" = yes; then
- RPATHFLAG=" -Wl,-R'%1\$-s'"
- else
- RPATHFLAG=" -R'%1\$-s'"
- fi
+ RPATHFLAG=" ${linker_flag}-R'%1\$-s'"
fi
fi
AC_SUBST(LINK_SO)
@@ -1121,30 +1144,24 @@ if test "$dln_a_out_works" = yes; then
STATIC=-Bstatic
fi
DLEXT=so
- AC_DEFINE(DLEXT, ".so")
CCDLFLAGS=
else
case "$target_os" in
- hpux*) DLEXT=sl
- AC_DEFINE(DLEXT, ".sl");;
- nextstep*) DLEXT=bundle
- AC_DEFINE(DLEXT, ".bundle");;
- openstep*) DLEXT=bundle
- AC_DEFINE(DLEXT, ".bundle");;
- rhapsody*) DLEXT=bundle
- AC_DEFINE(DLEXT, ".bundle");;
- darwin*) DLEXT=bundle
- AC_DEFINE(DLEXT, ".bundle");;
- os2-emx*) DLEXT=dll
- AC_DEFINE(DLEXT, ".dll");;
- cygwin*|mingw*) DLEXT=so
- AC_DEFINE(DLEXT, ".so")
- DLEXT2=dll
- AC_DEFINE(DLEXT2, ".dll");;
- *) DLEXT=so
- AC_DEFINE(DLEXT, ".so");;
+ hpux*) DLEXT=sl;;
+ nextstep*|openstep*|rhapsody*|darwin*)
+ DLEXT=bundle;;
+ os2-emx*) DLEXT=dll;;
+ cygwin*|mingw*)
+ DLEXT=so DLEXT2=dll;;
+ *) DLEXT=so;;
esac
fi
+len=2 # .rb
+n=`expr "$DLEXT" : '.*'`; test "$n" -gt "$len" && len=$n
+n=`expr "$DLEXT2" : '.*'`; test "$n" -gt "$len" && len=$n
+AC_DEFINE_UNQUOTED(DLEXT_MAXLEN, `expr $len + 1`)
+test ".$DLEXT" = "." || AC_DEFINE_UNQUOTED(DLEXT, ".$DLEXT")
+test ".$DLEXT2" = "." || AC_DEFINE_UNQUOTED(DLEXT2, ".$DLEXT2")
AC_SUBST(STRIP)dnl
if test "$with_dln_a_out" = yes; then
@@ -1180,7 +1197,7 @@ case "$target_os" in
human*)
AC_CHECK_LIB(signal, _harderr)
AC_CHECK_LIB(hmem, hmemset)
- AC_CHECK_FUNCS(select)
+ AC_CHECK_FUNCS(select gettimeofday)
AC_CACHE_CHECK(whether PD libc _dtos18 fail to convert big number,
rb_cv_missing__dtos18,
[AC_TRY_RUN(
@@ -1342,14 +1359,8 @@ if test "$enable_shared" = 'yes'; then
LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).sl.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).sl'
;;
aix*)
- if test "$GCC" = yes; then
- LIBRUBY_LDSHARED='$(CC) -shared'
- LIBRUBY_DLDFLAGS='-Wl,-G -Wl,-bE:ruby.imp -Wl,-bnoentry'
- else
- LIBRUBY_LDSHARED='/usr/ccs/bin/ld'
- LIBRUBY_DLDFLAGS='-G -bE:ruby.imp -bnoentry'
- fi
- LIBRUBYARG_SHARED='-L${libdir} -lruby'
+ LIBRUBY_DLDFLAGS="${linker_flag}-G ${linker_flag}-bnoentry $XLDFLAGS"
+ LIBRUBYARG_SHARED='-L${libdir} -l${RUBY_SO_NAME}'
SOLIBS='-lm -lc'
;;
beos*)
@@ -1366,21 +1377,17 @@ if test "$enable_shared" = 'yes'; then
LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).$(MAJOR).$(MINOR).dylib lib$(RUBY_SO_NAME).dylib'
;;
interix*)
- LIBRUBYARG_SHARED='-L${libdir} -L. -l$(RUBY_SO_NAME)'
+ LIBRUBYARG_SHARED='-L. -L${libdir} -l$(RUBY_SO_NAME)'
;;
*)
;;
esac
fi
if test "$enable_rpath" = yes; then
- if test "$GCC" = yes; then
- LIBRUBYARG_SHARED='-Wl,-R -Wl,$(libdir) -L$(libdir) -L. '"$LIBRUBYARG_SHARED"
- else
- LIBRUBYARG_SHARED='-R $(libdir) -L$(libdir) -L. '"$LIBRUBYARG_SHARED"
- fi
+ LIBRUBYARG_SHARED="${linker_flag}-R ${linker_flag}\$(libdir) -L. -L\$(libdir) $LIBRUBYARG_SHARED"
fi
-XLDFLAGS="$XLDFLAGS -L."
+LDFLAGS="-L. $LDFLAGS"
AC_SUBST(ARCHFILE)
dnl build rdoc index if requested
@@ -1394,9 +1401,6 @@ fi
AC_SUBST(RDOCTARGET)
case "$target_os" in
- linux*)
- XCFLAGS="$XCFLAGS -D_GNU_SOURCE=1"
- ;;
netbsd*)
CFLAGS="$CFLAGS -pipe"
;;
@@ -1453,6 +1457,7 @@ case "$target_os" in
LIBRUBY_SO='cyg$(RUBY_SO_NAME)'${MAJOR}${MINOR}.dll
LIBRUBY='lib$(RUBY_SO_NAME).dll.a'
fi
+ AC_LIBOBJ([strftime])
;;
mingw*)
RUBY_SO_NAME=${rb_cv_msvcrt}-'$(RUBY_INSTALL_NAME)'${MAJOR}${MINOR}
@@ -1486,9 +1491,6 @@ case "$target_os" in
esac
MINIOBJS=dmydln.o
;;
- aix*)
- PREINSTALL='@$(RM) -r $(prefix)/lib/$(LIBRUBY_A) $(prefix)/lib/$(LIBRUBY_SO) $(prefix)/lib/ruby/$(MAJOR).$(MINOR)/$(arch)'
- ;;
*)
;;
esac
@@ -1521,7 +1523,6 @@ AC_SUBST(COMMON_MACROS)
AC_SUBST(COMMON_HEADERS)
AC_SUBST(EXPORT_PREFIX)
AC_SUBST(MINIOBJS)
-AC_SUBST(PREINSTALL)
MAKEFILES="Makefile `echo $FIRSTMAKEFILE | sed 's/:.*//'`"
MAKEFILES="`echo $MAKEFILES`"
@@ -1638,8 +1639,10 @@ fi
AC_CONFIG_FILES($FIRSTMAKEFILE)
AC_CONFIG_FILES(Makefile, [{
+ sed '/^MISSING/s/\$U\././g' Makefile
echo; test x"$EXEEXT" = x || echo 'miniruby: miniruby$(EXEEXT)'
test "$RUBY_INSTALL_NAME$EXEEXT" = ruby || echo 'ruby: $(PROGRAM);'
sed ['s/{\$([^(){}]*)[^{}]*}//g'] ${srcdir}/common.mk
-} >> Makefile], [RUBY_INSTALL_NAME=$RUBY_INSTALL_NAME EXEEXT=$EXEEXT])
+ } >> confmk$$.tmp && mv -f confmk$$.tmp Makefile],
+[RUBY_INSTALL_NAME=$RUBY_INSTALL_NAME EXEEXT=$EXEEXT])
AC_OUTPUT
diff --git a/defines.h b/defines.h
index ef80989925..f1a565acf3 100644
--- a/defines.h
+++ b/defines.h
@@ -2,8 +2,8 @@
defines.h -
- $Author: nobu $
- $Date: 2005/10/25 16:59:57 $
+ $Author$
+ $Date$
created at: Wed May 18 00:21:44 JST 1994
************************************************/
@@ -218,19 +218,18 @@ flush_register_windows(void)
#endif
# if defined(__sparc_v9__) || defined(__sparcv9) || defined(__arch64__)
("flushw")
-# else
+# 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()
-#elif defined(__ia64__)
-void flush_register_windows(void)
-# if defined(__GNUC__) && (( __GNUC__ == 3 && __GNUC_MINOR__ > 0 ) || __GNUC__ > 3)
-__attribute__ ((noinline))
-# endif
- ;
-# define FLUSH_REGISTER_WINDOWS flush_register_windows()
+#elif defined(__ia64)
+void *rb_ia64_bsp(void);
+void rb_ia64_flushrs(void);
+# define FLUSH_REGISTER_WINDOWS rb_ia64_flushrs()
#else
# define FLUSH_REGISTER_WINDOWS ((void)0)
#endif
@@ -254,6 +253,10 @@ __attribute__ ((noinline))
#define ENV_IGNORECASE
#endif
+#ifndef DLEXT_MAXLEN
+#define DLEXT_MAXLEN 4
+#endif
+
#ifndef RUBY_PLATFORM
#define RUBY_PLATFORM "unknown-unknown"
#endif
diff --git a/dir.c b/dir.c
index 0798b3f76f..0dd12ffd7d 100644
--- a/dir.c
+++ b/dir.c
@@ -2,8 +2,8 @@
dir.c -
- $Author: shyouhei $
- $Date: 2006/12/14 14:50:13 $
+ $Author$
+ $Date$
created at: Wed Jan 5 09:51:01 JST 1994
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -89,153 +89,261 @@ char *strchr _((char*,char));
#define FNM_ERROR 2
#define downcase(c) (nocase && ISUPPER(c) ? tolower(c) : (c))
+#define compare(c1, c2) (((unsigned char)(c1)) - ((unsigned char)(c2)))
+
+/* caution: in case *p == '\0'
+ Next(p) == p + 1 in single byte environment
+ Next(p) == p in multi byte environment
+*/
+#if defined(CharNext)
+# define Next(p) CharNext(p)
+#elif defined(DJGPP)
+# define Next(p) ((p) + mblen(p, RUBY_MBCHAR_MAXSIZE))
+#elif defined(__EMX__)
+# define Next(p) ((p) + emx_mblen(p))
+static inline int
+emx_mblen(const char *p)
+{
+ int n = mblen(p, RUBY_MBCHAR_MAXSIZE);
+ return (n < 0) ? 1 : n;
+}
+#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
+#ifndef Next /* single byte environment */
+# define Next(p) ((p) + 1)
+# define Inc(p) (++(p))
+# define Compare(p1, p2) (compare(downcase(*(p1)), downcase(*(p2))))
+#else /* multi byte environment */
+# define Inc(p) ((p) = Next(p))
+# define Compare(p1, p2) (CompareImpl(p1, p2, nocase))
+static int
+CompareImpl(const char *p1, const char *p2, int nocase)
+{
+ const int len1 = Next(p1) - p1;
+ const int len2 = Next(p2) - p2;
+#ifdef _WIN32
+ char buf1[10], buf2[10]; /* large enough? */
#endif
-#if defined DOSISH
-#define isdirsep(c) ((c) == '/' || (c) == '\\')
-#else
-#define isdirsep(c) ((c) == '/')
+ if (len1 < 0 || len2 < 0) {
+ rb_fatal("CompareImpl: negative len");
+ }
+
+ if (len1 == 0) return len2;
+ if (len2 == 0) return -len1;
+
+#ifdef _WIN32
+ if (nocase && rb_w32_iswinnt()) {
+ if (len1 > 1) {
+ if (len1 >= sizeof(buf1)) {
+ rb_fatal("CompareImpl: too large len");
+ }
+ memcpy(buf1, p1, len1);
+ buf1[len1] = '\0';
+ CharLower(buf1);
+ p1 = buf1; /* trick */
+ }
+ if (len2 > 1) {
+ if (len2 >= sizeof(buf2)) {
+ rb_fatal("CompareImpl: too large len");
+ }
+ memcpy(buf2, p2, len2);
+ buf2[len2] = '\0';
+ CharLower(buf2);
+ p2 = buf2; /* trick */
+ }
+ }
#endif
+ if (len1 == 1)
+ if (len2 == 1)
+ return compare(downcase(*p1), downcase(*p2));
+ else {
+ const int ret = compare(downcase(*p1), *p2);
+ return ret ? ret : -1;
+ }
+ else
+ if (len2 == 1) {
+ const int ret = compare(*p1, downcase(*p2));
+ return ret ? ret : 1;
+ }
+ else {
+ const int ret = memcmp(p1, p2, len1 < len2 ? len1 : len2);
+ return ret ? ret : len1 - len2;
+ }
+}
+#endif /* environment */
static char *
-range(pat, test, flags)
- const char *pat;
- int test;
+bracket(p, s, flags)
+ const char *p; /* pattern (next to '[') */
+ const char *s; /* string */
int flags;
{
- int not, ok = 0;
- int nocase = flags & FNM_CASEFOLD;
- int escape = !(flags & FNM_NOESCAPE);
+ const int nocase = flags & FNM_CASEFOLD;
+ const int escape = !(flags & FNM_NOESCAPE);
- not = *pat == '!' || *pat == '^';
- if (not)
- pat++;
+ int ok = 0, not = 0;
- test = downcase(test);
+ if (*p == '!' || *p == '^') {
+ not = 1;
+ p++;
+ }
- while (*pat != ']') {
- int cstart, cend;
- if (escape && *pat == '\\')
- pat++;
- cstart = cend = *pat++;
- if (!cstart)
+ while (*p != ']') {
+ const char *t1 = p;
+ if (escape && *t1 == '\\')
+ t1++;
+ if (!*t1)
return NULL;
- if (*pat == '-' && pat[1] != ']') {
- pat++;
- if (escape && *pat == '\\')
- pat++;
- cend = *pat++;
- if (!cend)
+ p = Next(t1);
+ if (p[0] == '-' && p[1] != ']') {
+ const char *t2 = p + 1;
+ if (escape && *t2 == '\\')
+ t2++;
+ if (!*t2)
return NULL;
+ p = Next(t2);
+ if (!ok && Compare(t1, s) <= 0 && Compare(s, t2) <= 0)
+ ok = 1;
}
- if (downcase(cstart) <= test && test <= downcase(cend))
- ok = 1;
+ else
+ if (!ok && Compare(t1, s) == 0)
+ ok = 1;
}
- return ok == not ? NULL : (char *)pat + 1;
+
+ return ok == not ? NULL : (char *)p + 1;
}
-#define ISDIRSEP(c) (pathname && isdirsep(c))
-#define PERIOD(s) (period && *(s) == '.' && \
- ((s) == string || ISDIRSEP((s)[-1])))
+/* If FNM_PATHNAME is set, only path element will be matched. (upto '/' or '\0')
+ Otherwise, entire string will be matched.
+ End marker itself won't be compared.
+ And if function succeeds, *pcur reaches end marker.
+*/
+#define UNESCAPE(p) (escape && *(p) == '\\' ? (p) + 1 : (p))
+#define ISEND(p) (!*(p) || (pathname && *(p) == '/'))
+#define RETURN(val) return *pcur = p, *scur = s, (val);
+
static int
-fnmatch(pat, string, flags)
- const char *pat;
- const char *string;
+fnmatch_helper(pcur, scur, flags)
+ const char **pcur; /* pattern */
+ const char **scur; /* string */
int flags;
{
- int c;
- int test;
- const char *s = string;
- int escape = !(flags & FNM_NOESCAPE);
- int pathname = flags & FNM_PATHNAME;
- int period = !(flags & FNM_DOTMATCH);
- int nocase = flags & FNM_CASEFOLD;
+ const int period = !(flags & FNM_DOTMATCH);
+ const int pathname = flags & FNM_PATHNAME;
+ const int escape = !(flags & FNM_NOESCAPE);
+ const int nocase = flags & FNM_CASEFOLD;
- while ((c = *pat++) != '\0') {
- switch (c) {
- case '?':
- if (!*s || ISDIRSEP(*s) || PERIOD(s))
- return FNM_NOMATCH;
- s++;
- break;
- case '*':
- while ((c = *pat++) == '*')
- ;
+ const char *ptmp = 0;
+ const char *stmp = 0;
- if (PERIOD(s))
- return FNM_NOMATCH;
+ const char *p = *pcur;
+ const char *s = *scur;
- if (!c) {
- if (pathname && *rb_path_next(s))
- return FNM_NOMATCH;
- else
- return 0;
- }
- else if (ISDIRSEP(c)) {
- s = rb_path_next(s);
- if (*s) {
- s++;
- break;
- }
- return FNM_NOMATCH;
- }
+ if (period && *s == '.' && *UNESCAPE(p) != '.') /* leading period */
+ RETURN(FNM_NOMATCH);
- test = escape && c == '\\' ? *pat : c;
- test = downcase(test);
- pat--;
- while (*s) {
- if ((c == '?' || c == '[' || downcase(*s) == test) &&
- !fnmatch(pat, s, flags | FNM_DOTMATCH))
- return 0;
- else if (ISDIRSEP(*s))
- break;
- s++;
+ while (1) {
+ switch (*p) {
+ case '*':
+ do { p++; } while (*p == '*');
+ if (ISEND(UNESCAPE(p))) {
+ p = UNESCAPE(p);
+ RETURN(0);
}
- return FNM_NOMATCH;
+ if (ISEND(s))
+ RETURN(FNM_NOMATCH);
+ ptmp = p;
+ stmp = s;
+ continue;
- case '[':
- if (!*s || ISDIRSEP(*s) || PERIOD(s))
- return FNM_NOMATCH;
- pat = range(pat, *s, flags);
- if (pat == NULL)
- return FNM_NOMATCH;
- s++;
- break;
+ case '?':
+ if (ISEND(s))
+ RETURN(FNM_NOMATCH);
+ p++;
+ Inc(s);
+ continue;
- case '\\':
- if (escape
-#if defined DOSISH
- && *pat && strchr("*?[]\\", *pat)
-#endif
- ) {
- c = *pat;
- if (!c)
- c = '\\';
- else
- pat++;
+ case '[': {
+ const char *t;
+ if (ISEND(s))
+ RETURN(FNM_NOMATCH);
+ if (t = bracket(p + 1, s, flags)) {
+ p = t;
+ Inc(s);
+ continue;
}
- /* FALLTHROUGH */
+ goto failed;
+ }
+ }
- default:
-#if defined DOSISH
- if (ISDIRSEP(c) && isdirsep(*s))
- ;
- else
-#endif
- if(downcase(c) != downcase(*s))
- return FNM_NOMATCH;
- s++;
- break;
+ /* ordinary */
+ p = UNESCAPE(p);
+ if (ISEND(s))
+ RETURN(ISEND(p) ? 0 : FNM_NOMATCH);
+ if (ISEND(p))
+ goto failed;
+ if (Compare(p, s) != 0)
+ goto failed;
+ Inc(p);
+ Inc(s);
+ continue;
+
+ failed: /* try next '*' position */
+ if (ptmp && stmp) {
+ p = ptmp;
+ Inc(stmp); /* !ISEND(*stmp) */
+ s = stmp;
+ continue;
+ }
+ RETURN(FNM_NOMATCH);
+ }
+}
+
+static int
+fnmatch(p, s, flags)
+ const char *p; /* pattern */
+ const char *s; /* string */
+ int flags;
+{
+ const int period = !(flags & FNM_DOTMATCH);
+ const int pathname = flags & FNM_PATHNAME;
+
+ const char *ptmp = 0;
+ const char *stmp = 0;
+
+ if (pathname) {
+ while (1) {
+ if (p[0] == '*' && p[1] == '*' && p[2] == '/') {
+ do { p += 3; } while (p[0] == '*' && p[1] == '*' && p[2] == '/');
+ ptmp = p;
+ stmp = s;
+ }
+ if (fnmatch_helper(&p, &s, flags) == 0) {
+ while (*s && *s != '/') Inc(s);
+ if (*p && *s) {
+ p++;
+ s++;
+ continue;
+ }
+ if (!*p && !*s)
+ return 0;
+ }
+ /* failed : try next recursion */
+ if (ptmp && stmp && !(period && *stmp == '.')) {
+ while (*stmp && *stmp != '/') Inc(stmp);
+ if (*stmp) {
+ p = ptmp;
+ stmp++;
+ s = stmp;
+ continue;
+ }
+ }
+ return FNM_NOMATCH;
}
}
- return !*s ? 0 : FNM_NOMATCH;
+ else
+ return fnmatch_helper(&p, &s, flags);
}
VALUE rb_cDir;
@@ -355,6 +463,29 @@ dir_check(dir)
/*
* call-seq:
+ * dir.inspect => string
+ *
+ * Return a string describing this Dir object.
+ */
+static VALUE
+dir_inspect(dir)
+ VALUE dir;
+{
+ struct dir_data *dirp;
+
+ GetDIR(dir, dirp);
+ if (dirp->path) {
+ char *c = rb_obj_classname(dir);
+ int len = strlen(c) + strlen(dirp->path) + 4;
+ VALUE s = rb_str_new(0, len);
+ snprintf(RSTRING_PTR(s), len+1, "#<%s:%s>", c, dirp->path);
+ return s;
+ }
+ return rb_funcall(dir, rb_intern("to_s"), 0, 0);
+}
+
+/*
+ * call-seq:
* dir.path => string or nil
*
* Returns the path parameter passed to <em>dir</em>'s constructor.
@@ -538,6 +669,9 @@ dir_rewind(dir)
{
struct dir_data *dirp;
+ if (rb_safe_level() >= 4 && !OBJ_TAINTED(dir)) {
+ rb_raise(rb_eSecurityError, "Insecure: can't close");
+ }
GetDIR(dir, dirp);
rewinddir(dirp->dir);
return dir;
@@ -559,9 +693,6 @@ dir_close(dir)
{
struct dir_data *dirp;
- if (rb_safe_level() >= 4 && !OBJ_TAINTED(dir)) {
- rb_raise(rb_eSecurityError, "Insecure: can't close");
- }
GetDIR(dir, dirp);
closedir(dirp->dir);
dirp->dir = NULL;
@@ -819,109 +950,252 @@ sys_warning_1(mesg)
rb_sys_warning("%s", mesg);
}
-#define GLOB_VERBOSE (1U << (sizeof(int) * CHAR_BIT - 1))
+#define GLOB_VERBOSE (1UL << (sizeof(int) * CHAR_BIT - 1))
#define sys_warning(val) \
(void)((flags & GLOB_VERBOSE) && rb_protect((VALUE (*)_((VALUE)))sys_warning_1, (VALUE)(val), 0))
#define GLOB_ALLOC(type) (type *)malloc(sizeof(type))
#define GLOB_ALLOC_N(type, n) (type *)malloc(sizeof(type) * (n))
-#define GLOB_REALLOC_N(var, type, n) (type *)realloc((var), sizeof(type) * (n))
#define GLOB_JUMP_TAG(status) ((status == -1) ? rb_memerror() : rb_jump_tag(status))
+/*
+ * ENOTDIR can be returned by stat(2) if a non-leaf element of the path
+ * is not a directory.
+ */
+#define to_be_ignored(e) ((e) == ENOENT || (e) == ENOTDIR)
+
+/* System call with warning */
+static int
+do_stat(const char *path, struct stat *pst, int flags)
+
+{
+ int ret = stat(path, pst);
+ if (ret < 0 && !to_be_ignored(errno))
+ sys_warning(path);
+
+ return ret;
+}
+
+static int
+do_lstat(const char *path, struct stat *pst, int flags)
+{
+ int ret = lstat(path, pst);
+ if (ret < 0 && !to_be_ignored(errno))
+ sys_warning(path);
+
+ return ret;
+}
+
+static DIR *
+do_opendir(const char *path, int flags)
+{
+ DIR *dirp = opendir(path);
+ if (dirp == NULL && !to_be_ignored(errno))
+ sys_warning(path);
+
+ return dirp;
+}
+
/* Return nonzero if S has any special globbing chars in it. */
static int
-has_magic(s, send, flags)
- const char *s, *send;
+has_magic(s, flags)
+ const char *s;
int flags;
{
- register const char *p = s;
- register char c;
- int open = 0;
const int escape = !(flags & FNM_NOESCAPE);
const int nocase = flags & FNM_CASEFOLD;
- while ((c = *p++) != '\0') {
+ register const char *p = s;
+ register char c;
+
+ while (c = *p++) {
switch (c) {
- case '?':
case '*':
- return Qtrue;
-
- case '[': /* Only accept an open brace if there is a close */
- open++; /* brace to match it. Bracket expressions must be */
- continue; /* complete, according to Posix.2 */
- case ']':
- if (open)
- return Qtrue;
- continue;
+ case '?':
+ case '[':
+ return 1;
case '\\':
- if (escape && *p++ == '\0')
- return Qfalse;
- break;
+ if (escape && !(c = *p++))
+ return 0;
+ continue;
default:
if (!FNM_SYSCASE && ISALPHA(c) && nocase)
- return Qtrue;
+ return 1;
}
- if (send && p >= send) break;
+ p = Next(p-1);
}
- return Qfalse;
+
+ return 0;
}
-static char*
-extract_path(p, pend)
- const char *p, *pend;
+/* Find separator in globbing pattern. */
+static char *
+find_dirsep(const char *s, int flags)
{
- char *alloc;
- int len;
-
- len = pend - p;
- alloc = GLOB_ALLOC_N(char, len+1);
- if (!alloc) return NULL;
- memcpy(alloc, p, len);
- if (len > 1 && pend[-1] == '/'
-#if defined DOSISH_DRIVE_LETTER
- && pend[-2] != ':'
-#endif
- ) {
- alloc[len-1] = 0;
- }
- else {
- alloc[len] = 0;
- }
+ const int escape = !(flags & FNM_NOESCAPE);
- return alloc;
-}
+ register const char *p = s;
+ register char c;
+ int open = 0;
-static char*
-extract_elem(path)
- const char *path;
-{
- const char *pend;
+ while (c = *p++) {
+ switch (c) {
+ case '[':
+ open = 1;
+ continue;
+ case ']':
+ open = 0;
+ continue;
+
+ case '/':
+ if (!open)
+ return (char *)p-1;
+ continue;
+
+ case '\\':
+ if (escape && !(c = *p++))
+ return (char *)p-1;
+ continue;
+ }
- pend = strchr(path, '/');
- if (!pend) pend = path + strlen(path);
+ p = Next(p-1);
+ }
- return extract_path(path, pend);
+ return (char *)p-1;
}
+/* Remove escaping backslashes */
static void
remove_backslashes(p)
char *p;
{
- char *pend = p + strlen(p);
char *t = p;
+ char *s = p;
- while (p < pend) {
+ while (*p) {
if (*p == '\\') {
- if (++p == pend) break;
+ if (t != s)
+ memmove(t, s, p - s);
+ t += p - s;
+ s = ++p;
+ if (!*p) break;
+ }
+ Inc(p);
+ }
+
+ while (*p++);
+
+ if (t != s)
+ memmove(t, s, p - s); /* move '\0' too */
+}
+
+/* Globing pattern */
+enum glob_pattern_type { PLAIN, MAGICAL, RECURSIVE, MATCH_ALL, MATCH_DIR };
+
+struct glob_pattern {
+ char *str;
+ enum glob_pattern_type type;
+ struct glob_pattern *next;
+};
+
+static void glob_free_pattern(struct glob_pattern *list);
+
+static struct glob_pattern *
+glob_make_pattern(const char *p, int flags)
+{
+ struct glob_pattern *list, *tmp, **tail = &list;
+ int dirsep = 0; /* pattern is terminated with '/' */
+
+ while (*p) {
+ tmp = GLOB_ALLOC(struct glob_pattern);
+ if (!tmp) goto error;
+ if (p[0] == '*' && p[1] == '*' && p[2] == '/') {
+ /* fold continuous RECURSIVEs (needed in glob_helper) */
+ do { p += 3; } while (p[0] == '*' && p[1] == '*' && p[2] == '/');
+ tmp->type = RECURSIVE;
+ tmp->str = 0;
+ dirsep = 1;
+ }
+ else {
+ const char *m = find_dirsep(p, flags);
+ char *buf = GLOB_ALLOC_N(char, m-p+1);
+ if (!buf) {
+ free(tmp);
+ goto error;
+ }
+ memcpy(buf, p, m-p);
+ buf[m-p] = '\0';
+ tmp->type = has_magic(buf, flags) ? MAGICAL : PLAIN;
+ tmp->str = buf;
+ if (*m) {
+ dirsep = 1;
+ p = m + 1;
+ }
+ else {
+ dirsep = 0;
+ p = m;
+ }
}
- *t++ = *p++;
+ *tail = tmp;
+ tail = &tmp->next;
+ }
+
+ tmp = GLOB_ALLOC(struct glob_pattern);
+ if (!tmp) {
+ error:
+ *tail = 0;
+ glob_free_pattern(list);
+ return 0;
}
- *t = '\0';
+ tmp->type = dirsep ? MATCH_DIR : MATCH_ALL;
+ tmp->str = 0;
+ *tail = tmp;
+ tmp->next = 0;
+
+ return list;
}
+static void
+glob_free_pattern(struct glob_pattern *list)
+{
+ while (list) {
+ struct glob_pattern *tmp = list;
+ list = list->next;
+ if (tmp->str)
+ free(tmp->str);
+ free(tmp);
+ }
+}
+
+static char *
+join_path(const char *path, int dirsep, const char *name)
+{
+ long len = strlen(path);
+ char *buf = GLOB_ALLOC_N(char, len+strlen(name)+(dirsep?1:0)+1);
+
+ if (!buf) return 0;
+ memcpy(buf, path, len);
+ if (dirsep) {
+ strcpy(buf+len, "/");
+ len++;
+ }
+ strcpy(buf+len, name);
+ return buf;
+}
+
+enum answer { YES, NO, UNKNOWN };
+
+#ifndef S_ISLNK
+# ifndef S_IFLNK
+# define S_ISLNK(m) (0)
+# else
+# define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
+# endif
+#endif
+
#ifndef S_ISDIR
# define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
#endif
@@ -946,235 +1220,239 @@ glob_func_caller(val)
#define glob_call_func(func, path, arg) (*func)(path, arg)
-static int glob_helper _((const char *path, const char *sub, int flags, int (*func)(const char *,VALUE), VALUE arg));
+static int glob_helper _((const char *, int, enum answer, enum answer, struct glob_pattern **, struct glob_pattern **, int, ruby_glob_func *, VALUE));
static int
-glob_helper(path, sub, flags, func, arg)
+glob_helper(path, dirsep, exist, isdir, beg, end, flags, func, arg)
const char *path;
- const char *sub;
+ int dirsep; /* '/' should be placed before appending child entry's name to 'path'. */
+ enum answer exist; /* Does 'path' indicate an existing entry? */
+ enum answer isdir; /* Does 'path' indicate a directory or a symlink to a directory? */
+ struct glob_pattern **beg;
+ struct glob_pattern **end;
int flags;
- int (*func) _((const char *, VALUE));
+ ruby_glob_func *func;
VALUE arg;
{
struct stat st;
- const char *p, *m;
int status = 0;
- char *buf = 0;
- char *newpath = 0;
- char *newbuf;
-
- p = sub ? sub : path;
- if (!has_magic(p, 0, flags)) {
-#if !defined DOSISH
- if (!(flags & FNM_NOESCAPE))
-#endif
- {
- newpath = strdup(path);
- if (!newpath) return -1;
- if (sub) {
- p = newpath + (sub - path);
- remove_backslashes(newpath + (sub - path));
- sub = p;
+ struct glob_pattern **cur, **new_beg, **new_end;
+ int plain = 0, magical = 0, recursive = 0, match_all = 0, match_dir = 0;
+ int escape = !(flags & FNM_NOESCAPE);
+
+ for (cur = beg; cur < end; ++cur) {
+ struct glob_pattern *p = *cur;
+ if (p->type == RECURSIVE) {
+ recursive = 1;
+ p = p->next;
+ }
+ switch (p->type) {
+ case PLAIN:
+ plain = 1;
+ break;
+ case MAGICAL:
+ magical = 1;
+ break;
+ case MATCH_ALL:
+ match_all = 1;
+ break;
+ case MATCH_DIR:
+ match_dir = 1;
+ break;
+ case RECURSIVE:
+ rb_bug("continuous RECURSIVEs");
+ }
+ }
+
+ if (*path) {
+ if (match_all && exist == UNKNOWN) {
+ if (do_lstat(path, &st, flags) == 0) {
+ exist = YES;
+ isdir = S_ISDIR(st.st_mode) ? YES : S_ISLNK(st.st_mode) ? UNKNOWN : NO;
}
else {
- remove_backslashes(newpath);
- p = path = newpath;
+ exist = NO;
+ isdir = NO;
}
}
- if (lstat(path, &st) == 0) {
+ if (match_dir && isdir == UNKNOWN) {
+ if (do_stat(path, &st, flags) == 0) {
+ exist = YES;
+ isdir = S_ISDIR(st.st_mode) ? YES : NO;
+ }
+ else {
+ exist = NO;
+ isdir = NO;
+ }
+ }
+ if (match_all && exist == YES) {
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. */
- sys_warning(path);
+ if (match_dir && isdir == YES) {
+ char *tmp = join_path(path, dirsep, "");
+ if (!tmp) return -1;
+ status = glob_call_func(func, tmp, arg);
+ free(tmp);
+ if (status) return status;
}
- if (newpath) free(newpath);
- return status;
}
- while (p && !status) {
- if (*p == '/') p++;
- m = strchr(p, '/');
- if (has_magic(p, m, flags)) {
- char *dir, *base, *magic;
- DIR *dirp;
- struct dirent *dp;
- int recursive = 0;
-
- struct d_link {
- char *path;
- struct d_link *next;
- } *tmp, *link, **tail = &link;
-
- base = extract_path(path, p);
- if (!base) {
+ if (exist == NO || isdir == NO) return 0;
+
+ if (magical || recursive) {
+ struct dirent *dp;
+ DIR *dirp = do_opendir(*path ? path : ".", flags);
+ if (dirp == NULL) return 0;
+
+ for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
+ char *buf = join_path(path, dirsep, dp->d_name);
+ enum answer new_isdir = UNKNOWN;
+
+ if (!buf) {
status = -1;
break;
}
- if (path == p) dir = ".";
- else dir = base;
+ if (recursive && strcmp(dp->d_name, ".") != 0 && strcmp(dp->d_name, "..") != 0
+ && fnmatch("*", dp->d_name, flags) == 0) {
+#ifndef _WIN32
+ if (do_lstat(buf, &st, flags) == 0)
+ new_isdir = S_ISDIR(st.st_mode) ? YES : S_ISLNK(st.st_mode) ? UNKNOWN : NO;
+ else
+ new_isdir = NO;
+#else
+ new_isdir = dp->d_isdir ? (!dp->d_isrep ? YES : UNKNOWN) : NO;
+#endif
+ }
- magic = extract_elem(p);
- if (!magic) {
+ new_beg = new_end = GLOB_ALLOC_N(struct glob_pattern *, (end - beg) * 2);
+ if (!new_beg) {
status = -1;
break;
}
- if (stat(dir, &st) < 0) {
- if (errno != ENOENT)
- sys_warning(dir);
- free(base);
- free(magic);
- break;
- }
- if (S_ISDIR(st.st_mode)) {
- if (m && strcmp(magic, "**") == 0) {
- int n = strlen(base);
- recursive = 1;
- newbuf = GLOB_REALLOC_N(buf, char, n+strlen(m)+3);
- if (!newbuf) {
- status = -1;
- goto finalize;
- }
- buf = newbuf;
- sprintf(buf, "%s%s", base, *base ? m : m+1);
- status = glob_helper(buf, buf+n, flags, func, arg);
- if (status) goto finalize;
+
+ for (cur = beg; cur < end; ++cur) {
+ struct glob_pattern *p = *cur;
+ if (p->type == RECURSIVE) {
+ if (new_isdir == YES) /* not symlink but real directory */
+ *new_end++ = p; /* append recursive pattern */
+ p = p->next; /* 0 times recursion */
}
- dirp = opendir(dir);
- if (dirp == NULL) {
- sys_warning(dir);
- free(base);
- free(magic);
- break;
+ if (p->type == PLAIN || p->type == MAGICAL) {
+ if (fnmatch(p->str, dp->d_name, flags) == 0)
+ *new_end++ = p->next;
}
}
- else {
- free(base);
- free(magic);
- break;
- }
-#if defined DOSISH_DRIVE_LETTER
-#define BASE (*base && !((isdirsep(*base) && !base[1]) || (base[1] == ':' && isdirsep(base[2]) && !base[3])))
-#else
-#define BASE (*base && !(isdirsep(*base) && !base[1]))
-#endif
+ status = glob_helper(buf, 1, YES, new_isdir, new_beg, new_end, flags, func, arg);
+ free(buf);
+ free(new_beg);
+ if (status) break;
+ }
- 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;
- newbuf = GLOB_REALLOC_N(buf, char, strlen(base)+NAMLEN(dp)+strlen(m)+6);
- if (!newbuf) {
- status = -1;
- break;
- }
- buf = newbuf;
- sprintf(buf, "%s%s%s", base, (BASE) ? "/" : "", dp->d_name);
- if (lstat(buf, &st) < 0) {
- if (errno != ENOENT)
- sys_warning(buf);
- continue;
- }
- if (S_ISDIR(st.st_mode)) {
- char *t = buf+strlen(buf);
- strcpy(t, "/**");
- strcpy(t+3, m);
- status = glob_helper(buf, t, flags, func, arg);
- if (status) break;
- continue;
- }
- continue;
+ closedir(dirp);
+ }
+ else if (plain) {
+ struct glob_pattern **copy_beg, **copy_end, **cur2;
+
+ copy_beg = copy_end = GLOB_ALLOC_N(struct glob_pattern *, end - beg);
+ if (!copy_beg) return -1;
+ for (cur = beg; cur < end; ++cur)
+ *copy_end++ = (*cur)->type == PLAIN ? *cur : 0;
+
+ for (cur = copy_beg; cur < copy_end; ++cur) {
+ if (*cur) {
+ char *buf;
+ char *name;
+ name = GLOB_ALLOC_N(char, strlen((*cur)->str) + 1);
+ if (!name) {
+ status = -1;
+ break;
}
- if (fnmatch(magic, dp->d_name, flags) == 0) {
- newbuf = GLOB_REALLOC_N(buf, char, strlen(base)+NAMLEN(dp)+2);
- if (!newbuf) {
- status = -1;
- break;
- }
- buf = newbuf;
- sprintf(buf, "%s%s%s", base, (BASE) ? "/" : "", dp->d_name);
- if (!m) {
- status = glob_call_func(func, buf, arg);
- if (status) break;
- continue;
- }
- tmp = GLOB_ALLOC(struct d_link);
- if (!tmp) {
- status = -1;
- break;
- }
- tmp->path = buf;
- buf = 0;
- *tail = tmp;
- tail = &tmp->next;
+ strcpy(name, (*cur)->str);
+ if (escape) remove_backslashes(name);
+
+ new_beg = new_end = GLOB_ALLOC_N(struct glob_pattern *, end - beg);
+ if (!new_beg) {
+ free(name);
+ status = -1;
+ break;
}
- }
- closedir(dirp);
- finalize:
- *tail = 0;
- free(base);
- free(magic);
- 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);
-
- newbuf = GLOB_REALLOC_N(buf, char, len+mlen+1);
- if (!newbuf) {
- status = -1;
- goto next_elem;
- }
- buf = newbuf;
- sprintf(buf, "%s%s", link->path, m);
- status = glob_helper(buf, buf+len, flags, func, arg);
- }
- }
- else {
- sys_warning(link->path);
- }
+ *new_end++ = (*cur)->next;
+ for (cur2 = cur + 1; cur2 < copy_end; ++cur2) {
+ if (*cur2 && fnmatch((*cur2)->str, name, flags) == 0) {
+ *new_end++ = (*cur2)->next;
+ *cur2 = 0;
}
- next_elem:
- tmp = link;
- link = link->next;
- free(tmp->path);
- free(tmp);
}
- break;
+
+ buf = join_path(path, dirsep, name);
+ free(name);
+ if (!buf) {
+ free(new_beg);
+ status = -1;
+ break;
+ }
+ status = glob_helper(buf, 1, UNKNOWN, UNKNOWN, new_beg, new_end, flags, func, arg);
+ free(buf);
+ free(new_beg);
+ if (status) break;
}
}
- p = m;
+
+ free(copy_beg);
}
- if (buf) free(buf);
- if (newpath) free(newpath);
+
return status;
}
-int
-ruby_glob(path, flags, func, arg)
+static int
+ruby_glob0(path, flags, func, arg)
const char *path;
int flags;
- int (*func) _((const char *, VALUE));
+ ruby_glob_func *func;
VALUE arg;
{
+ struct glob_pattern *list;
+ const char *root, *start;
+ char *buf;
+ int n;
+ int status;
+
+ start = root = path;
flags |= FNM_SYSCASE;
- return glob_helper(path, 0, flags & ~GLOB_VERBOSE, func, arg);
+#if defined DOSISH
+ root = rb_path_skip_prefix(root);
+#endif
+
+ if (root && *root == '/') root++;
+
+ n = root - start;
+ buf = GLOB_ALLOC_N(char, n + 1);
+ if (!buf) return -1;
+ MEMCPY(buf, start, char, n);
+ buf[n] = '\0';
+
+ list = glob_make_pattern(root, flags);
+ if (!list) {
+ free(buf);
+ return -1;
+ }
+ status = glob_helper(buf, 0, UNKNOWN, UNKNOWN, &list, &list + 1, flags, func, arg);
+ glob_free_pattern(list);
+ free(buf);
+
+ return status;
}
int
-ruby_globi(path, flags, func, arg)
+ruby_glob(path, flags, func, arg)
const char *path;
int flags;
- int (*func) _((const char *, VALUE));
+ ruby_glob_func *func;
VALUE arg;
{
- return glob_helper(path, 0, flags | FNM_CASEFOLD, func, arg);
+ return ruby_glob0(path, flags & ~GLOB_VERBOSE, func, arg);
}
static int rb_glob_caller _((const char *, VALUE));
@@ -1204,8 +1482,11 @@ rb_glob2(path, flags, func, arg)
args.func = func;
args.v = arg;
- flags |= FNM_SYSCASE;
- return glob_helper(path, 0, flags | GLOB_VERBOSE, rb_glob_caller, (VALUE)&args);
+ if (flags & FNM_SYSCASE) {
+ rb_warning("Dir.glob() ignores File::FNM_CASEFOLD");
+ }
+
+ return ruby_glob0(path, flags | GLOB_VERBOSE, rb_glob_caller, (VALUE)&args);
}
void
@@ -1215,19 +1496,10 @@ rb_glob(path, func, arg)
VALUE arg;
{
int status = rb_glob2(path, 0, func, arg);
- if (status) rb_jump_tag(status);
-}
-
-void
-rb_globi(path, func, arg)
- const char *path;
- void (*func) _((const char*, VALUE));
- VALUE arg;
-{
- int status = rb_glob2(path, FNM_CASEFOLD, func, arg);
- if (status) rb_jump_tag(status);
+ if (status) GLOB_JUMP_TAG(status);
}
+static void push_pattern _((const char* path, VALUE ary));
static void
push_pattern(path, ary)
const char *path;
@@ -1236,155 +1508,196 @@ push_pattern(path, ary)
rb_ary_push(ary, rb_tainted_str_new2(path));
}
-static int
-push_globs(ary, s, flags)
- VALUE ary;
- const char *s;
- int flags;
-{
- return rb_glob2(s, flags, push_pattern, ary);
-}
-
-static int
-push_braces(ary, str, flags)
- VALUE ary;
+int
+ruby_brace_expand(str, flags, func, arg)
const char *str;
int flags;
+ ruby_glob_func *func;
+ VALUE arg;
{
- char *buf = 0;
- char *b, *newbuf;
- const char *s, *p, *t;
- const char *lbrace, *rbrace;
- int nest = 0;
- int status = 0;
+ const int escape = !(flags & FNM_NOESCAPE);
+ const char *p = str;
+ const char *s = p;
+ const char *lbrace = 0, *rbrace = 0;
+ int nest = 0, status = 0;
- s = p = str;
- lbrace = rbrace = 0;
while (*p) {
- if (*p == '{') {
+ if (*p == '{' && nest++ == 0) {
lbrace = p;
- break;
}
- p++;
- }
- while (*p) {
- if (*p == '{') nest++;
- if (*p == '}' && --nest == 0) {
+ if (*p == '}' && --nest <= 0) {
rbrace = p;
break;
}
- p++;
+ if (*p == '\\' && escape) {
+ if (!*++p) break;
+ }
+ Inc(p);
}
if (lbrace && rbrace) {
- int len = strlen(s);
+ char *buf = GLOB_ALLOC_N(char, strlen(s) + 1);
+ long shift;
+
+ if (!buf) return -1;
+ memcpy(buf, s, lbrace-s);
+ shift = (lbrace-s);
p = lbrace;
- while (*p != '}') {
- t = p + 1;
- for (p = t; *p!='}' && *p!=','; p++) {
- /* skip inner braces */
- if (*p == '{') {
- nest = 1;
- while (*++p != '}' || --nest) {
- if (*p == '{') nest++;
- }
+ while (p < rbrace) {
+ const char *t = ++p;
+ nest = 0;
+ while (p < rbrace && !(*p == ',' && nest == 0)) {
+ if (*p == '{') nest++;
+ if (*p == '}') nest--;
+ if (*p == '\\' && escape) {
+ if (++p == rbrace) break;
}
+ Inc(p);
}
- newbuf = GLOB_REALLOC_N(buf, char, len+1);
- if (!newbuf) {
- status = -1;
- break;
- }
- buf = newbuf;
- memcpy(buf, s, lbrace-s);
- b = buf + (lbrace-s);
- memcpy(b, t, p-t);
- strcpy(b+(p-t), rbrace+1);
- status = push_braces(ary, buf, flags);
+ memcpy(buf+shift, t, p-t);
+ strcpy(buf+shift+(p-t), rbrace+1);
+ status = ruby_brace_expand(buf, flags, func, arg);
if (status) break;
}
+ free(buf);
}
- else {
- status = push_globs(ary, str, flags);
+ else if (!lbrace && !rbrace) {
+ status = (*func)(s, arg);
}
- if (buf) free(buf);
return status;
}
-#define isdelim(c) ((c)=='\0')
+struct brace_args {
+ ruby_glob_func *func;
+ VALUE value;
+ int flags;
+};
+
+static int glob_brace _((const char *, VALUE));
+static int
+glob_brace(path, val)
+ const char *path;
+ VALUE val;
+{
+ struct brace_args *arg = (struct brace_args *)val;
+
+ return ruby_glob0(path, arg->flags, arg->func, arg->value);
+}
+
+static int
+ruby_brace_glob0(str, flags, func, arg)
+ const char *str;
+ int flags;
+ ruby_glob_func *func;
+ VALUE arg;
+{
+ struct brace_args args;
+
+ args.func = func;
+ args.value = arg;
+ args.flags = flags;
+ return ruby_brace_expand(str, flags, glob_brace, (VALUE)&args);
+}
+
+int
+ruby_brace_glob(str, flags, func, arg)
+ const char *str;
+ int flags;
+ ruby_glob_func *func;
+ VALUE arg;
+{
+ return ruby_brace_glob0(str, flags & ~GLOB_VERBOSE, func, arg);
+}
+
+static int
+push_glob(VALUE ary, const char *str, int flags)
+{
+ struct glob_args args;
+
+ args.func = push_pattern;
+ args.v = ary;
+ return ruby_brace_glob0(str, flags | GLOB_VERBOSE, rb_glob_caller, (VALUE)&args);
+}
static VALUE
-rb_push_glob(str, flags)
+rb_push_glob(str, flags) /* '\0' is delimiter */
VALUE str;
int flags;
{
- const char *p, *pend, *buf;
- int nest, maxnest;
- int status = 0;
- int noescape = flags & FNM_NOESCAPE;
+ long offset = 0;
VALUE ary;
ary = rb_ary_new();
SafeStringValue(str);
- p = RSTRING(str)->ptr;
- pend = p + RSTRING(str)->len;
-
- while (p < pend) {
- nest = maxnest = 0;
- while (p < pend && isdelim(*p)) p++;
- buf = p;
- while (p < pend && !isdelim(*p)) {
- if (*p == '{') nest++, maxnest++;
- if (*p == '}') nest--;
- if (!noescape && *p == '\\') {
- if (++p == pend) break;
- }
+
+ while (offset < RSTRING_LEN(str)) {
+ int status = push_glob(ary, RSTRING(str)->ptr + offset, flags);
+ char *p, *pend;
+ if (status) GLOB_JUMP_TAG(status);
+ if (offset >= RSTRING_LEN(str)) break;
+ p = RSTRING(str)->ptr + offset;
+ p += strlen(p) + 1;
+ pend = RSTRING(str)->ptr + RSTRING_LEN(str);
+ while (p < pend && !*p)
p++;
- }
- if (maxnest == 0) {
- status = push_globs(ary, buf, flags);
- if (status) break;
- }
- else if (nest == 0) {
- status = push_braces(ary, buf, flags);
- if (status) break;
- }
- /* else unmatched braces */
+ offset = p - RSTRING(str)->ptr;
}
- if (status) GLOB_JUMP_TAG(status);
- if (rb_block_given_p()) {
- rb_ary_each(ary);
- return Qnil;
+
+ return ary;
+}
+
+static VALUE
+dir_globs(argc, argv, flags)
+ long argc;
+ VALUE *argv;
+ int flags;
+{
+ VALUE ary = rb_ary_new();
+ long i;
+
+ for (i = 0; i < argc; ++i) {
+ int status;
+ VALUE str = argv[i];
+ StringValue(str);
+ status = push_glob(ary, RSTRING(str)->ptr, flags);
+ if (status) GLOB_JUMP_TAG(status);
}
+
return ary;
}
/*
* call-seq:
- * Dir[ string ] => array
+ * Dir[ array ] => array
+ * Dir[ string [, string ...] ] => array
*
* Equivalent to calling
- * <em>dir</em>.<code>glob(</code><i>string,</i><code>0)</code>.
+ * <code>Dir.glob(</code><i>array,</i><code>0)</code> and
+ * <code>Dir.glob([</code><i>string,...</i><code>],0)</code>.
*
*/
static VALUE
-dir_s_aref(obj, str)
- VALUE obj, str;
-{
- return rb_push_glob(str, 0);
-}
+dir_s_aref(int argc, VALUE *argv, VALUE obj)
+ {
+ if (argc == 1) {
+ return rb_push_glob(argv[0], 0);
+ }
+ return dir_globs(argc, argv, 0);
+ }
/*
* call-seq:
- * Dir.glob( string, [flags] ) => array
- * Dir.glob( string, [flags] ) {| filename | block } => nil
+ * Dir.glob( pattern, [flags] ) => array
+ * Dir.glob( pattern, [flags] ) {| filename | block } => nil
*
- * 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 the meaning of
- * the <i>flags</i> parameter.
+ * Returns the filenames found by expanding <i>pattern</i> which is
+ * an +Array+ of the patterns or the pattern +String+, 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 the meaning of the <i>flags</i>
+ * parameter. Note that case sensitivity depends on your system (so
+ * <code>File::FNM_CASEFOLD</code> is ignored)
*
* <code>*</code>:: Matches any file. Can be restricted by
* other values in the glob. <code>*</code>
@@ -1439,7 +1752,7 @@ dir_s_glob(argc, argv, obj)
VALUE *argv;
VALUE obj;
{
- VALUE str, rflags;
+ VALUE str, rflags, ary;
int flags;
if (rb_scan_args(argc, argv, "11", &str, &rflags) == 2)
@@ -1447,7 +1760,20 @@ dir_s_glob(argc, argv, obj)
else
flags = 0;
- return rb_push_glob(str, flags);
+ ary = rb_check_array_type(str);
+ if (NIL_P(ary)) {
+ ary = rb_push_glob(str, flags);
+ }
+ else {
+ volatile VALUE v = ary;
+ ary = dir_globs(RARRAY_LEN(v), RARRAY_PTR(v), flags);
+ }
+
+ if (rb_block_given_p()) {
+ rb_ary_each(ary);
+ return Qnil;
+ }
+ return ary;
}
static VALUE
@@ -1534,6 +1860,8 @@ dir_entries(io, dirname)
* have <code>c</code> in them (including at
* the beginning or end). Equivalent to
* <code>/ .* /x</code> in regexp.
+ * <code>**</code>:: Matches directories recursively or files
+ * expansively.
* <code>?</code>:: Matches any one character. Equivalent to
* <code>/.{1}/</code> in regexp.
* <code>[set]</code>:: Matches any one character in +set+.
@@ -1546,31 +1874,52 @@ dir_entries(io, dirname)
* 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('cat', 'cat') #=> true : match entire string
+ * File.fnmatch('cat', 'category') #=> false : only match partial string
+ * File.fnmatch('c{at,ub}s', 'cats') #=> false : { } isn't supported
+ *
+ * File.fnmatch('c?t', 'cat') #=> true : '?' match only 1 character
+ * File.fnmatch('c??t', 'cat') #=> false : ditto
+ * File.fnmatch('c*', 'cats') #=> true : '*' match 0 or more characters
+ * File.fnmatch('c*t', 'c/a/b/t') #=> true : ditto
+ * File.fnmatch('ca[a-z]', 'cat') #=> true : inclusive bracket expression
+ * File.fnmatch('ca[^t]', 'cat') #=> false : exclusive bracket expression ('^' or '!')
+ *
+ * File.fnmatch('cat', 'CAT') #=> false : case sensitive
+ * File.fnmatch('cat', 'CAT', File::FNM_CASEFOLD) #=> true : case insensitive
+ *
+ * File.fnmatch('?', '/', File::FNM_PATHNAME) #=> false : wildcard doesn't match '/' on FNM_PATHNAME
+ * File.fnmatch('*', '/', File::FNM_PATHNAME) #=> false : ditto
+ * File.fnmatch('[/]', '/', File::FNM_PATHNAME) #=> false : ditto
+ *
+ * File.fnmatch('\?', '?') #=> true : escaped wildcard becomes ordinary
+ * File.fnmatch('\a', 'a') #=> true : escaped ordinary remains ordinary
+ * File.fnmatch('\a', '\a', File::FNM_NOESCAPE) #=> true : FNM_NOESACPE makes '\' ordinary
+ * File.fnmatch('[\?]', '?') #=> true : can escape inside bracket expression
+ *
+ * File.fnmatch('*', '.profile') #=> false : wildcard doesn't match leading
+ * File.fnmatch('*', '.profile', File::FNM_DOTMATCH) #=> true period by default.
+ * File.fnmatch('.*', '.profile') #=> true
+ *
+ * rbfiles = '**' '/' '*.rb' # you don't have to do like this. just write in single string.
+ * File.fnmatch(rbfiles, 'main.rb') #=> false
+ * File.fnmatch(rbfiles, './main.rb') #=> false
+ * File.fnmatch(rbfiles, 'lib/song.rb') #=> true
+ * File.fnmatch('**.rb', 'main.rb') #=> true
+ * File.fnmatch('**.rb', './main.rb') #=> false
+ * File.fnmatch('**.rb', 'lib/song.rb') #=> true
+ * File.fnmatch('*', 'dave/.profile') #=> true
*
- * 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
+ * pattern = '*' '/' '*'
+ * File.fnmatch(pattern, 'dave/.profile', File::FNM_PATHNAME) #=> false
+ * File.fnmatch(pattern, 'dave/.profile', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true
*
- * 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
+ * pattern = '**' '/' 'foo'
+ * File.fnmatch(pattern, 'a/b/c/foo', File::FNM_PATHNAME) #=> true
+ * File.fnmatch(pattern, '/a/b/c/foo', File::FNM_PATHNAME) #=> true
+ * File.fnmatch(pattern, 'c:/a/b/c/foo', File::FNM_PATHNAME) #=> true
+ * File.fnmatch(pattern, 'a/.b/c/foo', File::FNM_PATHNAME) #=> false
+ * File.fnmatch(pattern, 'a/.b/c/foo', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true
*/
static VALUE
file_s_fnmatch(argc, argv, obj)
@@ -1640,7 +1989,7 @@ Init_Dir()
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_aref, 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);
diff --git a/dln.c b/dln.c
index fd59bdab8e..b405da6bff 100644
--- a/dln.c
+++ b/dln.c
@@ -2,8 +2,8 @@
dln.c -
- $Author: matz $
- $Date: 2006/08/07 03:43:39 $
+ $Author$
+ $Date$
created at: Tue Jan 18 17:05:06 JST 1994
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -1676,6 +1676,35 @@ dln_find_file(fname, path)
#endif
}
+#if defined(__CYGWIN32__)
+const char *
+conv_to_posix_path(win32, posix, len)
+ char *win32;
+ char *posix;
+ int len;
+{
+ char *first = win32;
+ char *p = win32;
+ char *dst = posix;
+
+ posix[0] = '\0';
+ for (p = win32; *p; p++)
+ if (*p == ';') {
+ *p = 0;
+ cygwin32_conv_to_posix_path(first, posix);
+ posix += strlen(posix);
+ *posix++ = ':';
+ first = p + 1;
+ *p = ';';
+ }
+ if (len < strlen(first))
+ fprintf(stderr, "PATH length too long: %s\n", first);
+ else
+ cygwin32_conv_to_posix_path(first, posix);
+ return dst;
+}
+#endif
+
static char fbuf[MAXPATHLEN];
static char *
diff --git a/dln.h b/dln.h
index 3d52ea2827..182cf9f9f4 100644
--- a/dln.h
+++ b/dln.h
@@ -2,8 +2,8 @@
dln.h -
- $Author: michal $
- $Date: 2003/01/16 07:34:01 $
+ $Author$
+ $Date$
created at: Wed Jan 19 16:53:09 JST 1994
Copyright (C) 1993-2003 Yukihiro Matsumoto
diff --git a/doc/NEWS b/doc/NEWS-1.8.0
index b4445fa59f..b4445fa59f 100644
--- a/doc/NEWS
+++ b/doc/NEWS-1.8.0
diff --git a/doc/forwardable.rd b/doc/forwardable.rd
index f9c8234761..7272c374b6 100644
--- a/doc/forwardable.rd
+++ b/doc/forwardable.rd
@@ -1,8 +1,8 @@
-- forwardable.rb
$Release Version: 1.1 $
- $Revision: 1.2 $
- $Date: 2001/05/07 23:52:57 $
+ $Revision$
+ $Date$
Original version by Tosh
=begin
diff --git a/doc/forwardable.rd.ja b/doc/forwardable.rd.ja
index a56823dd1a..d928fddc5e 100644
--- a/doc/forwardable.rd.ja
+++ b/doc/forwardable.rd.ja
@@ -1,7 +1,7 @@
-- forwatable.rb
$Release Version: 1.1 $
- $Revision: 1.1 $
- $Date: 2001/07/19 05:42:06 $
+ $Revision$
+ $Date$
=begin
= Forwardable
diff --git a/doc/irb/irb-tools.rd.ja b/doc/irb/irb-tools.rd.ja
index 38145576dc..64d9ab29c8 100644
--- a/doc/irb/irb-tools.rd.ja
+++ b/doc/irb/irb-tools.rd.ja
@@ -1,7 +1,7 @@
irb´ØÏ¢¤ª¤Þ¤±¥³¥Þ¥ó¥É¤È¥é¥¤¥Ö¥é¥ê
$Release Version: 0.7.1 $
- $Revision: 1.1 $
- $Date: 2001/07/19 05:42:06 $
+ $Revision$
+ $Date$
by Keiju ISHITSUKA(Nihon Rational Co.,Ltd.)
=begin
diff --git a/doc/irb/irb.rd b/doc/irb/irb.rd
index f56e8b60e0..a42cd46680 100644
--- a/doc/irb/irb.rd
+++ b/doc/irb/irb.rd
@@ -1,7 +1,7 @@
irb -- interactive ruby
$Release Version: 0.9 $
- $Revision: 1.6 $
- $Date: 2003/07/31 16:34:07 $
+ $Revision$
+ $Date$
by Keiju ISHITSUKA(keiju@ishitsuka.com)
by gotoken-san who is original translater from japanese version
diff --git a/doc/irb/irb.rd.ja b/doc/irb/irb.rd.ja
index aa3c0e13aa..338dcc644e 100644
--- a/doc/irb/irb.rd.ja
+++ b/doc/irb/irb.rd.ja
@@ -1,7 +1,7 @@
irb -- interactive ruby
$Release Version: 0.9.5 $
- $Revision: 1.3.2.1 $
- $Date: 2005/04/19 19:24:56 $
+ $Revision$
+ $Date$
by Keiju ISHITSUKA(keiju@ruby-lang.org)
=begin
= irb¤È¤Ï?
diff --git a/doc/shell.rd b/doc/shell.rd
index ae6855cbd8..02ee1b020a 100644
--- a/doc/shell.rd
+++ b/doc/shell.rd
@@ -1,7 +1,7 @@
-- shell.rb
$Release Version: 0.6.0 $
- $Revision: 1.2 $
- $Date: 2001/05/17 10:09:49 $
+ $Revision$
+ $Date$
by Keiju ISHITSUKA(keiju@ishitsuka.com)
=begin
diff --git a/doc/shell.rd.ja b/doc/shell.rd.ja
index aab9e5c7d2..073e71ea42 100644
--- a/doc/shell.rd.ja
+++ b/doc/shell.rd.ja
@@ -1,7 +1,7 @@
-- shell.rb
$Release Version: 0.6.0 $
- $Revision: 1.1 $
- $Date: 2001/07/19 05:42:06 $
+ $Revision$
+ $Date$
by Keiju ISHITSUKA(keiju@ishitsuka.com)
=begin
diff --git a/enum.c b/enum.c
index 112a5f820b..2a29272ae9 100644
--- a/enum.c
+++ b/enum.c
@@ -2,8 +2,8 @@
enum.c -
- $Author: drbrain $
- $Date: 2006/06/15 01:24:40 $
+ $Author$
+ $Date$
created at: Fri Oct 1 15:15:19 JST 1993
Copyright (C) 1993-2003 Yukihiro Matsumoto
diff --git a/env.h b/env.h
index 196090f387..c50103f71e 100644
--- a/env.h
+++ b/env.h
@@ -2,8 +2,8 @@
env.h -
- $Author: matz $
- $Date: 2006/02/13 09:10:55 $
+ $Author$
+ $Date$
created at: Mon Jul 11 11:53:03 JST 1994
Copyright (C) 1993-2003 Yukihiro Matsumoto
diff --git a/error.c b/error.c
index 6ebc927853..44e709276f 100644
--- a/error.c
+++ b/error.c
@@ -2,8 +2,8 @@
error.c -
- $Author: matz $
- $Date: 2006/07/20 07:04:13 $
+ $Author$
+ $Date$
created at: Mon Aug 9 16:11:34 JST 1993
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -488,14 +488,14 @@ static VALUE
exc_backtrace(exc)
VALUE exc;
{
- static ID bt;
+ ID bt = rb_intern("bt");
- if (!bt) bt = rb_intern("bt");
- return rb_attr_get(exc, bt);
+ if (!rb_ivar_defined(exc, bt)) return Qnil;
+ return rb_ivar_get(exc, bt);
}
-VALUE
-rb_check_backtrace(bt)
+static VALUE
+check_backtrace(bt)
VALUE bt;
{
long i;
@@ -532,7 +532,7 @@ exc_set_backtrace(exc, bt)
VALUE exc;
VALUE bt;
{
- return rb_iv_set(exc, "bt", rb_check_backtrace(bt));
+ return rb_iv_set(exc, "bt", check_backtrace(bt));
}
/*
diff --git a/eval.c b/eval.c
index e0a7e17af6..014ee9d9d3 100644
--- a/eval.c
+++ b/eval.c
@@ -2,8 +2,8 @@
eval.c -
- $Author: shyouhei $
- $Date: 2007/01/27 15:45:49 $
+ $Author$
+ $Date$
created at: Thu Jun 10 14:22:17 JST 1993
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -29,11 +29,6 @@
#endif
#include <stdio.h>
-#if defined(HAVE_GETCONTEXT) && defined(HAVE_SETCONTEXT)
-#include <ucontext.h>
-#define USE_CONTEXT
-#endif
-#include <setjmp.h>
#include "st.h"
#include "dln.h"
@@ -90,10 +85,6 @@ char *strrchr _((const char*,const char));
#endif
#ifdef USE_CONTEXT
-typedef struct {
- ucontext_t context;
- volatile int status;
-} rb_jmpbuf_t[1];
NORETURN(static void rb_jump_context(rb_jmpbuf_t, int));
static inline void
@@ -195,18 +186,20 @@ static int volatile freebsd_clear_carry_flag = 0;
# define POST_GETCONTEXT 0
# endif
# define ruby_longjmp(env, val) rb_jump_context(env, val)
-# define ruby_setjmp(j) ((j)->status = 0, \
+# define ruby_setjmp(just_before_setjmp, j) ((j)->status = 0, \
+ (just_before_setjmp), \
PRE_GETCONTEXT, \
getcontext(&(j)->context), \
POST_GETCONTEXT, \
(j)->status)
#else
-typedef jmp_buf rb_jmpbuf_t;
# if !defined(setjmp) && defined(HAVE__SETJMP)
-# define ruby_setjmp(env) _setjmp(env)
+# define ruby_setjmp(just_before_setjmp, env) \
+ ((just_before_setjmp), _setjmp(env))
# define ruby_longjmp(env,val) _longjmp(env,val)
# else
-# define ruby_setjmp(env) setjmp(env)
+# define ruby_setjmp(just_before_setjmp, env) \
+ ((just_before_setjmp), setjmp(env))
# define ruby_longjmp(env,val) longjmp(env,val)
# endif
#endif
@@ -250,6 +243,8 @@ static int scope_vmode;
#define SCOPE_SET(f) (scope_vmode=(f))
#define SCOPE_TEST(f) (scope_vmode&(f))
+VALUE (*ruby_sandbox_save)_((rb_thread_t));
+VALUE (*ruby_sandbox_restore)_((rb_thread_t));
NODE* ruby_current_node;
int ruby_safe_level = 0;
/* safe-level:
@@ -458,8 +453,7 @@ rb_define_alloc_func(klass, func)
VALUE (*func) _((VALUE));
{
Check_Type(klass, T_CLASS);
- rb_add_method(rb_singleton_class(klass), ID_ALLOCATOR, NEW_CFUNC(func, 0),
- NOEX_PRIVATE);
+ rb_add_method(CLASS_OF(klass), ID_ALLOCATOR, NEW_CFUNC(func, 0), NOEX_PRIVATE);
}
void
@@ -467,7 +461,7 @@ rb_undef_alloc_func(klass)
VALUE klass;
{
Check_Type(klass, T_CLASS);
- rb_add_method(rb_singleton_class(klass), ID_ALLOCATOR, 0, NOEX_UNDEF);
+ rb_add_method(CLASS_OF(klass), ID_ALLOCATOR, 0, NOEX_UNDEF);
}
static NODE*
@@ -575,13 +569,8 @@ remove_method(klass, mid)
if (mid == __id__ || mid == __send__ || mid == init) {
rb_warn("removing `%s' may cause serious problem", rb_id2name(mid));
}
- if (st_lookup(RCLASS(klass)->m_tbl, mid, (st_data_t *)&body)) {
- if (!body || !body->nd_body) body = 0;
- else {
- st_delete(RCLASS(klass)->m_tbl, &mid, (st_data_t *)&body);
- }
- }
- if (!body) {
+ 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));
}
@@ -1033,7 +1022,7 @@ static struct tag *prot_tag;
#define PROT_LAMBDA INT2FIX(2) /* 5 */
#define PROT_YIELD INT2FIX(3) /* 7 */
-#define EXEC_TAG() (FLUSH_REGISTER_WINDOWS, ruby_setjmp(prot_tag->buf))
+#define EXEC_TAG() (FLUSH_REGISTER_WINDOWS, ruby_setjmp(((void)0), prot_tag->buf))
#define JUMP_TAG(st) do { \
ruby_frame = prot_tag->frame; \
@@ -1067,8 +1056,8 @@ static VALUE ruby_wrapper; /* security wrapper */
#define POP_CLASS() ruby_class = _class; \
} while (0)
-static NODE *ruby_cref = 0;
-static NODE *top_cref;
+NODE *ruby_cref = 0;
+NODE *ruby_top_cref;
#define PUSH_CREF(c) ruby_cref = NEW_NODE(NODE_CREF,(c),0,ruby_cref)
#define POP_CREF() ruby_cref = ruby_cref->nd_next
@@ -1084,9 +1073,11 @@ static NODE *top_cref;
ruby_scope = _scope; \
scope_vmode = SCOPE_PUBLIC
-typedef struct thread * rb_thread_t;
-static rb_thread_t curr_thread = 0;
-static rb_thread_t main_thread;
+rb_thread_t rb_curr_thread;
+rb_thread_t rb_main_thread;
+#define main_thread rb_main_thread
+#define curr_thread rb_curr_thread
+
static void scope_dup _((struct SCOPE *));
#define POP_SCOPE() \
@@ -1118,7 +1109,7 @@ static VALUE rb_yield_0 _((VALUE, VALUE, VALUE, int, int));
#define YIELD_FUNC_AVALUE 1
#define YIELD_FUNC_SVALUE 2
-static VALUE rb_call _((VALUE,VALUE,ID,int,const VALUE*,int));
+static VALUE rb_call _((VALUE,VALUE,ID,int,const VALUE*,int,VALUE));
static VALUE module_setup _((VALUE,NODE*));
static VALUE massign _((VALUE,NODE*,VALUE,int));
@@ -1206,8 +1197,6 @@ error_pos()
}
}
-VALUE rb_check_backtrace(VALUE);
-
static VALUE
get_backtrace(info)
VALUE info;
@@ -1215,7 +1204,7 @@ get_backtrace(info)
if (NIL_P(info)) return Qnil;
info = rb_funcall(info, rb_intern("backtrace"), 0);
if (NIL_P(info)) return Qnil;
- return rb_check_backtrace(info);
+ return rb_check_array_type(info);
}
static void
@@ -1302,9 +1291,8 @@ error_print()
warn_print2(RSTRING(epath)->ptr, RSTRING(epath)->len);
warn_print(")\n");
}
- if (tail && elen>len+1) {
+ if (tail) {
warn_print2(tail, elen-len-1);
- if (einfo[elen-1] != '\n') warn_print2("\n", 1);
}
}
}
@@ -1400,8 +1388,8 @@ ruby_init()
rb_call_inits();
ruby_class = rb_cObject;
ruby_frame->self = ruby_top_self;
- top_cref = rb_node_newnode(NODE_CREF,rb_cObject,0,0);
- ruby_cref = top_cref;
+ ruby_top_cref = rb_node_newnode(NODE_CREF,rb_cObject,0,0);
+ ruby_cref = ruby_top_cref;
rb_define_global_const("TOPLEVEL_BINDING", rb_f_binding(ruby_top_self));
#ifdef __MACOS__
_macruby_init();
@@ -1446,6 +1434,8 @@ static void rb_thread_wait_other_threads _((void));
static int thread_set_raised();
static int thread_reset_raised();
+static int thread_no_ensure _((void));
+
static VALUE exception_error;
static VALUE sysstack_error;
@@ -1505,6 +1495,9 @@ error_handle(ex)
if (rb_obj_is_kind_of(ruby_errinfo, rb_eSystemExit)) {
status = sysexit_status(ruby_errinfo);
}
+ else if (rb_obj_is_instance_of(ruby_errinfo, rb_eSignal)) {
+ /* no message when exiting by signal */
+ }
else {
error_print();
}
@@ -1572,12 +1565,15 @@ ruby_cleanup(ex)
int ex;
{
int state;
- volatile VALUE err = ruby_errinfo;
+ VALUE err;
+ volatile VALUE errs[2];
+ int nerr;
+ errs[0] = ruby_errinfo;
ruby_safe_level = 0;
Init_stack((void*)&state);
ruby_finalize_0();
- if (ruby_errinfo) err = ruby_errinfo;
+ errs[1] = ruby_errinfo;
PUSH_TAG(PROT_NONE);
PUSH_ITER(ITER_NOT);
if ((state = EXEC_TAG()) == 0) {
@@ -1588,14 +1584,20 @@ ruby_cleanup(ex)
ex = state;
}
POP_ITER();
- ruby_errinfo = err;
+ ruby_errinfo = errs[0];
ex = error_handle(ex);
ruby_finalize_1();
POP_TAG();
- if (err && rb_obj_is_kind_of(err, rb_eSystemExit)) {
- VALUE st = rb_iv_get(err, "status");
- return NUM2INT(st);
+ for (nerr = sizeof(errs) / sizeof(errs[0]); nerr;) {
+ if (!(err = errs[--nerr])) continue;
+ if (rb_obj_is_kind_of(err, rb_eSystemExit)) {
+ return sysexit_status(err);
+ }
+ else if (rb_obj_is_kind_of(err, rb_eSignal)) {
+ VALUE sig = rb_iv_get(err, "signo");
+ ruby_default_signal(NUM2INT(sig));
+ }
}
return ex;
}
@@ -1860,7 +1862,7 @@ rb_eval_cmd(cmd, arg, level)
POP_TAG();
POP_FRAME();
- jump_tag_but_local_jump(state, val);
+ if (state) jump_tag_but_local_jump(state, val);
return val;
}
@@ -2170,9 +2172,6 @@ rb_alias(klass, name, def)
st_insert(RCLASS(klass)->m_tbl, name,
(st_data_t)NEW_METHOD(NEW_FBODY(body, def, origin),
NOEX_WITH_SAFE(orig->nd_noex)));
-
- if (!ruby_running) return;
-
if (singleton) {
rb_funcall(singleton, singleton_added, 1, ID2SYM(name));
}
@@ -2278,7 +2277,7 @@ copy_node_scope(node, rval)
int tmp_iter = ruby_iter->iter;\
switch (tmp_iter) {\
case ITER_PRE:\
- ruby_block = ruby_block->outer;\
+ if (ruby_block) ruby_block = ruby_block->outer;\
case ITER_PAS:\
tmp_iter = ITER_NOT;\
}\
@@ -3193,7 +3192,7 @@ rb_eval(self, n)
END_CALLARGS;
ruby_current_node = node;
SET_CURRENT_SOURCE();
- result = rb_call(CLASS_OF(recv),recv,each,0,0,0);
+ result = rb_call(CLASS_OF(recv),recv,each,0,0,0,self);
}
POP_ITER();
}
@@ -3319,7 +3318,7 @@ rb_eval(self, n)
result = rb_eval(self, node->nd_head);
}
POP_TAG();
- if (node->nd_ensr) {
+ if (node->nd_ensr && !thread_no_ensure()) {
VALUE retval = prot_tag->retval; /* save retval */
VALUE errinfo = ruby_errinfo;
@@ -3434,7 +3433,7 @@ rb_eval(self, n)
ruby_current_node = node;
SET_CURRENT_SOURCE();
- rb_call(CLASS_OF(recv),recv,node->nd_mid,argc,argv,scope);
+ rb_call(CLASS_OF(recv),recv,node->nd_mid,argc,argv,scope,self);
result = argv[argc-1];
}
break;
@@ -3452,7 +3451,7 @@ rb_eval(self, n)
ruby_current_node = node;
SET_CURRENT_SOURCE();
- result = rb_call(CLASS_OF(recv),recv,node->nd_mid,argc,argv,0);
+ result = rb_call(CLASS_OF(recv),recv,node->nd_mid,argc,argv,0,self);
}
break;
@@ -3467,13 +3466,13 @@ rb_eval(self, n)
ruby_current_node = node;
SET_CURRENT_SOURCE();
- result = rb_call(CLASS_OF(self),self,node->nd_mid,argc,argv,1);
+ result = rb_call(CLASS_OF(self),self,node->nd_mid,argc,argv,1,self);
}
break;
case NODE_VCALL:
SET_CURRENT_SOURCE();
- result = rb_call(CLASS_OF(self),self,node->nd_mid,0,0,2);
+ result = rb_call(CLASS_OF(self),self,node->nd_mid,0,0,2,self);
break;
case NODE_SUPER:
@@ -3502,6 +3501,10 @@ rb_eval(self, n)
}
argv = RARRAY(RBASIC(ruby_scope)->klass)->ptr;
}
+ else if (!ruby_scope->local_vars) {
+ argc = 0;
+ argv = 0;
+ }
else {
argv = ruby_scope->local_vars + 2;
}
@@ -4752,7 +4755,7 @@ rb_f_block_given_p()
return Qfalse;
}
-static VALUE rb_eThreadError;
+VALUE rb_eThreadError;
NORETURN(static void proc_jump_error(int, VALUE));
static void
@@ -5271,7 +5274,7 @@ assign(self, lhs, val, pcall)
/* attr set */
ruby_current_node = lhs;
SET_CURRENT_SOURCE();
- rb_call(CLASS_OF(recv), recv, lhs->nd_mid, 1, &val, scope);
+ rb_call(CLASS_OF(recv), recv, lhs->nd_mid, 1, &val, scope, self);
}
else {
/* array set */
@@ -5282,7 +5285,7 @@ assign(self, lhs, val, pcall)
ruby_current_node = lhs;
SET_CURRENT_SOURCE();
rb_call(CLASS_OF(recv), recv, lhs->nd_mid,
- RARRAY(args)->len, RARRAY(args)->ptr, scope);
+ RARRAY(args)->len, RARRAY(args)->ptr, scope, self);
}
}
break;
@@ -5303,9 +5306,9 @@ rb_iterate(it_proc, data1, bl_proc, data2)
NODE *node = NEW_IFUNC(bl_proc, data2);
VALUE self = ruby_top_self;
- PUSH_ITER(ITER_PRE);
PUSH_TAG(PROT_LOOP);
PUSH_BLOCK(0, node);
+ PUSH_ITER(ITER_PRE);
state = EXEC_TAG();
if (state == 0) {
iter_retry:
@@ -5319,9 +5322,9 @@ rb_iterate(it_proc, data1, bl_proc, data2)
state = 0;
goto iter_retry;
}
+ POP_ITER();
POP_BLOCK();
POP_TAG();
- POP_ITER();
switch (state) {
case 0:
@@ -5467,7 +5470,9 @@ rb_ensure(b_proc, data1, e_proc, data2)
}
POP_TAG();
retval = prot_tag ? prot_tag->retval : Qnil; /* save retval */
+ if (!thread_no_ensure()) {
(*e_proc)(data2);
+ }
if (prot_tag) return_value(retval);
if (state) JUMP_TAG(state);
return result;
@@ -5753,7 +5758,7 @@ rb_call0(klass, recv, id, oid, argc, argv, body, flags)
volatile int safe = -1;
if (NOEX_SAFE(flags) > ruby_safe_level &&
- ruby_safe_level == 0 && NOEX_SAFE(flags) > 2) {
+ !(flags&NOEX_TAINTED) && ruby_safe_level == 0 && NOEX_SAFE(flags) > 2) {
rb_raise(rb_eSecurityError, "calling insecure method: %s",
rb_id2name(id));
}
@@ -5940,14 +5945,21 @@ rb_call0(klass, recv, id, oid, argc, argv, body, flags)
while (opt && argc) {
assign(recv, opt->nd_head, *argv, 1);
argv++; argc--;
+ ++i;
opt = opt->nd_next;
}
if (opt) {
rb_eval(recv, opt);
+ while (opt) {
+ opt = opt->nd_next;
+ ++i;
+ }
}
+ }
+ if (!node->nd_rest) {
i = nopt;
}
- if (node->nd_rest) {
+ else {
VALUE v;
if (argc > 0) {
@@ -6008,12 +6020,13 @@ rb_call0(klass, recv, id, oid, argc, argv, body, flags)
}
static VALUE
-rb_call(klass, recv, mid, argc, argv, scope)
+rb_call(klass, recv, mid, argc, argv, scope, self)
VALUE klass, recv;
ID mid;
int argc; /* OK */
const VALUE *argv; /* OK */
int scope;
+ VALUE self;
{
NODE *body; /* OK */
int noex;
@@ -6050,10 +6063,11 @@ rb_call(klass, recv, mid, argc, argv, scope)
if (noex & NOEX_PROTECTED) {
VALUE defined_class = klass;
+ if (self == Qundef) self = ruby_frame->self;
if (TYPE(defined_class) == T_ICLASS) {
defined_class = RBASIC(defined_class)->klass;
}
- if (!rb_obj_is_kind_of(ruby_frame->self, rb_class_real(defined_class)))
+ if (!rb_obj_is_kind_of(self, rb_class_real(defined_class)))
return method_missing(recv, mid, argc, argv, CSTAT_PROT);
}
}
@@ -6073,7 +6087,7 @@ rb_apply(recv, mid, args)
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);
+ return rb_call(CLASS_OF(recv), recv, mid, argc, argv, 1, Qundef);
}
/*
@@ -6106,7 +6120,7 @@ rb_f_send(argc, argv, recv)
vid = *argv++; argc--;
PUSH_ITER(rb_block_given_p()?ITER_PRE:ITER_NOT);
- vid = rb_call(CLASS_OF(recv), recv, rb_to_id(vid), argc, argv, 1);
+ vid = rb_call(CLASS_OF(recv), recv, rb_to_id(vid), argc, argv, 1, Qundef);
POP_ITER();
return vid;
@@ -6135,7 +6149,7 @@ vafuncall(recv, mid, n, ar)
argv = 0;
}
- return rb_call(CLASS_OF(recv), recv, mid, n, argv, 1);
+ return rb_call(CLASS_OF(recv), recv, mid, n, argv, 1, Qundef);
}
VALUE
@@ -6194,7 +6208,7 @@ rb_funcall2(recv, mid, argc, argv)
int argc;
const VALUE *argv;
{
- return rb_call(CLASS_OF(recv), recv, mid, argc, argv, 1);
+ return rb_call(CLASS_OF(recv), recv, mid, argc, argv, 1, Qundef);
}
VALUE
@@ -6204,7 +6218,7 @@ rb_funcall3(recv, mid, argc, argv)
int argc;
const VALUE *argv;
{
- return rb_call(CLASS_OF(recv), recv, mid, argc, argv, 0);
+ return rb_call(CLASS_OF(recv), recv, mid, argc, argv, 0, Qundef);
}
VALUE
@@ -6226,7 +6240,7 @@ rb_call_super(argc, argv)
}
PUSH_ITER(ruby_iter->iter ? ITER_PRE : ITER_NOT);
- result = rb_call(RCLASS(klass)->super, self, ruby_frame->orig_func, argc, argv, 3);
+ result = rb_call(RCLASS(klass)->super, self, ruby_frame->orig_func, argc, argv, 3, Qundef);
POP_ITER();
return result;
@@ -6491,17 +6505,16 @@ eval(self, src, scope, file, line)
if (state) {
if (state == TAG_RAISE) {
if (strcmp(file, "(eval)") == 0) {
- VALUE mesg, errat, bt2;
+ 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 &&
- (bt2 = backtrace(-2), RARRAY(bt2)->len > 0)) {
+ 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(bt2)->ptr[0];
+ RARRAY(errat)->ptr[0] = RARRAY(backtrace(-2))->ptr[0];
}
}
rb_exc_raise(ruby_errinfo);
@@ -6811,7 +6824,7 @@ rb_load(fname, wrap)
ruby_errinfo = Qnil; /* ensure */
PUSH_VARS();
PUSH_CLASS(ruby_wrapper);
- ruby_cref = top_cref;
+ ruby_cref = ruby_top_cref;
if (!wrap) {
rb_secure(4); /* should alter global state */
ruby_class = rb_cObject;
@@ -6937,13 +6950,25 @@ static st_table *loading_tbl;
#define IS_DLEXT(e) (strcmp(e, DLEXT) == 0)
#endif
-static char *
+
+static const char *const loadable_ext[] = {
+ ".rb", DLEXT,
+#ifdef DLEXT2
+ DLEXT2,
+#endif
+ 0
+};
+
+static int rb_feature_p _((const char *, const char *, int));
+static int search_required _((VALUE, VALUE *, VALUE *));
+
+static int
rb_feature_p(feature, ext, rb)
const char *feature, *ext;
int rb;
{
VALUE v;
- char *f, *e;
+ const char *f, *e;
long i, len, elen;
if (ext) {
@@ -6954,51 +6979,64 @@ rb_feature_p(feature, ext, rb)
len = strlen(feature);
elen = 0;
}
- for (i = 0; i < RARRAY(rb_features)->len; ++i) {
- v = RARRAY(rb_features)->ptr[i];
+ for (i = 0; i < RARRAY_LEN(rb_features); ++i) {
+ v = RARRAY_PTR(rb_features)[i];
f = StringValuePtr(v);
- if (strncmp(f, feature, len) != 0) continue;
+ if (RSTRING_LEN(v) < len || strncmp(f, feature, len) != 0)
+ continue;
if (!*(e = f + len)) {
if (ext) continue;
- return e;
+ return 'u';
}
if (*e != '.') continue;
if ((!rb || !ext) && (IS_SOEXT(e) || IS_DLEXT(e))) {
- return e;
+ return 's';
}
if ((rb || !ext) && (strcmp(e, ".rb") == 0)) {
- return e;
+ return 'r';
+ }
+ }
+ if (loading_tbl) {
+ if (st_lookup(loading_tbl, (st_data_t)feature, 0)) {
+ if (!ext) return 'u';
+ return strcmp(ext, ".rb") ? 's' : 'r';
+ }
+ else {
+ char *buf;
+
+ if (ext && *ext) return 0;
+ buf = ALLOCA_N(char, len + DLEXT_MAXLEN + 1);
+ MEMCPY(buf, feature, char, len);
+ for (i = 0; (e = loadable_ext[i]) != 0; i++) {
+ strncpy(buf + len, e, DLEXT_MAXLEN + 1);
+ if (st_lookup(loading_tbl, (st_data_t)buf, 0)) {
+ return i ? 's' : 'r';
+ }
+ }
}
}
return 0;
}
-static const char *const loadable_ext[] = {
- ".rb", DLEXT,
-#ifdef DLEXT2
- DLEXT2,
-#endif
- 0
-};
-
int
rb_provided(feature)
const char *feature;
{
- int i;
- char *buf;
+ const char *ext = strrchr(feature, '.');
- 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;
+ if (ext && !strchr(ext, '/')) {
+ if (strcmp(".rb", ext) == 0) {
+ if (rb_feature_p(feature, ext, Qtrue)) return Qtrue;
+ return Qfalse;
+ }
+ else if (IS_SOEXT(ext) || IS_DLEXT(ext)) {
+ if (rb_feature_p(feature, ext, Qfalse)) return Qtrue;
+ return Qfalse;
+ }
}
+ if (rb_feature_p(feature, feature + strlen(feature), Qtrue))
+ return Qtrue;
+
return Qfalse;
}
@@ -7016,19 +7054,41 @@ rb_provide(feature)
rb_provide_feature(rb_str_new2(feature));
}
-static int
-load_wait(ftptr)
- char *ftptr;
+static char *
+load_lock(ftptr)
+ const char *ftptr;
{
st_data_t th;
- if (!loading_tbl) return Qfalse;
- if (!st_lookup(loading_tbl, (st_data_t)ftptr, &th)) return Qfalse;
+ if (!loading_tbl ||
+ !st_lookup(loading_tbl, (st_data_t)ftptr, &th))
+ {
+ /* loading ruby library should be serialized. */
+ if (!loading_tbl) {
+ loading_tbl = st_init_strtable();
+ }
+ /* partial state */
+ ftptr = ruby_strdup(ftptr);
+ st_insert(loading_tbl, (st_data_t)ftptr, (st_data_t)curr_thread);
+ return (char *)ftptr;
+ }
do {
- if ((rb_thread_t)th == curr_thread) return Qtrue;
+ if ((rb_thread_t)th == curr_thread) return 0;
CHECK_INTS;
} while (st_lookup(loading_tbl, (st_data_t)ftptr, &th));
- return Qtrue;
+ return 0;
+}
+
+static void
+load_unlock(const char *ftptr)
+{
+ if (ftptr) {
+ st_data_t key = (st_data_t)ftptr;
+
+ if (st_delete(loading_tbl, &key, 0)) {
+ free((char *)key);
+ }
+ }
}
/*
@@ -7070,16 +7130,16 @@ search_required(fname, featurep, path)
*featurep = fname;
*path = 0;
- ext = strrchr(ftptr = RSTRING(fname)->ptr, '.');
+ ext = strrchr(ftptr = RSTRING_PTR(fname), '.');
if (ext && !strchr(ext, '/')) {
if (strcmp(".rb", ext) == 0) {
if (rb_feature_p(ftptr, ext, Qtrue)) return 'r';
- if (*path = rb_find_file(fname)) return 'r';
+ if ((*path = rb_find_file(fname)) != 0) 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);
+ tmp = rb_str_new(RSTRING_PTR(fname), ext-RSTRING_PTR(fname));
*featurep = tmp;
#ifdef DLEXT2
OBJ_FREEZE(tmp);
@@ -7098,20 +7158,18 @@ search_required(fname, featurep, path)
}
else if (IS_DLEXT(ext)) {
if (rb_feature_p(ftptr, ext, Qfalse)) return 's';
- if (*path = rb_find_file(fname)) return 's';
+ if ((*path = rb_find_file(fname)) != 0) return 's';
}
}
tmp = fname;
- switch (type = rb_find_file_ext(&tmp, loadable_ext)) {
+ type = rb_find_file_ext(&tmp, loadable_ext);
+ *featurep = tmp;
+ switch (type) {
case 0:
- if ((ext = rb_feature_p(ftptr, 0, Qfalse))) {
- type = strcmp(".rb", ext);
- break;
- }
- return 0;
+ ftptr = RSTRING_PTR(tmp);
+ return rb_feature_p(ftptr, 0, Qfalse);
default:
- *featurep = tmp;
ext = strrchr(ftptr = RSTRING(tmp)->ptr, '.');
if (rb_feature_p(ftptr, ext, !--type)) break;
*path = rb_find_file(tmp);
@@ -7159,20 +7217,13 @@ rb_require_safe(fname, safe)
ruby_safe_level = safe;
found = search_required(fname, &feature, &path);
if (found) {
- if (!path || load_wait(RSTRING(feature)->ptr)) {
+ if (!path || !(ftptr = load_lock(RSTRING_PTR(feature)))) {
result = Qfalse;
}
else {
ruby_safe_level = 0;
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;
@@ -7197,11 +7248,7 @@ rb_require_safe(fname, safe)
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);
- }
- }
+ load_unlock(ftptr);
if (state) JUMP_TAG(state);
if (NIL_P(result)) {
load_failed(fname);
@@ -7220,6 +7267,24 @@ rb_require(fname)
return rb_require_safe(fn, ruby_safe_level);
}
+void
+ruby_init_ext(name, init)
+ const char *name;
+ void (*init) _((void));
+{
+ ruby_current_node = 0;
+ ruby_sourcefile = rb_source_filename(name);
+ ruby_sourceline = 0;
+ ruby_frame->last_func = 0;
+ ruby_frame->orig_func = 0;
+ SCOPE_SET(SCOPE_PUBLIC);
+ if (load_lock(name)) {
+ (*init)();
+ rb_provide(name);
+ load_unlock(name);
+ }
+}
+
static void
secure_visibility(self)
VALUE self;
@@ -8923,7 +8988,7 @@ mnew(klass, obj, id, mklass)
data->body = body;
data->rklass = rklass;
data->oid = oid;
- data->safe_level = NOEX_WITH_SAFE(noex);
+ data->safe_level = NOEX_WITH_SAFE(0);
OBJ_INFECT(method, klass);
return method;
@@ -9564,14 +9629,14 @@ rb_mod_define_method(argc, argv, mod)
rb_raise(rb_eTypeError, "wrong argument type (expected Proc/Method)");
}
- if (SCOPE_TEST(SCOPE_PRIVATE)) {
- noex = NOEX_PRIVATE;
- }
- else if (SCOPE_TEST(SCOPE_PROTECTED)) {
- noex = NOEX_PROTECTED;
- }
- else {
- noex = NOEX_PUBLIC;
+ noex = NOEX_PUBLIC;
+ if (ruby_cbase == mod) {
+ if (SCOPE_TEST(SCOPE_PRIVATE)) {
+ noex = NOEX_PRIVATE;
+ }
+ else if (SCOPE_TEST(SCOPE_PROTECTED)) {
+ noex = NOEX_PROTECTED;
+ }
}
rb_add_method(mod, id, node, noex);
return body;
@@ -9699,19 +9764,6 @@ Init_Binding()
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__
@@ -9776,13 +9828,6 @@ VALUE rb_cThread;
extern VALUE rb_last_status;
-enum thread_status {
- THREAD_TO_KILL,
- THREAD_RUNNABLE,
- THREAD_STOPPED,
- THREAD_KILLED,
-};
-
#define WAIT_FD (1<<0)
#define WAIT_SELECT (1<<1)
#define WAIT_TIME (1<<2)
@@ -9800,70 +9845,10 @@ enum thread_status {
# endif
#endif
-/* typedef struct thread * rb_thread_t; */
-
-struct thread {
- struct thread *next, *prev;
- rb_jmpbuf_t context;
-#ifdef SAVE_WIN32_EXCEPTION_LIST
- DWORD win32_exception_list;
-#endif
-
- VALUE result;
-
- 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;
- struct RVarmap *dyna_vars;
- struct BLOCK *block;
- struct iter *iter;
- struct tag *tag;
- VALUE klass;
- VALUE wrapper;
- NODE *cref;
-
- int flags; /* misc. states (vmode/rb_trap_immediate/raised) */
-
- 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;
-
- int abort;
- int priority;
- VALUE thgroup;
-
- st_table *locals;
-
- VALUE thread;
-};
-
#define THREAD_RAISED 0x200 /* temporary flag */
#define THREAD_TERMINATING 0x400 /* persistent flag */
-#define THREAD_FLAGS_MASK 0x400 /* mask for persistent flags */
+#define THREAD_NO_ENSURE 0x800 /* persistent flag */
+#define THREAD_FLAGS_MASK 0xc00 /* mask for persistent flags */
#define FOREACH_THREAD_FROM(f,x) x = f; do { x = x->next;
#define END_FOREACH_FROM(f,x) } while (x != f)
@@ -9882,7 +9867,7 @@ struct thread_status_t {
int safe;
- enum thread_status status;
+ enum rb_thread_status status;
int wait_for;
int fd;
fd_set readfds;
@@ -9931,6 +9916,12 @@ thread_reset_raised()
return 1;
}
+static int
+thread_no_ensure()
+{
+ return ((curr_thread->flags & THREAD_NO_ENSURE) == THREAD_NO_ENSURE);
+}
+
static void rb_thread_ready _((rb_thread_t));
static VALUE run_trap_eval _((VALUE));
@@ -9978,7 +9969,7 @@ rb_trap_eval(cmd, sig, safe)
static const char *
thread_status_name(status)
- enum thread_status status;
+ enum rb_thread_status status;
{
switch (status) {
case THREAD_RUNNABLE:
@@ -10061,6 +10052,7 @@ thread_mark(th)
rb_gc_mark(th->last_match);
rb_mark_tbl(th->locals);
rb_gc_mark(th->thgroup);
+ rb_gc_mark_maybe(th->sandbox);
/* mark data in copied stack */
if (th == curr_thread) return;
@@ -10071,9 +10063,9 @@ 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__
+#ifdef __ia64
if (th->bstr_ptr) {
- rb_gc_mark_locations(th->bstr_ptr, th->bstr_ptr+th->bstr_len);
+ rb_gc_mark_locations(th->bstr_ptr, th->bstr_ptr+th->bstr_len);
}
#endif
}
@@ -10159,7 +10151,7 @@ thread_free(th)
{
if (th->stk_ptr) free(th->stk_ptr);
th->stk_ptr = 0;
-#ifdef __ia64__
+#ifdef __ia64
if (th->bstr_ptr) free(th->bstr_ptr);
th->bstr_ptr = 0;
#endif
@@ -10188,7 +10180,6 @@ static VALUE th_raise_exception;
static NODE *th_raise_node;
static VALUE th_cmd;
static int th_sig, th_safe;
-static char *th_signm;
#define RESTORE_NORMAL 1
#define RESTORE_FATAL 2
@@ -10199,6 +10190,9 @@ static char *th_signm;
#define RESTORE_EXIT 7
extern VALUE *rb_gc_stack_start;
+#ifdef __ia64
+extern VALUE *rb_gc_register_stack_start;
+#endif
static void
rb_thread_save_context(th)
@@ -10220,22 +10214,19 @@ rb_thread_save_context(th)
th->stk_len = len;
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);
- }
+#ifdef __ia64
+ th->bstr_pos = rb_gc_register_stack_start;
+ len = (VALUE*)rb_ia64_bsp() - th->bstr_pos;
+ th->bstr_len = 0;
+ if (len > th->bstr_max) {
+ VALUE *ptr = realloc(th->bstr_ptr, sizeof(VALUE) * len);
+ if (!ptr) rb_memerror();
+ th->bstr_ptr = ptr;
+ th->bstr_max = len;
+ }
+ th->bstr_len = len;
+ rb_ia64_flushrs();
+ MEMCPY(th->bstr_ptr, th->bstr_pos, VALUE, th->bstr_len);
#endif
#ifdef SAVE_WIN32_EXCEPTION_LIST
th->win32_exception_list = win32_get_exception_list();
@@ -10265,6 +10256,10 @@ rb_thread_save_context(th)
th->safe = ruby_safe_level;
th->node = ruby_current_node;
+ if (ruby_sandbox_save != NULL)
+ {
+ ruby_sandbox_save(th);
+ }
}
static int
@@ -10290,7 +10285,7 @@ rb_thread_switch(n)
rb_raise_jump(th_raise_exception);
break;
case RESTORE_SIGNAL:
- rb_raise(rb_eSignal, "SIG%s", th_signm);
+ rb_thread_signal_raise(th_sig);
break;
case RESTORE_EXIT:
ruby_errinfo = th_raise_exception;
@@ -10308,53 +10303,24 @@ rb_thread_switch(n)
}
#define THREAD_SAVE_CONTEXT(th) \
- (rb_thread_save_context(th),\
- rb_thread_switch((FLUSH_REGISTER_WINDOWS, ruby_setjmp((th)->context))))
+ (rb_thread_switch((FLUSH_REGISTER_WINDOWS, ruby_setjmp(rb_thread_save_context(th), (th)->context))))
NORETURN(static void rb_thread_restore_context _((rb_thread_t,int)));
-
-# if defined(_MSC_VER) && _MSC_VER >= 1300
-__declspec(noinline) static void stack_extend(rb_thread_t, int);
-# endif
-static void
-stack_extend(th, exit)
- rb_thread_t th;
- int exit;
-{
- VALUE space[1024];
-
- memset(space, 0, 1); /* prevent array from optimization */
- rb_thread_restore_context(th, exit);
-}
+NORETURN(NOINLINE(static void rb_thread_restore_context_0(rb_thread_t,int,void*)));
+NORETURN(NOINLINE(static void stack_extend(rb_thread_t, int, VALUE *)));
static void
-rb_thread_restore_context(th, exit)
- rb_thread_t th;
- int exit;
+rb_thread_restore_context_0(rb_thread_t th, int exit, void *vp)
{
- 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);
- }
- else {
- /* Stack grows upward */
- if (&v < th->stk_pos + th->stk_len) stack_extend(th, exit);
- }
-#endif
-
rb_trap_immediate = 0; /* inhibit interrupts from here */
+ if (ruby_sandbox_restore != NULL)
+ {
+ ruby_sandbox_restore(th);
+ }
ruby_frame = th->frame;
ruby_scope = th->scope;
ruby_class = th->klass;
@@ -10379,8 +10345,8 @@ rb_thread_restore_context(th, exit)
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);
+#ifdef __ia64
+ MEMCPY(tmp->bstr_pos, tmp->bstr_ptr, VALUE, tmp->bstr_len);
#endif
tval = rb_lastline_get();
@@ -10393,6 +10359,78 @@ rb_thread_restore_context(th, exit)
ruby_longjmp(tmp->context, ex);
}
+#ifdef __ia64
+#define C(a) rse_##a##0, rse_##a##1, rse_##a##2, rse_##a##3, rse_##a##4
+#define E(a) rse_##a##0= rse_##a##1= rse_##a##2= rse_##a##3= rse_##a##4
+static volatile int C(a), C(b), C(c), C(d), C(e);
+static volatile int C(f), C(g), C(h), C(i), C(j);
+static volatile int C(k), C(l), C(m), C(n), C(o);
+static volatile int C(p), C(q), C(r), C(s), C(t);
+int rb_dummy_false = 0;
+NORETURN(NOINLINE(static void register_stack_extend(rb_thread_t, int, void *, VALUE *)));
+static void
+register_stack_extend(rb_thread_t th, int exit, void *vp, VALUE *curr_bsp)
+{
+ if (rb_dummy_false) {
+ /* use registers as much as possible */
+ E(a) = E(b) = E(c) = E(d) = E(e) =
+ E(f) = E(g) = E(h) = E(i) = E(j) =
+ E(k) = E(l) = E(m) = E(n) = E(o) =
+ E(p) = E(q) = E(r) = E(s) = E(t) = 0;
+ E(a) = E(b) = E(c) = E(d) = E(e) =
+ E(f) = E(g) = E(h) = E(i) = E(j) =
+ E(k) = E(l) = E(m) = E(n) = E(o) =
+ E(p) = E(q) = E(r) = E(s) = E(t) = 0;
+ }
+ if (curr_bsp < th->bstr_pos+th->bstr_len) {
+ register_stack_extend(th, exit, &exit, (VALUE*)rb_ia64_bsp());
+ }
+ rb_thread_restore_context_0(th, exit, &exit);
+}
+#undef C
+#undef E
+#endif
+
+# if defined(_MSC_VER) && _MSC_VER >= 1300
+__declspec(noinline) static void stack_extend(rb_thread_t, int, VALUE*);
+# endif
+static void
+stack_extend(rb_thread_t th, int exit, VALUE *addr_in_prev_frame)
+{
+#define STACK_PAD_SIZE 1024
+ VALUE space[STACK_PAD_SIZE];
+
+#if STACK_GROW_DIRECTION < 0
+ if (addr_in_prev_frame > th->stk_pos) stack_extend(th, exit, &space[0]);
+#elif STACK_GROW_DIRECTION > 0
+ if (addr_in_prev_frame < th->stk_pos + th->stk_len) stack_extend(th, exit, &space[STACK_PAD_SIZE-1]);
+#else
+ if (addr_in_prev_frame < rb_gc_stack_start) {
+ /* Stack grows downward */
+ if (addr_in_prev_frame > th->stk_pos) stack_extend(th, exit, &space[0]);
+ }
+ else {
+ /* Stack grows upward */
+ if (addr_in_prev_frame < th->stk_pos + th->stk_len) stack_extend(th, exit, &space[STACK_PAD_SIZE-1]);
+ }
+#endif
+#ifdef __ia64
+ register_stack_extend(th, exit, space, (VALUE*)rb_ia64_bsp());
+#else
+ rb_thread_restore_context_0(th, exit, space);
+#endif
+}
+
+static void
+rb_thread_restore_context(th, exit)
+ rb_thread_t th;
+ int exit;
+{
+ VALUE v;
+ if (!th->stk_ptr) rb_bug("unsaved context");
+ stack_extend(th, exit, &v);
+}
+
static void
rb_thread_ready(th)
rb_thread_t th;
@@ -10989,7 +11027,7 @@ rb_thread_join(th, limit)
rb_thread_t th;
double limit;
{
- enum thread_status last_status = THREAD_RUNNABLE;
+ enum rb_thread_status last_status = THREAD_RUNNABLE;
if (rb_thread_critical) rb_thread_deadlock();
if (!rb_thread_dead(th)) {
@@ -11179,10 +11217,19 @@ VALUE
rb_thread_wakeup(thread)
VALUE thread;
{
+ if (!RTEST(rb_thread_wakeup_alive(thread)))
+ rb_raise(rb_eThreadError, "killed thread");
+ return thread;
+}
+
+VALUE
+rb_thread_wakeup_alive(thread)
+ VALUE thread;
+{
rb_thread_t th = rb_thread_check(thread);
if (th->status == THREAD_KILLED)
- rb_raise(rb_eThreadError, "killed thread");
+ return Qnil;
rb_thread_ready(th);
return thread;
@@ -11220,16 +11267,34 @@ rb_thread_run(thread)
}
+static void
+kill_thread(th, flags)
+ rb_thread_t th;
+ int flags;
+{
+ if (th != curr_thread && th->safe < 4) {
+ rb_secure(4);
+ }
+ if (th->status == THREAD_TO_KILL || th->status == THREAD_KILLED)
+ return;
+ if (th == th->next || th == main_thread) rb_exit(EXIT_SUCCESS);
+
+ rb_thread_ready(th);
+ th->flags |= flags;
+ th->status = THREAD_TO_KILL;
+ if (!rb_thread_critical) rb_thread_schedule();
+}
+
+
/*
* call-seq:
- * thr.exit => thr or nil
- * thr.kill => thr or nil
- * thr.terminate => thr or nil
+ * thr.exit => thr
+ * thr.kill => thr
+ * thr.terminate => thr
*
- * 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.
+ * Terminates <i>thr</i> and schedules another thread to be run, returning
+ * the terminated <code>Thread</code>. If this is the main thread, or the
+ * last thread, exits the process.
*/
VALUE
@@ -11238,22 +11303,35 @@ rb_thread_kill(thread)
{
rb_thread_t th = rb_thread_check(thread);
- if (th != curr_thread && th->safe < 4) {
- rb_secure(4);
- }
- if (th->status == THREAD_TO_KILL || th->status == THREAD_KILLED)
- return thread;
- if (th == th->next || th == main_thread) rb_exit(EXIT_SUCCESS);
-
- rb_thread_ready(th);
- th->status = THREAD_TO_KILL;
- if (!rb_thread_critical) rb_thread_schedule();
+ kill_thread(th, 0);
return thread;
}
/*
* call-seq:
+ * thr.exit! => thr
+ * thr.kill! => thr
+ * thr.terminate! => thr
+ *
+ * Terminates <i>thr</i> without calling ensure clauses and schedules
+ * another thread to be run, returning the terminated <code>Thread</code>.
+ * If this is the main thread, or the last thread, exits the process.
+ *
+ * See <code>Thread#exit</code> for the safer version.
+ */
+
+static VALUE
+rb_thread_kill_bang(thread)
+ VALUE thread;
+{
+ rb_thread_t th = rb_thread_check(thread);
+ kill_thread(th, THREAD_NO_ENSURE);
+ return thread;
+}
+
+/*
+ * call-seq:
* Thread.kill(thread) => thread
*
* Causes the given <em>thread</em> to exit (see <code>Thread::exit</code>).
@@ -11341,7 +11419,7 @@ rb_thread_pass()
VALUE
rb_thread_stop()
{
- enum thread_status last_status = THREAD_RUNNABLE;
+ enum rb_thread_status last_status = THREAD_RUNNABLE;
rb_thread_critical = 0;
if (curr_thread == curr_thread->next) {
@@ -11406,10 +11484,12 @@ rb_thread_sleep_forever()
/*
* call-seq:
* thr.priority => integer
- *
- * Returns the priority of <i>thr</i>. Default is zero; higher-priority threads
- * will run before lower-priority threads.
- *
+ *
+ * Returns the priority of <i>thr</i>. Default is inherited from the
+ * current thread which creating the new thread, or zero for the
+ * initial main thread; higher-priority threads will run before
+ * lower-priority threads.
+ *
* Thread.current.priority #=> 0
*/
@@ -11424,10 +11504,10 @@ rb_thread_priority(thread)
/*
* 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 }
@@ -11577,6 +11657,15 @@ rb_thread_abort_exc_set(thread, val)
}
+enum rb_thread_status
+rb_thread_status(thread)
+ VALUE thread;
+{
+ rb_thread_t th = rb_thread_check(thread);
+ return th->status;
+}
+
+
/*
* call-seq:
* thr.group => thgrp or nil
@@ -11598,14 +11687,14 @@ rb_thread_group(thread)
return group;
}
-#ifdef __ia64__
+#ifdef __ia64
# define IA64_INIT(x) x
#else
# define IA64_INIT(x)
#endif
#define THREAD_ALLOC(th) do {\
- th = ALLOC(struct thread);\
+ th = ALLOC(struct rb_thread);\
\
th->next = 0;\
th->prev = 0;\
@@ -11620,6 +11709,7 @@ rb_thread_group(thread)
th->wait_for = 0;\
IA64_INIT(th->bstr_ptr = 0);\
IA64_INIT(th->bstr_len = 0);\
+ IA64_INIT(th->bstr_max = 0);\
FD_ZERO(&th->readfds);\
FD_ZERO(&th->writefds);\
FD_ZERO(&th->exceptfds);\
@@ -11645,6 +11735,11 @@ rb_thread_group(thread)
th->thgroup = thgroup_default;\
th->locals = 0;\
th->thread = 0;\
+ if (curr_thread == 0) {\
+ th->sandbox = Qnil;\
+ } else {\
+ th->sandbox = curr_thread->sandbox;\
+ }\
} while (0)
static rb_thread_t
@@ -11677,21 +11772,36 @@ catch_timer(sig)
/* cause EINTR */
}
+static int time_thread_alive_p = 0;
static pthread_t time_thread;
static void*
thread_timer(dummy)
void *dummy;
{
+#ifdef _THREAD_SAFE
+#define test_cancel() pthread_testcancel()
+#else
+#define test_cancel() /* void */
+#endif
+
+ sigset_t all_signals;
+
+ sigfillset(&all_signals);
+ pthread_sigmask(SIG_BLOCK, &all_signals, 0);
+
for (;;) {
#ifdef HAVE_NANOSLEEP
struct timespec req, rem;
+ test_cancel();
req.tv_sec = 0;
req.tv_nsec = 10000000;
nanosleep(&req, &rem);
#else
struct timeval tv;
+
+ test_cancel();
tv.tv_sec = 0;
tv.tv_usec = 10000;
select(0, NULL, NULL, NULL, &tv);
@@ -11703,6 +11813,7 @@ thread_timer(dummy)
}
}
}
+#undef test_cancel
}
void
@@ -11714,6 +11825,20 @@ void
rb_thread_stop_timer()
{
}
+
+void
+rb_thread_cancel_timer()
+{
+#ifdef _THREAD_SAFE
+ if( time_thread_alive_p )
+ {
+ pthread_cancel( time_thread );
+ pthread_join( time_thread, NULL );
+ time_thread_alive_p = 0;
+ }
+ thread_init = 0;
+#endif
+}
#elif defined(HAVE_SETITIMER)
static void
catch_timer(sig)
@@ -11751,6 +11876,12 @@ rb_thread_stop_timer()
tval.it_value = tval.it_interval;
setitimer(ITIMER_VIRTUAL, &tval, NULL);
}
+
+void
+rb_thread_cancel_timer()
+{
+}
+
#else /* !(_THREAD_SAFE || HAVE_SETITIMER) */
int rb_thread_tick = THREAD_TICK;
#endif
@@ -11764,7 +11895,7 @@ rb_thread_start_0(fn, arg, th)
volatile rb_thread_t th_save = th;
volatile VALUE thread = th->thread;
struct BLOCK *volatile saved_block = 0;
- enum thread_status status;
+ enum rb_thread_status status;
int state;
if (OBJ_FROZEN(curr_thread->thgroup)) {
@@ -11783,6 +11914,7 @@ rb_thread_start_0(fn, arg, th)
#ifdef _THREAD_SAFE
pthread_create(&time_thread, 0, thread_timer, 0);
+ time_thread_alive_p = 1;
#else
rb_thread_start_timer();
#endif
@@ -12047,7 +12179,7 @@ rb_thread_value(thread)
*/
static VALUE
-rb_thread_status(thread)
+rb_thread_status_name(thread)
VALUE thread;
{
rb_thread_t th = rb_thread_check(thread);
@@ -12074,7 +12206,7 @@ rb_thread_status(thread)
* thr.alive? #=> false
*/
-static VALUE
+VALUE
rb_thread_alive_p(thread)
VALUE thread;
{
@@ -12211,13 +12343,15 @@ rb_thread_interrupt()
void
rb_thread_signal_raise(sig)
- char *sig;
+ int sig;
{
- if (sig == 0) return; /* should not happen */
rb_thread_critical = 0;
if (curr_thread == main_thread) {
+ VALUE argv[1];
+
rb_thread_ready(curr_thread);
- rb_raise(rb_eSignal, "SIG%s", sig);
+ argv[0] = INT2FIX(sig);
+ rb_exc_raise(rb_class_new_instance(1, argv, rb_eSignal));
}
rb_thread_ready(main_thread);
if (!rb_thread_dead(curr_thread)) {
@@ -12225,7 +12359,7 @@ rb_thread_signal_raise(sig)
return;
}
}
- th_signm = sig;
+ th_sig = sig;
curr_thread = main_thread;
rb_thread_restore_context(curr_thread, RESTORE_SIGNAL);
}
@@ -12902,8 +13036,11 @@ Init_Thread()
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, "kill!", rb_thread_kill_bang, 0);
+ rb_define_method(rb_cThread, "terminate!", rb_thread_kill_bang, 0);
+ rb_define_method(rb_cThread, "exit!", rb_thread_kill_bang, 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, "status", rb_thread_status_name, 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);
@@ -13073,13 +13210,3 @@ rb_throw(tag, val)
argv[1] = val;
rb_f_throw(2, argv);
}
-
-/* flush_register_windows must not be inlined because flushrs doesn't flush
- * current frame in register stack. */
-#ifdef __ia64__
-void flush_register_windows(void)
-{
- __asm__ ("flushrs");
-}
-#endif
-
diff --git a/ext/Setup b/ext/Setup
index 7b214abde3..d0d6317a5e 100644
--- a/ext/Setup
+++ b/ext/Setup
@@ -28,6 +28,7 @@
#syck
#syslog
#tcltklib
+#thread
#tk
#win32ole
#zlib
diff --git a/ext/Setup.atheos b/ext/Setup.atheos
index 9b1bdecb95..6bda3a4cfb 100644
--- a/ext/Setup.atheos
+++ b/ext/Setup.atheos
@@ -28,6 +28,7 @@ strscan
syck
syslog
#tcltklib
+thread
#tk
#win32ole
zlib
diff --git a/ext/Setup.dj b/ext/Setup.dj
index f2ed3a4f16..4f94788886 100644
--- a/ext/Setup.dj
+++ b/ext/Setup.dj
@@ -28,6 +28,7 @@ strscan
syck
#syslog
#tcltklib
+thread
#tk
#win32ole
zlib
diff --git a/ext/Setup.emx b/ext/Setup.emx
index 7ea04543c5..afc5923577 100644
--- a/ext/Setup.emx
+++ b/ext/Setup.emx
@@ -28,6 +28,7 @@ strscan
#syck
#syslog
#tcltklib
+thread
#tk
#win32ole
#zlib
diff --git a/ext/Setup.nt b/ext/Setup.nt
index 7a330f801a..9f8abf9b8d 100644
--- a/ext/Setup.nt
+++ b/ext/Setup.nt
@@ -28,6 +28,7 @@ strscan
syck
#syslog
#tcltklib
+thread
#tk
win32ole
#zlib
diff --git a/ext/Setup.x68 b/ext/Setup.x68
index 9b9563d941..0966e737e9 100644
--- a/ext/Setup.x68
+++ b/ext/Setup.x68
@@ -28,6 +28,7 @@ strscan
#syck
#syslog
#tcltklib
+thread
#tk
#win32ole
#zlib
diff --git a/ext/Win32API/Win32API.c b/ext/Win32API/Win32API.c
index a4fd0396f0..96ce8c6636 100644
--- a/ext/Win32API/Win32API.c
+++ b/ext/Win32API/Win32API.c
@@ -108,7 +108,7 @@ Win32API_initialize(self, dllname, proc, import, export)
}
if (16 < RARRAY(a_import)->len) {
- rb_raise(rb_eRuntimeError, "too many parameters: %ld\n", RARRAY(a_import)->len);
+ rb_raise(rb_eRuntimeError, "too many parameters: %d\n", RARRAY(a_import)->len);
}
rb_iv_set(self, "__import__", a_import);
diff --git a/ext/Win32API/lib/win32/registry.rb b/ext/Win32API/lib/win32/registry.rb
index 9a2f3827b7..2671551a33 100644
--- a/ext/Win32API/lib/win32/registry.rb
+++ b/ext/Win32API/lib/win32/registry.rb
@@ -493,7 +493,7 @@ module Win32
# utility functions
#
def self.expand_environ(str)
- str.gsub(/%([^%]+)%/) { ENV[$1] || ENV[$1.upcase] || $& }
+ str.gsub(/%([^%]+)%/) { ENV[$1] || $& }
end
@@type2name = { }
diff --git a/ext/Win32API/lib/win32/resolv.rb b/ext/Win32API/lib/win32/resolv.rb
index 92336fac28..6534d20760 100644
--- a/ext/Win32API/lib/win32/resolv.rb
+++ b/ext/Win32API/lib/win32/resolv.rb
@@ -11,7 +11,7 @@ module Win32
def self.get_hosts_path
path = get_hosts_dir
- path = File.expand_path('hosts', path)
+ path = File.join(path.gsub(/\\/, File::SEPARATOR), 'hosts')
File.exist?(path) ? path : nil
end
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 6f215afa48..a4b769e8cf 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -224,14 +224,14 @@ GetVpValue(VALUE v, int must)
#ifdef ENABLE_NUMERIC_STRING
case T_STRING:
SafeStringValue(v);
- return VpCreateRbObject(strlen(RSTRING(v)->ptr) + VpBaseFig() + 1,
- RSTRING(v)->ptr);
+ return VpCreateRbObject(strlen(RSTRING_PTR(v)) + VpBaseFig() + 1,
+ RSTRING_PTR(v));
#endif /* ENABLE_NUMERIC_STRING */
case T_BIGNUM:
bg = rb_big2str(v, 10);
- return VpCreateRbObject(strlen(RSTRING(bg)->ptr) + VpBaseFig() + 1,
- RSTRING(bg)->ptr);
+ return VpCreateRbObject(strlen(RSTRING_PTR(bg)) + VpBaseFig() + 1,
+ RSTRING_PTR(bg));
default:
goto SomeOneMayDoIt;
}
@@ -240,7 +240,7 @@ SomeOneMayDoIt:
if(must) {
rb_raise(rb_eTypeError, "%s can't be coerced into BigDecimal",
rb_special_const_p(v)?
- RSTRING(rb_inspect(v))->ptr:
+ RSTRING_PTR(rb_inspect(v)):
rb_obj_classname(v)
);
}
@@ -332,7 +332,7 @@ BigDecimal_load(VALUE self, VALUE str)
unsigned long m=0;
SafeStringValue(str);
- pch = RSTRING(str)->ptr;
+ pch = (unsigned char *)RSTRING_PTR(str);
/* First get max prec */
while((*pch)!=(unsigned char)'\0' && (ch=*pch++)!=(unsigned char)':') {
if(!ISDIGIT(ch)) {
@@ -341,7 +341,7 @@ BigDecimal_load(VALUE self, VALUE str)
m = m*10 + (unsigned long)(ch-'0');
}
if(m>VpBaseFig()) m -= VpBaseFig();
- GUARD_OBJ(pv,VpNewRbClass(m,pch,self));
+ GUARD_OBJ(pv,VpNewRbClass(m,(char *)pch,self));
m /= VpBaseFig();
if(m && pv->MaxPrec>m) pv->MaxPrec = m+1;
return ToValue(pv);
@@ -474,7 +474,7 @@ VpNewRbClass(U_LONG mx, char *str, VALUE klass)
}
VP_EXPORT Real *
-VpCreateRbObject(U_LONG mx, char *str)
+VpCreateRbObject(U_LONG mx, const char *str)
{
Real *pv = VpAlloc(mx,str);
pv->obj = (VALUE)Data_Wrap_Struct(rb_cBigDecimal, 0, BigDecimal_delete, pv);
@@ -586,22 +586,19 @@ BigDecimal_to_f(VALUE self)
{
ENTER(1);
Real *p;
- double d;
+ double d, d2;
S_LONG e;
- char *buf;
GUARD_OBJ(p,GetVpValue(self,1));
if(VpVtoD(&d, &e, p)!=1) return rb_float_new(d);
- buf = ALLOCA_N(char,(unsigned int)VpNumOfChars(p,"E"));
- VpToString(p, buf, 0, 0);
errno = 0;
- d = strtod(buf, 0);
- if(errno == ERANGE) {
+ 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);
+ return rb_float_new(d*d2);
}
/* The coerce method provides support for Ruby type coercion. It is not
@@ -784,17 +781,6 @@ BigDecimal_eq(VALUE self, VALUE r)
return BigDecimalCmp(self, r, '=');
}
-/* Returns true if the values are not equal in value. Values may be coerced
- * to perform the comparison:
- *
- * BigDecimal.new('1.0') != 1.0 -> false
- */
-static VALUE
-BigDecimal_ne(VALUE self, VALUE r)
-{
- return BigDecimalCmp(self, r, '!');
-}
-
/* call-seq:
* a < b
*
@@ -1065,7 +1051,7 @@ static VALUE
BigDecimal_remainder(VALUE self, VALUE r) /* remainder */
{
VALUE f;
- Real *d,*rv=0;
+ Real *d,*rv;
f = BigDecimal_divremain(self,r,&d,&rv);
if(f!=(VALUE)0) return f;
return ToValue(rv);
@@ -1279,7 +1265,7 @@ BigDecimal_round(int argc, VALUE *argv, VALUE self)
{
ENTER(5);
Real *c, *a;
- int iLoc;
+ int iLoc = 0;
U_LONG mx;
VALUE vLoc;
VALUE vRound;
@@ -1513,13 +1499,13 @@ BigDecimal_to_s(int argc, VALUE *argv, VALUE self)
if(rb_scan_args(argc,argv,"01",&f)==1) {
if(TYPE(f)==T_STRING) {
SafeStringValue(f);
- psz = RSTRING(f)->ptr;
+ psz = RSTRING_PTR(f);
if(*psz==' ') {
fPlus = 1; psz++;
} else if(*psz=='+') {
fPlus = 2; psz++;
}
- while((ch=*psz++)!=0) {
+ while(ch=*psz++) {
if(ISSPACE(ch)) continue;
if(!ISDIGIT(ch)) {
if(ch=='F' || ch=='f') fmt = 1; /* F format */
@@ -1690,7 +1676,7 @@ BigDecimal_global_new(int argc, VALUE *argv, VALUE self)
mf = GetPositiveInt(nFig);
}
SafeStringValue(iniValue);
- GUARD_OBJ(pv,VpCreateRbObject(mf, RSTRING(iniValue)->ptr));
+ GUARD_OBJ(pv,VpCreateRbObject(mf, RSTRING_PTR(iniValue)));
return ToValue(pv);
}
@@ -1721,7 +1707,7 @@ BigDecimal_new(int argc, VALUE *argv, VALUE self)
mf = GetPositiveInt(nFig);
}
SafeStringValue(iniValue);
- GUARD_OBJ(pv,VpNewRbClass(mf, RSTRING(iniValue)->ptr,self));
+ GUARD_OBJ(pv,VpNewRbClass(mf, RSTRING_PTR(iniValue),self));
return ToValue(pv);
}
@@ -1814,76 +1800,94 @@ Init_bigdecimal(void)
/* Exceptions */
/*
- * Determines whether overflow, underflow or zero divide result in
+ * 0xff: Determines whether overflow, underflow or zero divide result in
* an exception being thrown. See BigDecimal.mode.
*/
rb_define_const(rb_cBigDecimal, "EXCEPTION_ALL",INT2FIX(VP_EXCEPTION_ALL));
/*
- * Determines what happens when the result of a computation is not a
+ * 0x02: Determines what happens when the result of a computation is not a
* number (NaN). See BigDecimal.mode.
*/
rb_define_const(rb_cBigDecimal, "EXCEPTION_NaN",INT2FIX(VP_EXCEPTION_NaN));
/*
- * Determines what happens when the result of a computation is infinity.
- * See BigDecimal.mode.
+ * 0x01: Determines what happens when the result of a computation is
+ * infinity. See BigDecimal.mode.
*/
rb_define_const(rb_cBigDecimal, "EXCEPTION_INFINITY",INT2FIX(VP_EXCEPTION_INFINITY));
/*
- * Determines what happens when the result of a computation is an underflow
- * (a result too small to be represented). See BigDecimal.mode.
+ * 0x04: Determines what happens when the result of a computation is an
+ * underflow (a result too small to be represented). See BigDecimal.mode.
*/
rb_define_const(rb_cBigDecimal, "EXCEPTION_UNDERFLOW",INT2FIX(VP_EXCEPTION_UNDERFLOW));
/*
- * Determines what happens when the result of a computation is an underflow
- * (a result too large to be represented). See BigDecimal.mode.
+ * 0x01: Determines what happens when the result of a computation is an
+ * underflow (a result too large to be represented). See BigDecimal.mode.
*/
rb_define_const(rb_cBigDecimal, "EXCEPTION_OVERFLOW",INT2FIX(VP_EXCEPTION_OVERFLOW));
/*
- * Determines what happens when a division by zero is performed.
+ * 0x01: Determines what happens when a division by zero is performed.
* See BigDecimal.mode.
*/
rb_define_const(rb_cBigDecimal, "EXCEPTION_ZERODIVIDE",INT2FIX(VP_EXCEPTION_ZERODIVIDE));
/*
- * Determines what happens when a result must be rounded in order to
- * fit in the appropriate number of significant digits. See
+ * 0x100: Determines what happens when a result must be rounded in order to
+ * fit in the appropriate number of significant digits. See
* BigDecimal.mode.
*/
rb_define_const(rb_cBigDecimal, "ROUND_MODE",INT2FIX(VP_ROUND_MODE));
- /* Indicates that values should be rounded away from zero. See BigDecimal.mode. */
+ /* 1: Indicates that values should be rounded away from zero. See
+ * BigDecimal.mode.
+ */
rb_define_const(rb_cBigDecimal, "ROUND_UP",INT2FIX(VP_ROUND_UP));
- /* Indicates that values should be rounded towards zero. See BigDecimal.mode. */
+
+ /* 2: Indicates that values should be rounded towards zero. See
+ * BigDecimal.mode.
+ */
rb_define_const(rb_cBigDecimal, "ROUND_DOWN",INT2FIX(VP_ROUND_DOWN));
- /* Indicates that digits >= 5 should be rounded up, others rounded down. See BigDecimal.mode. */
+
+ /* 3: Indicates that digits >= 5 should be rounded up, others rounded down.
+ * See BigDecimal.mode. */
rb_define_const(rb_cBigDecimal, "ROUND_HALF_UP",INT2FIX(VP_ROUND_HALF_UP));
- /* Indicates that digits >= 6 should be rounded up, others rounded down. See BigDecimal.mode. */
+
+ /* 4: Indicates that digits >= 6 should be rounded up, others rounded down.
+ * See BigDecimal.mode.
+ */
rb_define_const(rb_cBigDecimal, "ROUND_HALF_DOWN",INT2FIX(VP_ROUND_HALF_DOWN));
- /* Round towards +infinity. See BigDecimal.mode. */
+ /* 5: Round towards +infinity. See BigDecimal.mode. */
rb_define_const(rb_cBigDecimal, "ROUND_CEILING",INT2FIX(VP_ROUND_CEIL));
- /* Round towards -infinity. See BigDecimal.mode. */
+
+ /* 6: Round towards -infinity. See BigDecimal.mode. */
rb_define_const(rb_cBigDecimal, "ROUND_FLOOR",INT2FIX(VP_ROUND_FLOOR));
- /* Round towards the even neighbor. See BigDecimal.mode. */
+
+ /* 7: Round towards the even neighbor. See BigDecimal.mode. */
rb_define_const(rb_cBigDecimal, "ROUND_HALF_EVEN",INT2FIX(VP_ROUND_HALF_EVEN));
- /* Indicates that a value is not a number. See BigDecimal.sign. */
+ /* 0: Indicates that a value is not a number. See BigDecimal.sign. */
rb_define_const(rb_cBigDecimal, "SIGN_NaN",INT2FIX(VP_SIGN_NaN));
- /* Indicates that a value is +0. See BigDecimal.sign. */
+
+ /* 1: Indicates that a value is +0. See BigDecimal.sign. */
rb_define_const(rb_cBigDecimal, "SIGN_POSITIVE_ZERO",INT2FIX(VP_SIGN_POSITIVE_ZERO));
- /* Indicates that a value is -0. See BigDecimal.sign. */
+
+ /* -1: Indicates that a value is -0. See BigDecimal.sign. */
rb_define_const(rb_cBigDecimal, "SIGN_NEGATIVE_ZERO",INT2FIX(VP_SIGN_NEGATIVE_ZERO));
- /* Indicates that a value is positive and finite. See BigDecimal.sign. */
+
+ /* 2: Indicates that a value is positive and finite. See BigDecimal.sign. */
rb_define_const(rb_cBigDecimal, "SIGN_POSITIVE_FINITE",INT2FIX(VP_SIGN_POSITIVE_FINITE));
- /* Indicates that a value is negative and finite. See BigDecimal.sign. */
+
+ /* -2: Indicates that a value is negative and finite. See BigDecimal.sign. */
rb_define_const(rb_cBigDecimal, "SIGN_NEGATIVE_FINITE",INT2FIX(VP_SIGN_NEGATIVE_FINITE));
- /* Indicates that a value is positive and infinite. See BigDecimal.sign. */
+
+ /* 3: Indicates that a value is positive and infinite. See BigDecimal.sign. */
rb_define_const(rb_cBigDecimal, "SIGN_POSITIVE_INFINITE",INT2FIX(VP_SIGN_POSITIVE_INFINITE));
- /* Indicates that a value is negative and infinite. See BigDecimal.sign. */
+
+ /* -3: Indicates that a value is negative and infinite. See BigDecimal.sign. */
rb_define_const(rb_cBigDecimal, "SIGN_NEGATIVE_INFINITE",INT2FIX(VP_SIGN_NEGATIVE_INFINITE));
/* instance methods */
@@ -1924,7 +1928,6 @@ Init_bigdecimal(void)
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);
@@ -1959,27 +1962,17 @@ static int gfCheckVal = 1; /* Value checking flag in VpNmlz() */
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 */
-#ifndef BASE_FIG
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 */
-#else
-#ifndef BASE
-#error BASE_FIG is defined but BASE is not
-#endif
-#define HALF_BASE (BASE/2)
-#define BASE1 (BASE/10)
-#endif
-#ifndef DBLE_FIG
-#define DBLE_FIG (DBL_DIG+1) /* figure of double */
-#endif
static Real *VpConstOne; /* constant 1.0 */
static Real *VpPt5; /* constant 0.5 */
-#define maxnr 100UL /* Maximum iterations for calcurating sqrt. */
+static U_LONG maxnr = 100; /* Maximum iterations for calcurating sqrt. */
/* used in VpSqrt() */
/* ETC */
@@ -2096,8 +2089,8 @@ VpSetRoundMode(unsigned long n)
* (to let the compiler know they may be changed in outside
* (... but not actually..)).
*/
-volatile const double gZero_ABCED9B1_CE73__00400511F31D = 0.0;
-volatile const double gOne_ABCED9B4_CE73__00400511F31D = 1.0;
+volatile double gZero_ABCED9B1_CE73__00400511F31D = 0.0;
+volatile double gOne_ABCED9B4_CE73__00400511F31D = 1.0;
static double
Zero(void)
{
@@ -2182,7 +2175,7 @@ VpIsNegDoubleZero(double v)
}
VP_EXPORT int
-VpException(unsigned short f,char *str,int always)
+VpException(unsigned short f, const char *str,int always)
{
VALUE exc;
int fatal=0;
@@ -2219,8 +2212,8 @@ VpException(unsigned short f,char *str,int always)
return 0; /* 0 Means VpException() raised no exception */
raise:
- if(fatal) rb_fatal(str);
- else rb_raise(exc,str);
+ if(fatal) rb_fatal("%s", str);
+ else rb_raise(exc, "%s", str);
return 0;
}
@@ -2324,7 +2317,7 @@ NaN:
* returns number of chars needed to represent vp in specified format.
*/
VP_EXPORT U_LONG
-VpNumOfChars(Real *vp,char *pszFmt)
+VpNumOfChars(Real *vp,const char *pszFmt)
{
S_INT ex;
U_LONG nc;
@@ -2369,15 +2362,16 @@ VpNumOfChars(Real *vp,char *pszFmt)
VP_EXPORT U_LONG
VpInit(U_LONG BaseVal)
{
+ U_LONG w;
+ double v;
+
/* Setup +/- Inf NaN -0 */
VpGetDoubleNaN();
VpGetDoublePosInf();
VpGetDoubleNegInf();
VpGetDoubleNegZero();
-#ifndef BASE_FIG
if(BaseVal <= 0) {
- U_LONG w;
/* Base <= 0, then determine Base by calcuration. */
BASE = 1;
while(
@@ -2394,8 +2388,6 @@ VpInit(U_LONG BaseVal)
BASE1 = BASE / 10;
BASE_FIG = 0;
while(BaseVal /= 10) ++BASE_FIG;
-#endif
-
/* Allocates Vp constants. */
VpConstOne = VpAlloc((U_LONG)1, "1");
VpPt5 = VpAlloc((U_LONG)1, ".5");
@@ -2404,6 +2396,15 @@ VpInit(U_LONG BaseVal)
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);
@@ -2419,7 +2420,7 @@ VpInit(U_LONG BaseVal)
}
VP_EXPORT Real *
-VpOne()
+VpOne(void)
{
return VpConstOne;
}
@@ -2469,7 +2470,7 @@ overflow:
* NULL be returned if memory allocation is failed,or any error.
*/
VP_EXPORT Real *
-VpAlloc(U_LONG mx, char *szVal)
+VpAlloc(U_LONG mx, const char *szVal)
{
U_LONG i, ni, ipn, ipf, nf, ipe, ne, nalloc;
char v,*psz;
@@ -2506,7 +2507,7 @@ VpAlloc(U_LONG mx, char *szVal)
psz = ALLOCA_N(char,strlen(szVal)+1);
i = 0;
ipn = 0;
- while((psz[i]=szVal[ipn])!=0) {
+ while(psz[i]=szVal[ipn]) {
if(ISDIGIT(psz[i])) ++ni;
if(psz[i]=='_') {
if(ni>0) {ipn++;continue;}
@@ -2549,7 +2550,7 @@ VpAlloc(U_LONG mx, char *szVal)
else if(szVal[i] == '+') ++i;
/* Skip digits */
ni = 0; /* digits in mantissa */
- while((v = szVal[i]) != 0) {
+ while(v = szVal[i]) {
if(!ISDIGIT(v)) break;
++i;
++ni;
@@ -2563,7 +2564,7 @@ VpAlloc(U_LONG mx, char *szVal)
if(szVal[i] == '.') { /* xxx. */
++i;
ipf = i;
- while((v = szVal[i]) != 0) { /* get fraction part. */
+ while(v = szVal[i]) { /* get fraction part. */
if(!ISDIGIT(v)) break;
++i;
++nf;
@@ -2581,7 +2582,7 @@ VpAlloc(U_LONG mx, char *szVal)
ipe = i;
v = szVal[i];
if((v == '-') ||(v == '+')) ++i;
- while((v=szVal[i])!=0) {
+ while(v=szVal[i]) {
if(!ISDIGIT(v)) break;
++i;
++ne;
@@ -3884,7 +3885,7 @@ VpToFString(Real *a,char *psz,int fFmt,int fPlus)
* 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)
+VpCtoV(Real *a, const char *int_chr, U_LONG ni, const char *frac, U_LONG nf, const char *exp_chr, U_LONG ne)
{
U_LONG i, j, ind_a, ma, mi, me;
U_LONG loc;
@@ -4433,7 +4434,7 @@ VpLeftRound(Real *y, int f, int nf)
if(!VpHasVal(y)) return 0; /* Unable to round */
v = y->frac[0];
nf -= VpExponent(y)*BASE_FIG;
- while((v /= 10) != 0) nf--;
+ while(v=v/10) nf--;
nf += (BASE_FIG-1);
return VpMidRound(y,f,nf);
}
diff --git a/ext/bigdecimal/bigdecimal.h b/ext/bigdecimal/bigdecimal.h
index aabc551a76..4f77feab00 100644
--- a/ext/bigdecimal/bigdecimal.h
+++ b/ext/bigdecimal/bigdecimal.h
@@ -105,7 +105,7 @@ typedef struct {
VP_EXPORT Real *
VpNewRbClass(U_LONG mx,char *str,VALUE klass);
-VP_EXPORT Real *VpCreateRbObject(U_LONG mx,char *str);
+VP_EXPORT Real *VpCreateRbObject(U_LONG mx,const char *str);
VP_EXPORT U_LONG VpBaseFig(void);
VP_EXPORT U_LONG VpDblFig(void);
@@ -126,13 +126,13 @@ 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 VpException(unsigned short f,const char *str,int always);
VP_EXPORT int VpIsNegDoubleZero(double v);
-VP_EXPORT U_LONG VpNumOfChars(Real *vp,char *pszFmt);
+VP_EXPORT U_LONG VpNumOfChars(Real *vp,const 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 Real *VpAlloc(U_LONG mx, const 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);
@@ -143,7 +143,7 @@ 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 VpCtoV(Real *a,const char *int_chr,U_LONG ni,const char *frac,U_LONG nf,const 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);
@@ -155,7 +155,7 @@ 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();
+VP_EXPORT Real *VpOne(void);
/*
* ------------------
diff --git a/ext/bigdecimal/bigdecimal_en.html b/ext/bigdecimal/bigdecimal_en.html
index 02c88df43e..c2b86faef6 100644
--- a/ext/bigdecimal/bigdecimal_en.html
+++ b/ext/bigdecimal/bigdecimal_en.html
@@ -379,7 +379,7 @@ 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.
+n can be a string representing a positive integer number.
<CODE><PRE>
BigDecimal("0.1234567890123456789").to_s("10") # ==> "0.1234567890 123456789E0"
</PRE></CODE>
@@ -678,10 +678,9 @@ 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.
+Because most computers have no internal decimal representaion.
+Once you use BigDecimal,you need to keep using it without
+considering computation cost if exact computation is required.
<H4>Which is the first input?</H4>
Because most people uses decimal notatin for numeric data representation,
diff --git a/ext/bigdecimal/bigdecimal_ja.html b/ext/bigdecimal/bigdecimal_ja.html
index 8fd95a6fe3..37bbcbbb09 100644
--- a/ext/bigdecimal/bigdecimal_ja.html
+++ b/ext/bigdecimal/bigdecimal_ja.html
@@ -676,10 +676,11 @@ exponent=1Asign=2 ‚Ȃ甒l‚ª 1234.56784321 ‚Å‚ ‚é‚̂͌©‚ê‚Î’¼‚®‚É•ª‚©‚è‚Ü‚·B
<H3>10i‚̃fƒƒŠƒbƒg</H3>
ŽÀ‚Í¡‚܂ł̃ƒŠƒbƒg‚ÍA‚»‚̂܂܃fƒƒŠƒbƒg‚É‚à‚È‚è‚Ü‚·B
-‚»‚à‚»‚àA10i‚ð2iA2i‚ð10i‚ɕϊ·‚·‚邿‚¤‚È‘€ì‚͕ϊ·Œë·
+‚»‚à‚»‚àA10i‚ð2i‚ɕϊ·‚·‚邿‚¤‚È‘€ì‚͕ϊ·Œë·
‚𔺂¤ê‡‚ð‰ñ”ð‚·‚é‚±‚Ƃ͂ł«‚Ü‚¹‚ñB
-Šù‚ÉŒvŽZ‹@“à•”‚ÉŽæ‚螂܂ꂽ2i”’l‚ð BigDecimal ‚Ì“à•”•\Œ»‚É
-•ÏŠ·‚·‚邯‚«‚ɂ͌뷂ª”ð‚¯‚ç‚ê‚È‚¢ê‡‚ª‚ ‚è‚Ü‚·B
+‘åŠT‚̃Rƒ“ƒsƒ…[ƒ^‚Í10i‚Ì“à•”•\Œ»‚ðŽ‚Á‚Ä‚¢‚È‚¢‚Ì‚ÅA
+BigDecimal ‚ð—˜—p‚µ‚Č뷖³‚µ‚ÌŒvŽZ‚ð‚·‚éꇂÍAŒvŽZ‘¬“x
+‚𖳎‹‚µ‚Ä‚àÅŒã‚܂ŠBigDecimal ‚ðŽg—p‘±‚¯‚é•K—v‚ª‚ ‚è‚Ü‚·B
<H3>ʼn‚͉½‚©H</H3>
Ž©•ª‚ÅŒvŽZ‚·‚邯‚«‚ɂ킴‚í‚´2i”‚ðŽg‚¤l‚͋ɂ߂Ă܂ê‚Å‚·B
diff --git a/ext/bigdecimal/extconf.rb b/ext/bigdecimal/extconf.rb
index 864aaad862..a68a656044 100644
--- a/ext/bigdecimal/extconf.rb
+++ b/ext/bigdecimal/extconf.rb
@@ -1,12 +1,2 @@
require 'mkmf'
-
-base_fig = 0
-src = ("(BASE > 0) && "
- "(BASE * (BASE+1)) > BASE && "
- "(BASE * (BASE+1)) / BASE == (BASE+1)")
-while try_static_assert(src, nil, "-DBASE=10#{'0'*base_fig}UL")
- base_fig += 1
-end
-$defs << "-DBASE=1#{'0'*base_fig}UL" << "-DBASE_FIG=#{base_fig}"
-
create_makefile('bigdecimal')
diff --git a/ext/curses/curses.c b/ext/curses/curses.c
index 4e84b0837f..9c51a2127f 100644
--- a/ext/curses/curses.c
+++ b/ext/curses/curses.c
@@ -1,5 +1,5 @@
/* -*- C -*-
- * $Id: curses.c,v 1.24.2.8 2006/07/18 05:08:34 matz Exp $
+ * $Id$
*
* ext/curses/curses.c
*
@@ -1255,7 +1255,6 @@ window_color_set(VALUE obj, VALUE col)
GetWINDOW(obj, winp);
res = wcolor_set(winp->window, NUM2INT(col), NULL);
return (res == OK) ? Qtrue : Qfalse;
- return Qfalse;
}
#endif /* USE_COLOR */
diff --git a/ext/curses/extconf.rb b/ext/curses/extconf.rb
index 0124bbbf4a..01fe971093 100644
--- a/ext/curses/extconf.rb
+++ b/ext/curses/extconf.rb
@@ -20,7 +20,7 @@ end
if make
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 wcolor_set)
- have_func(f) || (have_macro(f, curses) && $defs.push(format("-DHAVE_%s", f.upcase)))
+ have_func(f)
end
flag = "-D_XOPEN_SOURCE_EXTENDED"
src = "int test_var[(sizeof(char*)>sizeof(int))*2-1];"
diff --git a/ext/dbm/dbm.c b/ext/dbm/dbm.c
index 83e6a9893b..69b7a6e7a7 100644
--- a/ext/dbm/dbm.c
+++ b/ext/dbm/dbm.c
@@ -2,8 +2,8 @@
dbm.c -
- $Author: usa $
- $Date: 2005/06/20 07:53:19 $
+ $Author$
+ $Date$
created at: Mon Jan 24 15:59:52 JST 1994
Copyright (C) 1995-2001 Yukihiro Matsumoto
diff --git a/ext/dbm/extconf.rb b/ext/dbm/extconf.rb
index 52ec688952..0074ab605b 100644
--- a/ext/dbm/extconf.rb
+++ b/ext/dbm/extconf.rb
@@ -2,9 +2,13 @@ require 'mkmf'
dir_config("dbm")
-dblib = with_config("dbm-type", nil)
+if dblib = with_config("dbm-type", nil)
+ dblib = dblib.split(/[ ,]+/)
+else
+ dblib = %w(db db2 db1 dbm gdbm gdbm_compat qdbm)
+end
-$dbm_conf_headers = {
+headers = {
"db" => ["db.h"],
"db1" => ["db1/ndbm.h", "db1.h", "ndbm.h"],
"db2" => ["db2/db.h", "db2.h", "db.h"],
@@ -14,48 +18,36 @@ $dbm_conf_headers = {
"qdbm" => ["relic.h"],
}
-def db_check(db)
- $dbm_conf_db_prefix = ""
- $dbm_conf_have_gdbm = false
- hsearch = ""
+def headers.db_check(db)
+ db_prefix = nil
+ have_gdbm = false
+ hsearch = nil
case db
when /^db2?$/
- $dbm_conf_db_prefix = "__db_n"
+ db_prefix = "__db_n"
hsearch = "-DDB_DBM_HSEARCH "
when "gdbm"
- $dbm_conf_have_gdbm = true
+ have_gdbm = true
when "gdbm_compat"
- $dbm_conf_have_gdbm = true
+ 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)
- $defs << hsearch << '-DDBM_HDR="<'+hdr+'>"'
- return true
- end
- end
- end
- return false
-end
-
-def db_prefix(func)
- $dbm_conf_db_prefix+func
-end
-
-if dblib
- dbm_hdr = db_check(dblib)
-else
- dbm_hdr = %w(db db2 db1 dbm gdbm gdbm_compat qdbm).any? do |dblib|
- db_check(dblib)
+ db_prefix ||= ""
+
+ if (have_library(db, db_prefix+"dbm_open") || have_func(db_prefix+"dbm_open")) and
+ hdr = self.fetch(db, ["ndbm.h"]).find {|hdr| have_type("DBM", hdr, hsearch)}
+ have_func(db_prefix+"dbm_clearerr") unless have_gdbm
+ $defs << hsearch if hsearch
+ $defs << '-DDBM_HDR="<'+hdr+'>"'
+ true
+ else
+ false
end
end
-have_header("cdefs.h")
-have_header("sys/cdefs.h")
-if dbm_hdr and have_func(db_prefix("dbm_open"))
- have_func(db_prefix("dbm_clearerr")) unless $dbm_conf_have_gdbm
+if dblib.any? {|db| headers.db_check(db)}
+ have_header("cdefs.h")
+ have_header("sys/cdefs.h")
create_makefile("dbm")
end
diff --git a/ext/digest/bubblebabble/.cvsignore b/ext/digest/bubblebabble/.cvsignore
new file mode 100644
index 0000000000..4088712231
--- /dev/null
+++ b/ext/digest/bubblebabble/.cvsignore
@@ -0,0 +1,3 @@
+Makefile
+mkmf.log
+*.def
diff --git a/ext/digest/bubblebabble/bubblebabble.c b/ext/digest/bubblebabble/bubblebabble.c
new file mode 100644
index 0000000000..3a03ceced0
--- /dev/null
+++ b/ext/digest/bubblebabble/bubblebabble.c
@@ -0,0 +1,142 @@
+/************************************************
+
+ bubblebabble.c - BubbleBabble encoding support
+
+ $Author$
+ created at: Fri Oct 13 18:31:42 JST 2006
+
+ Copyright (C) 2006 Akinori MUSHA
+
+ $Id$
+
+************************************************/
+
+#include "ruby.h"
+#include "digest.h"
+
+static ID id_digest;
+
+static VALUE
+bubblebabble_str_new(VALUE str_digest)
+{
+ char *digest;
+ size_t digest_len;
+ VALUE str;
+ char *p;
+ int i, j, seed = 1;
+ static const char vowels[] = {
+ 'a', 'e', 'i', 'o', 'u', 'y'
+ };
+ static const char consonants[] = {
+ 'b', 'c', 'd', 'f', 'g', 'h', 'k', 'l', 'm', 'n',
+ 'p', 'r', 's', 't', 'v', 'z', 'x'
+ };
+
+ StringValue(str_digest);
+ digest = RSTRING_PTR(str_digest);
+ digest_len = RSTRING_LEN(str_digest);
+
+ if ((LONG_MAX - 2) / 3 < (digest_len | 1)) {
+ rb_raise(rb_eRuntimeError, "digest string too long");
+ }
+
+ str = rb_str_new(0, (digest_len | 1) * 3 + 2);
+ p = RSTRING_PTR(str);
+
+ i = j = 0;
+ p[j++] = 'x';
+
+ for (;;) {
+ unsigned char byte1, byte2;
+
+ if (i >= digest_len) {
+ p[j++] = vowels[seed % 6];
+ p[j++] = consonants[16];
+ p[j++] = vowels[seed / 6];
+ break;
+ }
+
+ byte1 = digest[i++];
+ p[j++] = vowels[(((byte1 >> 6) & 3) + seed) % 6];
+ p[j++] = consonants[(byte1 >> 2) & 15];
+ p[j++] = vowels[((byte1 & 3) + (seed / 6)) % 6];
+
+ if (i >= digest_len) {
+ break;
+ }
+
+ byte2 = digest[i++];
+ p[j++] = consonants[(byte2 >> 4) & 15];
+ p[j++] = '-';
+ p[j++] = consonants[byte2 & 15];
+
+ seed = (seed * 5 + byte1 * 7 + byte2) % 36;
+ }
+
+ p[j] = 'x';
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * Digest.bubblebabble(string) -> bubblebabble_string
+ *
+ * Returns a BubbleBabble encoded version of a given _string_.
+ */
+static VALUE
+rb_digest_s_bubblebabble(VALUE klass, VALUE str)
+{
+ return bubblebabble_str_new(str);
+}
+
+/*
+ * call-seq:
+ * Digest::Class.bubblebabble(string, ...) -> hash_string
+ *
+ * Returns the BubbleBabble encoded hash value of a given _string_.
+ */
+static VALUE
+rb_digest_class_s_bubblebabble(int argc, VALUE *argv, VALUE klass)
+{
+ return bubblebabble_str_new(rb_funcall2(klass, id_digest, argc, argv));
+}
+
+/*
+ * call-seq:
+ * digest_obj.bubblebabble -> hash_string
+ *
+ * Returns the resulting hash value in a Bubblebabble encoded form.
+ */
+static VALUE
+rb_digest_instance_bubblebabble(VALUE self)
+{
+ return bubblebabble_str_new(rb_funcall(self, id_digest, 0));
+}
+
+/*
+ * This module adds some methods to Digest classes to perform
+ * BubbleBabble encoding.
+ */
+void
+Init_bubblebabble(void)
+{
+ VALUE mDigest, mDigest_Instance, cDigest_Class;
+
+ rb_require("digest");
+
+ mDigest = rb_path2class("Digest");
+ mDigest_Instance = rb_path2class("Digest::Instance");
+ cDigest_Class = rb_path2class("Digest::Class");
+
+ /* Digest::bubblebabble() */
+ rb_define_module_function(mDigest, "bubblebabble", rb_digest_s_bubblebabble, 1);
+
+ /* Digest::Class::bubblebabble() */
+ rb_define_singleton_method(cDigest_Class, "bubblebabble", rb_digest_class_s_bubblebabble, -1);
+
+ /* Digest::Instance#bubblebabble() */
+ rb_define_method(mDigest_Instance, "bubblebabble", rb_digest_instance_bubblebabble, 0);
+
+ id_digest = rb_intern("digest");
+}
diff --git a/ext/digest/bubblebabble/depend b/ext/digest/bubblebabble/depend
new file mode 100644
index 0000000000..b20148ded4
--- /dev/null
+++ b/ext/digest/bubblebabble/depend
@@ -0,0 +1,3 @@
+bubblebabble.o: bubblebabble.c $(srcdir)/../digest.h $(hdrdir)/ruby.h \
+ $(topdir)/config.h $(hdrdir)/defines.h $(hdrdir)/intern.h \
+ $(srcdir)/../defs.h
diff --git a/ext/digest/bubblebabble/extconf.rb b/ext/digest/bubblebabble/extconf.rb
new file mode 100644
index 0000000000..53cb83934a
--- /dev/null
+++ b/ext/digest/bubblebabble/extconf.rb
@@ -0,0 +1,6 @@
+require 'mkmf'
+
+$defs << "-DHAVE_CONFIG_H"
+$INCFLAGS << " -I$(srcdir)/.."
+
+create_makefile('digest/bubblebabble')
diff --git a/ext/digest/defs.h b/ext/digest/defs.h
index d51c627cf9..b9a3470e65 100644
--- a/ext/digest/defs.h
+++ b/ext/digest/defs.h
@@ -1,5 +1,5 @@
/* -*- C -*-
- * $Id: defs.h,v 1.7 2003/06/01 15:39:52 eban Exp $
+ * $Id$
*/
#ifndef DEFS_H
@@ -23,12 +23,8 @@
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;
+# elif SIZEOF_LONG_LONG == 8
+ typedef unsigned LONG_LONG uint64_t;
# else
# define NO_UINT64_T
# endif
diff --git a/ext/digest/digest.c b/ext/digest/digest.c
index 957fe4f6ea..92a925c616 100644
--- a/ext/digest/digest.c
+++ b/ext/digest/digest.c
@@ -2,157 +2,492 @@
digest.c -
- $Author: matz $
+ $Author$
created at: Fri May 25 08:57:27 JST 2001
Copyright (C) 1995-2001 Yukihiro Matsumoto
- Copyright (C) 2001 Akinori MUSHA
+ Copyright (C) 2001-2006 Akinori MUSHA
$RoughId: digest.c,v 1.16 2001/07/13 15:38:27 knu Exp $
- $Id: digest.c,v 1.14.2.2 2005/12/12 00:36:51 matz Exp $
+ $Id$
************************************************/
+#include "digest.h"
+
+static VALUE rb_mDigest;
+static VALUE rb_mDigest_Instance;
+static VALUE rb_cDigest_Class;
+static VALUE rb_cDigest_Base;
+
+static ID id_reset, id_update, id_finish, id_digest, id_hexdigest, id_digest_length;
+static ID id_metadata;
+
+RUBY_EXTERN void Init_digest_base(void);
+
/*
- * This module provides an interface to the following hash algorithms:
+ * Document-module: Digest
*
- * - 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.
+ * This module provides a framework for message digest libraries.
+ */
+
+static VALUE
+hexencode_str_new(VALUE str_digest)
+{
+ char *digest;
+ size_t digest_len;
+ int i;
+ VALUE str;
+ char *p;
+ static const char hex[] = {
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+ 'a', 'b', 'c', 'd', 'e', 'f'
+ };
+
+ StringValue(str_digest);
+ digest = RSTRING_PTR(str_digest);
+ digest_len = RSTRING_LEN(str_digest);
+
+ if (LONG_MAX / 2 < digest_len) {
+ rb_raise(rb_eRuntimeError, "digest string too long");
+ }
+
+ str = rb_str_new(0, digest_len * 2);
+
+ for (i = 0, p = RSTRING_PTR(str); i < digest_len; i++) {
+ unsigned char byte = digest[i];
+
+ p[i + i] = hex[byte >> 4];
+ p[i + i + 1] = hex[byte & 0x0f];
+ }
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * Digest.hexencode(string) -> hexencoded_string
*
- * - the SHA-256/384/512 Secure Hash Algorithm by NIST (the US'
- * National Institute of Standards and Technology), described in
- * FIPS PUB 180-2.
+ * Generates a hex-encoded version of a given _string_.
+ */
+static VALUE
+rb_digest_s_hexencode(VALUE klass, VALUE str)
+{
+ return hexencode_str_new(str);
+}
+
+/*
+ * Document-module: Digest::Instance
*
- * - the RIPEMD-160 cryptographic hash function, designed by Hans
- * Dobbertin, Antoon Bosselaers, and Bart Preneel.
+ * This module provides instance methods for a digest implementation
+ * object to calculate message digest values.
*/
-#include "digest.h"
+/*
+ * call-seq:
+ * digest_obj.update(string) -> digest_obj
+ * digest_obj << string -> digest_obj
+ *
+ * Updates the digest using a given _string_ and returns self.
+ *
+ * The update() method and the left-shift operator are overridden by
+ * each implementation subclass. (One should be an alias for the
+ * other)
+ */
+static VALUE
+rb_digest_instance_update(VALUE self, VALUE str)
+{
+ rb_raise(rb_eRuntimeError, "%s does not implement update()", rb_inspect(self));
+}
-static VALUE mDigest, cDigest_Base;
-static ID id_metadata;
+/*
+ * call-seq:
+ * digest_obj.instance_eval { finish } -> digest_obj
+ *
+ * Finishes the digest and returns the resulting hash value.
+ *
+ * This method is overridden by each implementation subclass and often
+ * made private, because some of those subclasses may leave internal
+ * data uninitialized. Do not call this method from outside. Use
+ * #digest!() instead, which ensures that internal data be reset for
+ * security reasons.
+ */
+static VALUE
+rb_digest_instance_finish(VALUE self)
+{
+ rb_raise(rb_eRuntimeError, "%s does not implement finish()", rb_inspect(self));
+}
/*
- * Digest::Base
+ * call-seq:
+ * digest_obj.reset -> digest_obj
+ *
+ * Resets the digest to the initial state and returns self.
+ *
+ * This method is overridden by each implementation subclass.
*/
+static VALUE
+rb_digest_instance_reset(VALUE self)
+{
+ rb_raise(rb_eRuntimeError, "%s does not implement reset()", rb_inspect(self));
+}
-static algo_t *
-get_digest_base_metadata(klass)
- VALUE klass;
+/*
+ * call-seq:
+ * digest_obj.new -> another_digest_obj
+ *
+ * Returns a new, initialized copy of the digest object. Equivalent
+ * to digest_obj.clone().reset().
+ */
+static VALUE
+rb_digest_instance_new(VALUE self)
{
- VALUE obj;
- algo_t *algo;
+ VALUE clone = rb_obj_clone(self);
+ rb_funcall(clone, id_reset, 0);
+ return clone;
+}
- if (rb_cvar_defined(klass, id_metadata) == Qfalse) {
- rb_notimplement();
+/*
+ * call-seq:
+ * digest_obj.digest -> string
+ * digest_obj.digest(string) -> string
+ *
+ * If none is given, returns the resulting hash value of the digest,
+ * keeping the digest's state.
+ *
+ * If a _string_ is given, returns the hash value for the given
+ * _string_, resetting the digest to the initial state before and
+ * after the process.
+ */
+static VALUE
+rb_digest_instance_digest(int argc, VALUE *argv, VALUE self)
+{
+ VALUE str, value;
+
+ if (rb_scan_args(argc, argv, "01", &str) > 0) {
+ rb_funcall(self, id_reset, 0);
+ rb_funcall(self, id_update, 1, str);
+ value = rb_funcall(self, id_finish, 0);
+ rb_funcall(self, id_reset, 0);
+ } else {
+ VALUE clone = rb_obj_clone(self);
+
+ value = rb_funcall(clone, id_finish, 0);
+ rb_funcall(clone, id_reset, 0);
}
- obj = rb_cvar_get(klass, id_metadata);
+ return value;
+}
- Data_Get_Struct(obj, algo_t, algo);
+/*
+ * call-seq:
+ * digest_obj.digest! -> string
+ *
+ * Returns the resulting hash value and resets the digest to the
+ * initial state.
+ */
+static VALUE
+rb_digest_instance_digest_bang(VALUE self)
+{
+ VALUE value = rb_funcall(self, id_finish, 0);
+ rb_funcall(self, id_reset, 0);
- return algo;
+ return value;
}
-static VALUE rb_digest_base_alloc _((VALUE));
+/*
+ * call-seq:
+ * digest_obj.hexdigest -> string
+ * digest_obj.hexdigest(string) -> string
+ *
+ * If none is given, returns the resulting hash value of the digest in
+ * a hex-encoded form, keeping the digest's state.
+ *
+ * If a _string_ is given, returns the hash value for the given
+ * _string_ in a hex-encoded form, resetting the digest to the initial
+ * state before and after the process.
+ */
static VALUE
-rb_digest_base_alloc(klass)
- VALUE klass;
+rb_digest_instance_hexdigest(int argc, VALUE *argv, VALUE self)
{
- algo_t *algo;
- VALUE obj;
- void *pctx;
-
- if (klass == cDigest_Base) {
- rb_raise(rb_eNotImpError, "Digest::Base is an abstract class");
+ VALUE str, value;
+
+ if (rb_scan_args(argc, argv, "01", &str) > 0) {
+ rb_funcall(self, id_reset, 0);
+ rb_funcall(self, id_update, 1, str);
+ value = rb_funcall(self, id_finish, 0);
+ rb_funcall(self, id_reset, 0);
+ } else {
+ VALUE clone = rb_obj_clone(self);
+
+ value = rb_funcall(clone, id_finish, 0);
+ rb_funcall(clone, id_reset, 0);
}
- algo = get_digest_base_metadata(klass);
+ return hexencode_str_new(value);
+}
- /* XXX: An uninitialized buffer leads ALGO_Equal() to fail */
- pctx = xcalloc(algo->ctx_size, 1);
- algo->init_func(pctx);
+/*
+ * call-seq:
+ * digest_obj.hexdigest! -> string
+ *
+ * Returns the resulting hash value and resets the digest to the
+ * initial state.
+ */
+static VALUE
+rb_digest_instance_hexdigest_bang(VALUE self)
+{
+ VALUE value = rb_funcall(self, id_finish, 0);
+ rb_funcall(self, id_reset, 0);
- obj = Data_Wrap_Struct(klass, 0, free, pctx);
+ return hexencode_str_new(value);
+}
- return obj;
+/*
+ * call-seq:
+ * digest_obj.to_s -> string
+ *
+ * Returns digest_obj.hexdigest().
+ */
+static VALUE
+rb_digest_instance_to_s(VALUE self)
+{
+ return rb_funcall(self, id_hexdigest, 0);
}
+/*
+ * call-seq:
+ * digest_obj.inspect -> string
+ *
+ * Creates a printable version of the digest object.
+ */
static VALUE
-rb_digest_base_s_digest(klass, str)
- VALUE klass;
+rb_digest_instance_inspect(VALUE self)
+{
VALUE str;
+ size_t digest_len = 32; /* about this size at least */
+ char *cname;
+
+ cname = rb_obj_classname(self);
+
+ /* #<Digest::ClassName: xxxxx...xxxx> */
+ str = rb_str_buf_new(2 + strlen(cname) + 2 + digest_len * 2 + 1);
+ rb_str_buf_cat2(str, "#<");
+ rb_str_buf_cat2(str, cname);
+ rb_str_buf_cat2(str, ": ");
+ rb_str_buf_append(str, rb_digest_instance_hexdigest(0, 0, self));
+ rb_str_buf_cat2(str, ">");
+ return str;
+}
+
+/*
+ * call-seq:
+ * digest_obj == another_digest_obj -> boolean
+ * digest_obj == string -> boolean
+ *
+ * If a string is given, checks whether it is equal to the hex-encoded
+ * hash value of the digest object. If another digest instance is
+ * given, checks whether they have the same hash value. Otherwise
+ * returns false.
+ */
+static VALUE
+rb_digest_instance_equal(VALUE self, VALUE other)
{
- algo_t *algo;
- void *pctx;
- size_t len;
- unsigned char *digest;
- volatile VALUE obj = rb_digest_base_alloc(klass);
+ VALUE str1, str2;
- algo = get_digest_base_metadata(klass);
- Data_Get_Struct(obj, void, pctx);
+ if (rb_obj_is_kind_of(other, rb_mDigest_Instance) == Qtrue) {
+ str1 = rb_digest_instance_digest(0, 0, self);
+ str2 = rb_digest_instance_digest(0, 0, other);
+ } else {
+ str1 = rb_digest_instance_to_s(self);
+ str2 = other;
+ }
- StringValue(str);
- algo->update_func(pctx, RSTRING(str)->ptr, RSTRING(str)->len);
+ /* never blindly assume that subclass methods return strings */
+ StringValue(str1);
+ StringValue(str2);
- len = algo->digest_len;
+ if (RSTRING_LEN(str1) == RSTRING_LEN(str2) &&
+ rb_str_cmp(str1, str2) == 0) {
+ return Qtrue;
+ }
+ return Qfalse;
+}
- digest = xmalloc(len);
- algo->final_func(digest, pctx);
+/*
+ * call-seq:
+ * digest_obj.digest_length -> integer
+ *
+ * Returns the length of the hash value of the digest.
+ *
+ * This method should be overridden by each implementation subclass.
+ * If not, digest_obj.digest().length() is returned.
+ */
+static VALUE
+rb_digest_instance_digest_length(VALUE self)
+{
+ /* subclasses really should redefine this method */
+ VALUE digest = rb_digest_instance_digest(0, 0, self);
- obj = rb_str_new(digest, len);
+ /* never blindly assume that #digest() returns a string */
+ StringValue(digest);
+ return INT2NUM(RSTRING_LEN(digest));
+}
- free(digest);
+/*
+ * call-seq:
+ * digest_obj.length -> integer
+ * digest_obj.size -> integer
+ *
+ * Returns digest_obj.digest_length().
+ */
+static VALUE
+rb_digest_instance_length(VALUE self)
+{
+ return rb_funcall(self, id_digest_length, 0);
+}
- return obj;
+/*
+ * call-seq:
+ * digest_obj.block_length -> integer
+ *
+ * Returns the block length of the digest.
+ *
+ * This method is overridden by each implementation subclass.
+ */
+static VALUE
+rb_digest_instance_block_length(VALUE self)
+{
+ rb_raise(rb_eRuntimeError, "%s does not implement block_length()", rb_inspect(self));
}
+/*
+ * Document-class: Digest::Class
+ *
+ * This module stands as a base class for digest implementation
+ * classes.
+ */
+
+/*
+ * call-seq:
+ * Digest::Class.digest(string, *parameters) -> hash_string
+ *
+ * Returns the hash value of a given _string_. This is equivalent to
+ * Digest::Class.new(*parameters).digest(string), where extra
+ * _parameters_, if any, are passed through to the constructor and the
+ * _string_ is passed to #digest().
+ */
static VALUE
-rb_digest_base_s_hexdigest(klass, str)
- VALUE klass;
- VALUE str;
+rb_digest_class_s_digest(int argc, VALUE *argv, VALUE klass)
{
- algo_t *algo;
+ VALUE str;
void *pctx;
- size_t len;
- unsigned char *hexdigest;
- volatile VALUE obj = rb_digest_base_alloc(klass);
+ volatile VALUE obj;
- algo = get_digest_base_metadata(klass);
- Data_Get_Struct(obj, void, pctx);
+ if (argc < 1) {
+ rb_raise(rb_eArgError, "no data given");
+ }
+
+ str = *argv++;
+ argc--;
StringValue(str);
- algo->update_func(pctx, RSTRING(str)->ptr, RSTRING(str)->len);
- len = algo->digest_len * 2;
+ obj = rb_obj_alloc(klass);
+ rb_obj_call_init(obj, argc, argv);
+
+ return rb_funcall(obj, id_digest, 1, str);
+}
+
+/*
+ * call-seq:
+ * Digest::Class.hexdigest(string[, ...]) -> hash_string
+ *
+ * Returns the hex-encoded hash value of a given _string_. This is
+ * almost equivalent to
+ * Digest.hexencode(Digest::Class.new(*parameters).digest(string)).
+ */
+static VALUE
+rb_digest_class_s_hexdigest(int argc, VALUE *argv, VALUE klass)
+{
+ return hexencode_str_new(rb_funcall2(klass, id_digest, argc, argv));
+}
+
+/*
+ * Document-class: Digest::Base
+ *
+ * This abstract class provides a common interface to message digest
+ * implementation classes written in C.
+ */
+
+static rb_digest_metadata_t *
+get_digest_base_metadata(VALUE klass)
+{
+ VALUE p;
+ VALUE obj;
+ rb_digest_metadata_t *algo;
+
+ for (p = klass; p; p = RCLASS(p)->super) {
+ if (rb_ivar_defined(p, id_metadata)) {
+ obj = rb_ivar_get(p, id_metadata);
+ break;
+ }
+ }
+
+ if (!p)
+ rb_raise(rb_eRuntimeError, "Digest::Base cannot be directly inherited in Ruby");
+
+ Data_Get_Struct(obj, rb_digest_metadata_t, algo);
- hexdigest = xmalloc(len + 1); /* +1 is for '\0' */
- algo->end_func(pctx, hexdigest);
+ switch (algo->api_version) {
+ case 2:
+ break;
- obj = rb_str_new(hexdigest, len);
+ /*
+ * put conversion here if possible when API is updated
+ */
- free(hexdigest);
+ default:
+ rb_raise(rb_eRuntimeError, "Incompatible digest API version");
+ }
+
+ return algo;
+}
+
+static VALUE
+rb_digest_base_alloc(VALUE klass)
+{
+ rb_digest_metadata_t *algo;
+ VALUE obj;
+ void *pctx;
+
+ if (klass == rb_cDigest_Base) {
+ rb_raise(rb_eNotImpError, "Digest::Base is an abstract class");
+ }
+
+ algo = get_digest_base_metadata(klass);
+
+ pctx = xmalloc(algo->ctx_size);
+ algo->init_func(pctx);
+
+ obj = Data_Wrap_Struct(klass, 0, free, pctx);
return obj;
}
+/* :nodoc: */
static VALUE
-rb_digest_base_copy(copy, obj)
- VALUE copy, obj;
+rb_digest_base_copy(VALUE copy, VALUE obj)
{
- algo_t *algo;
+ rb_digest_metadata_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);
@@ -160,157 +495,149 @@ rb_digest_base_copy(copy, obj)
return copy;
}
+/* :nodoc: */
static VALUE
-rb_digest_base_update(self, str)
- VALUE self, str;
+rb_digest_base_reset(VALUE self)
{
- algo_t *algo;
+ rb_digest_metadata_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);
+ algo->init_func(pctx);
return self;
}
+/* :nodoc: */
static VALUE
-rb_digest_base_init(argc, argv, self)
- int argc;
- VALUE* argv;
- VALUE self;
+rb_digest_base_update(VALUE self, VALUE str)
{
- VALUE arg;
+ rb_digest_metadata_t *algo;
+ void *pctx;
+
+ algo = get_digest_base_metadata(rb_obj_class(self));
- rb_scan_args(argc, argv, "01", &arg);
+ Data_Get_Struct(self, void, pctx);
- if (!NIL_P(arg)) rb_digest_base_update(self, arg);
+ StringValue(str);
+ algo->update_func(pctx, (unsigned char *)RSTRING_PTR(str), RSTRING_LEN(str));
return self;
}
+/* :nodoc: */
static VALUE
-rb_digest_base_digest(self)
- VALUE self;
+rb_digest_base_finish(VALUE self)
{
- algo_t *algo;
- void *pctx1, *pctx2;
- unsigned char *digest;
- size_t len;
+ rb_digest_metadata_t *algo;
+ void *pctx;
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);
+ Data_Get_Struct(self, void, pctx);
- str = rb_str_new(digest, len);
+ str = rb_str_new(0, algo->digest_len);
+ algo->finish_func(pctx, (unsigned char *)RSTRING_PTR(str));
- free(digest);
- free(pctx2);
+ /* avoid potential coredump caused by use of a finished context */
+ algo->init_func(pctx);
return str;
}
+/* :nodoc: */
static VALUE
-rb_digest_base_hexdigest(self)
- VALUE self;
+rb_digest_base_digest_length(VALUE self)
{
- algo_t *algo;
- void *pctx1, *pctx2;
- unsigned char *hexdigest;
- size_t len;
- VALUE str;
+ rb_digest_metadata_t *algo;
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;
+ return INT2NUM(algo->digest_len);
}
+/* :nodoc: */
static VALUE
-rb_digest_base_equal(self, other)
- VALUE self, other;
+rb_digest_base_block_length(VALUE self)
{
- algo_t *algo;
- VALUE klass;
- VALUE str1, str2;
-
- klass = rb_obj_class(self);
- algo = get_digest_base_metadata(klass);
+ rb_digest_metadata_t *algo;
- 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;
+ algo = get_digest_base_metadata(rb_obj_class(self));
- return Qfalse;
+ return INT2NUM(algo->block_len);
}
-/*
- * Init
- */
-
void
-Init_digest()
+Init_digest(void)
{
- mDigest = rb_define_module("Digest");
+ id_reset = rb_intern("reset");
+ id_update = rb_intern("update");
+ id_finish = rb_intern("finish");
+ id_digest = rb_intern("digest");
+ id_hexdigest = rb_intern("hexdigest");
+ id_digest_length = rb_intern("digest_length");
+
+ /*
+ * module Digest
+ */
+ rb_mDigest = rb_define_module("Digest");
+
+ /* module functions */
+ rb_define_module_function(rb_mDigest, "hexencode", rb_digest_s_hexencode, 1);
+
+ /*
+ * module Digest::Instance
+ */
+ rb_mDigest_Instance = rb_define_module_under(rb_mDigest, "Instance");
+
+ /* instance methods that should be overridden */
+ rb_define_method(rb_mDigest_Instance, "update", rb_digest_instance_update, 1);
+ rb_define_method(rb_mDigest_Instance, "<<", rb_digest_instance_update, 1);
+ rb_define_private_method(rb_mDigest_Instance, "finish", rb_digest_instance_finish, 0);
+ rb_define_method(rb_mDigest_Instance, "reset", rb_digest_instance_reset, 0);
+ rb_define_method(rb_mDigest_Instance, "digest_length", rb_digest_instance_digest_length, 0);
+ rb_define_method(rb_mDigest_Instance, "block_length", rb_digest_instance_block_length, 0);
+
+ /* instance methods that may be overridden */
+ rb_define_method(rb_mDigest_Instance, "==", rb_digest_instance_equal, 1);
+ rb_define_method(rb_mDigest_Instance, "inspect", rb_digest_instance_inspect, 0);
+
+ /* instance methods that need not usually be overridden */
+ rb_define_method(rb_mDigest_Instance, "new", rb_digest_instance_new, 0);
+ rb_define_method(rb_mDigest_Instance, "digest", rb_digest_instance_digest, -1);
+ rb_define_method(rb_mDigest_Instance, "digest!", rb_digest_instance_digest_bang, 0);
+ rb_define_method(rb_mDigest_Instance, "hexdigest", rb_digest_instance_hexdigest, -1);
+ rb_define_method(rb_mDigest_Instance, "hexdigest!", rb_digest_instance_hexdigest_bang, 0);
+ rb_define_method(rb_mDigest_Instance, "to_s", rb_digest_instance_to_s, 0);
+ rb_define_method(rb_mDigest_Instance, "length", rb_digest_instance_length, 0);
+ rb_define_method(rb_mDigest_Instance, "size", rb_digest_instance_length, 0);
+
+ /*
+ * class Digest::Class
+ */
+ rb_cDigest_Class = rb_define_class_under(rb_mDigest, "Class", rb_cObject);
+ rb_include_module(rb_cDigest_Class, rb_mDigest_Instance);
+
+ /* class methods */
+ rb_define_singleton_method(rb_cDigest_Class, "digest", rb_digest_class_s_digest, -1);
+ rb_define_singleton_method(rb_cDigest_Class, "hexdigest", rb_digest_class_s_hexdigest, -1);
- cDigest_Base = rb_define_class_under(mDigest, "Base", rb_cObject);
+ id_metadata = rb_intern("metadata");
- 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);
+ /* class Digest::Base < Digest::Class */
+ rb_cDigest_Base = rb_define_class_under(rb_mDigest, "Base", rb_cDigest_Class);
- 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);
+ rb_define_alloc_func(rb_cDigest_Base, rb_digest_base_alloc);
- id_metadata = rb_intern("metadata");
+ rb_define_method(rb_cDigest_Base, "initialize_copy", rb_digest_base_copy, 1);
+ rb_define_method(rb_cDigest_Base, "reset", rb_digest_base_reset, 0);
+ rb_define_method(rb_cDigest_Base, "update", rb_digest_base_update, 1);
+ rb_define_method(rb_cDigest_Base, "<<", rb_digest_base_update, 1);
+ rb_define_private_method(rb_cDigest_Base, "finish", rb_digest_base_finish, 0);
+ rb_define_method(rb_cDigest_Base, "digest_length", rb_digest_base_digest_length, 0);
+ rb_define_method(rb_cDigest_Base, "block_length", rb_digest_base_block_length, 0);
}
diff --git a/ext/digest/digest.h b/ext/digest/digest.h
index 578be0a3c4..6e4906c859 100644
--- a/ext/digest/digest.h
+++ b/ext/digest/digest.h
@@ -1,32 +1,32 @@
/************************************************
- digest.c -
+ digest.h - header file for ruby digest modules
- $Author: knu $
+ $Author$
created at: Fri May 25 08:54:56 JST 2001
- Copyright (C) 2001 Akinori MUSHA
+ Copyright (C) 2001-2006 Akinori MUSHA
$RoughId: digest.h,v 1.3 2001/07/13 15:38:27 knu Exp $
- $Id: digest.h,v 1.1 2001/07/13 20:06:13 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 *));
+#define RUBY_DIGEST_API_VERSION 2
+
+typedef void (*rb_digest_hash_init_func_t)(void *);
+typedef void (*rb_digest_hash_update_func_t)(void *, unsigned char *, size_t);
+typedef void (*rb_digest_hash_finish_func_t)(void *, unsigned char *);
typedef struct {
+ int api_version;
size_t digest_len;
+ size_t block_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;
+ rb_digest_hash_init_func_t init_func;
+ rb_digest_hash_update_func_t update_func;
+ rb_digest_hash_finish_func_t finish_func;
+} rb_digest_metadata_t;
diff --git a/ext/digest/digest.txt b/ext/digest/digest.txt
deleted file mode 100644
index 4969a9da90..0000000000
--- a/ext/digest/digest.txt
+++ /dev/null
@@ -1,113 +0,0 @@
-.\" 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: digest.txt,v 1.1 2001/07/13 20:06:13 knu Exp $
-
-** 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
deleted file mode 100644
index 7078c83573..0000000000
--- a/ext/digest/digest.txt.ja
+++ /dev/null
@@ -1,111 +0,0 @@
-.\" 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: digest.txt.ja,v 1.1 2001/07/19 05:42:07 knu Exp $
-
-** 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
index 3e35bf5064..cf9127ecc0 100644
--- a/ext/digest/extconf.rb
+++ b/ext/digest/extconf.rb
@@ -1,6 +1,10 @@
# $RoughId: extconf.rb,v 1.6 2001/07/13 15:38:27 knu Exp $
-# $Id: extconf.rb,v 1.1 2001/07/13 20:06:13 knu Exp $
+# $Id$
require "mkmf"
+$INSTALLFILES = {
+ "digest.h" => "$(RUBYARCHDIR)"
+}
+
create_makefile("digest")
diff --git a/ext/digest/lib/digest.rb b/ext/digest/lib/digest.rb
new file mode 100644
index 0000000000..244cd436b3
--- /dev/null
+++ b/ext/digest/lib/digest.rb
@@ -0,0 +1,48 @@
+require 'digest.so'
+
+module Digest
+ def self.const_missing(name)
+ case name
+ when :SHA256, :SHA384, :SHA512
+ lib = 'digest/sha2.so'
+ else
+ lib = File.join('digest', name.to_s.downcase)
+ end
+
+ begin
+ require lib
+ rescue LoadError => e
+ raise LoadError, "library not found for class Digest::#{name} -- #{lib}"
+ end
+
+ Digest.const_get(name)
+ end
+
+ class ::Digest::Class
+ # creates a digest object and reads a given file, _name_.
+ #
+ # p Digest::SHA256.file("X11R6.8.2-src.tar.bz2").hexdigest
+ # # => "f02e3c85572dc9ad7cb77c2a638e3be24cc1b5bea9fdbb0b0299c9668475c534"
+ def self.file(name)
+ new.file(name)
+ end
+ end
+
+ module Instance
+ # updates the digest with the contents of a given file _name_ and
+ # returns self.
+ def file(name)
+ File.open(name, "rb") {|f|
+ buf = ""
+ while f.read(16384, buf)
+ update buf
+ end
+ }
+ self
+ end
+ end
+end
+
+def Digest(name)
+ Digest.const_get(name)
+end
diff --git a/ext/digest/lib/md5.rb b/ext/digest/lib/md5.rb
index 6867fdc71b..c399f2de1d 100644
--- a/ext/digest/lib/md5.rb
+++ b/ext/digest/lib/md5.rb
@@ -1,14 +1,23 @@
# just for compatibility; requiring "md5" is obsoleted
#
# $RoughId: md5.rb,v 1.4 2001/07/13 15:38:27 knu Exp $
-# $Id: md5.rb,v 1.1 2001/07/13 20:06:14 knu Exp $
+# $Id$
require 'digest/md5'
-MD5 = Digest::MD5
+class MD5 < Digest::MD5
+ class << self
+ alias orig_new new
+ def new(str = nil)
+ if str
+ orig_new.update(str)
+ else
+ orig_new
+ end
+ end
-class MD5
- def self.md5(*args)
- new(*args)
+ def md5(*args)
+ new(*args)
+ end
end
end
diff --git a/ext/digest/lib/sha1.rb b/ext/digest/lib/sha1.rb
index 12fb5cdfa4..4446e12e8d 100644
--- a/ext/digest/lib/sha1.rb
+++ b/ext/digest/lib/sha1.rb
@@ -1,14 +1,23 @@
# just for compatibility; requiring "sha1" is obsoleted
#
# $RoughId: sha1.rb,v 1.4 2001/07/13 15:38:27 knu Exp $
-# $Id: sha1.rb,v 1.1 2001/07/13 20:06:14 knu Exp $
+# $Id$
require 'digest/sha1'
-SHA1 = Digest::SHA1
+class SHA1 < Digest::SHA1
+ class << self
+ alias orig_new new
+ def new(str = nil)
+ if str
+ orig_new.update(str)
+ else
+ orig_new
+ end
+ end
-class SHA1
- def self.sha1(*args)
- new(*args)
+ def sha1(*args)
+ new(*args)
+ end
end
end
diff --git a/ext/digest/md5/extconf.rb b/ext/digest/md5/extconf.rb
index ea29c9c5f8..018f8ccb02 100644
--- a/ext/digest/md5/extconf.rb
+++ b/ext/digest/md5/extconf.rb
@@ -1,5 +1,5 @@
# $RoughId: extconf.rb,v 1.3 2001/08/14 19:54:51 knu Exp $
-# $Id: extconf.rb,v 1.4.2.2 2006/05/25 23:44:05 nobu Exp $
+# $Id$
require "mkmf"
@@ -24,4 +24,6 @@ have_header("inttypes.h")
have_header("unistd.h")
+$preload = %w[digest]
+
create_makefile("digest/md5")
diff --git a/ext/digest/md5/md5.c b/ext/digest/md5/md5.c
index ed32cf95c1..993bc47a06 100644
--- a/ext/digest/md5/md5.c
+++ b/ext/digest/md5/md5.c
@@ -41,9 +41,15 @@
1999-05-03 lpd Original version.
*/
+/*
+ This code was modified for use in Ruby.
+
+ - Akinori MUSHA <knu@idaemons.org>
+ */
+
/*$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: md5.c,v 1.1 2001/07/13 20:06:14 knu Exp $ */
+/*$Id$ */
#include "md5.h"
@@ -391,7 +397,7 @@ MD5_Update(MD5_CTX *pms, const uint8_t *data, size_t nbytes)
}
void
-MD5_Final(uint8_t *digest, MD5_CTX *pms)
+MD5_Finish(MD5_CTX *pms, uint8_t *digest)
{
static const uint8_t pad[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -412,21 +418,3 @@ MD5_Final(uint8_t *digest, MD5_CTX *pms)
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
index 736e034512..f4580ef5e7 100644
--- a/ext/digest/md5/md5.h
+++ b/ext/digest/md5/md5.h
@@ -41,7 +41,7 @@
/* $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: md5.h,v 1.2 2002/02/24 08:20:22 knu Exp $ */
+/* $Id$ */
#ifndef MD5_INCLUDED
# define MD5_INCLUDED
@@ -63,18 +63,15 @@ typedef struct md5_state_s {
} MD5_CTX;
#ifdef RUBY
+/* avoid name clash */
#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
+#define MD5_Finish rb_Digest_MD5_Finish
#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));
+void MD5_Finish _((MD5_CTX *pms, uint8_t *digest));
#define MD5_BLOCK_LENGTH 64
#define MD5_DIGEST_LENGTH 16
diff --git a/ext/digest/md5/md5init.c b/ext/digest/md5/md5init.c
index 52f5de540f..17658f4fce 100644
--- a/ext/digest/md5/md5init.c
+++ b/ext/digest/md5/md5init.c
@@ -1,5 +1,5 @@
/* $RoughId: md5init.c,v 1.2 2001/07/13 19:49:10 knu Exp $ */
-/* $Id: md5init.c,v 1.5 2002/09/26 16:27:23 knu Exp $ */
+/* $Id$ */
#include "digest.h"
#if defined(HAVE_OPENSSL_MD5_H)
@@ -8,28 +8,33 @@
#include "md5.h"
#endif
-static algo_t md5 = {
+static rb_digest_metadata_t md5 = {
+ RUBY_DIGEST_API_VERSION,
MD5_DIGEST_LENGTH,
+ MD5_BLOCK_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,
+ (rb_digest_hash_init_func_t)MD5_Init,
+ (rb_digest_hash_update_func_t)MD5_Update,
+ (rb_digest_hash_finish_func_t)MD5_Finish,
};
+/*
+ * A class for calculating message digests using the MD5
+ * Message-Digest Algorithm by RSA Data Security, Inc., described in
+ * RFC1321.
+ */
void
Init_md5()
{
VALUE mDigest, cDigest_Base, cDigest_MD5;
- rb_require("digest.so");
+ rb_require("digest");
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);
+ rb_ivar_set(cDigest_MD5, rb_intern("metadata"),
+ Data_Wrap_Struct(rb_cObject, 0, 0, &md5));
}
diff --git a/ext/digest/md5/md5ossl.c b/ext/digest/md5/md5ossl.c
index 4af7d19ba5..d94ae2cd2f 100644
--- a/ext/digest/md5/md5ossl.c
+++ b/ext/digest/md5/md5ossl.c
@@ -1,30 +1,9 @@
-/* $Id: md5ossl.c,v 1.2 2003/01/06 11:47:53 knu Exp $ */
+/* $Id$ */
#include "md5ossl.h"
-#include <sys/types.h>
-#include <stdio.h>
-#include <string.h>
void
-MD5_End(MD5_CTX *pctx, unsigned char *hexdigest)
+MD5_Finish(MD5_CTX *pctx, unsigned char *digest)
{
- 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
index 401ef3418d..1680c4f5c9 100644
--- a/ext/digest/md5/md5ossl.h
+++ b/ext/digest/md5/md5ossl.h
@@ -1,4 +1,4 @@
-/* $Id: md5ossl.h,v 1.1.2.1 2005/08/30 10:43:34 gotoyuzo Exp $ */
+/* $Id$ */
#ifndef MD5OSSL_H_INCLUDED
#define MD5OSSL_H_INCLUDED
@@ -6,7 +6,8 @@
#include <stddef.h>
#include <openssl/md5.h>
-void MD5_End(MD5_CTX *pctx, unsigned char *hexdigest);
-int MD5_Equal(MD5_CTX *pctx1, MD5_CTX *pctx2);
+#define MD5_BLOCK_LENGTH MD5_CBLOCK
+
+void MD5_Finish(MD5_CTX *pctx, unsigned char *digest);
#endif
diff --git a/ext/digest/rmd160/depend b/ext/digest/rmd160/depend
index 0ca79c5f40..a21d7188dc 100644
--- a/ext/digest/rmd160/depend
+++ b/ext/digest/rmd160/depend
@@ -1,7 +1,5 @@
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
diff --git a/ext/digest/rmd160/extconf.rb b/ext/digest/rmd160/extconf.rb
index 232a3a5e06..09359944f2 100644
--- a/ext/digest/rmd160/extconf.rb
+++ b/ext/digest/rmd160/extconf.rb
@@ -1,5 +1,5 @@
# $RoughId: extconf.rb,v 1.3 2001/08/14 19:54:51 knu Exp $
-# $Id: extconf.rb,v 1.4.2.2 2006/05/25 23:44:05 nobu Exp $
+# $Id$
require "mkmf"
@@ -14,7 +14,7 @@ if !with_config("bundled-rmd160") &&
have_library("crypto") && have_header("openssl/ripemd.h")
$objs << "rmd160ossl.#{$OBJEXT}"
else
- $objs << "rmd160.#{$OBJEXT}" << "rmd160hl.#{$OBJEXT}"
+ $objs << "rmd160.#{$OBJEXT}"
end
have_header("sys/cdefs.h")
@@ -23,4 +23,6 @@ have_header("inttypes.h")
have_header("unistd.h")
+$preload = %w[digest]
+
create_makefile("digest/rmd160")
diff --git a/ext/digest/rmd160/rmd160.c b/ext/digest/rmd160/rmd160.c
index 9562a6fe67..88918728cd 100644
--- a/ext/digest/rmd160/rmd160.c
+++ b/ext/digest/rmd160/rmd160.c
@@ -1,6 +1,6 @@
/* $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: rmd160.c,v 1.1 2001/07/13 20:06:14 knu Exp $ */
+/* $Id$ */
/********************************************************************\
*
@@ -409,7 +409,7 @@ RMD160_Update(RMD160_CTX *context, const uint8_t *data, size_t nbytes)
/********************************************************************/
void
-RMD160_Final(uint8_t digest[20], RMD160_CTX *context)
+RMD160_Finish(RMD160_CTX *context, uint8_t digest[20])
{
uint32_t i;
uint32_t X[16];
@@ -454,11 +454,4 @@ RMD160_Final(uint8_t digest[20], RMD160_CTX *context)
}
}
-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
index 7df190413e..54d1ca9140 100644
--- a/ext/digest/rmd160/rmd160.h
+++ b/ext/digest/rmd160/rmd160.h
@@ -1,6 +1,6 @@
/* $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: rmd160.h,v 1.2 2002/02/24 08:20:22 knu Exp $ */
+/* $Id$ */
/********************************************************************\
*
@@ -39,26 +39,14 @@ typedef struct {
#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 */
+#define RMD160_Finish rb_Digest_RMD160_Finish
#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 */
+void RMD160_Finish _((RMD160_CTX *, uint8_t[20]));
__END_DECLS
#define RMD160_BLOCK_LENGTH 64
diff --git a/ext/digest/rmd160/rmd160hl.c b/ext/digest/rmd160/rmd160hl.c
deleted file mode 100644
index 14299d7c7a..0000000000
--- a/ext/digest/rmd160/rmd160hl.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/* $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,v 1.1 2001/07/13 20:06:14 knu Exp $ */
-
-/* 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
index 3aa7847019..763867df86 100644
--- a/ext/digest/rmd160/rmd160init.c
+++ b/ext/digest/rmd160/rmd160init.c
@@ -1,5 +1,5 @@
/* $RoughId: rmd160init.c,v 1.3 2001/07/13 20:00:43 knu Exp $ */
-/* $Id: rmd160init.c,v 1.3 2002/09/26 17:26:46 knu Exp $ */
+/* $Id$ */
#include "digest.h"
#if defined(HAVE_OPENSSL_RIPEMD_H)
@@ -8,31 +8,33 @@
#include "rmd160.h"
#endif
-static algo_t rmd160 = {
+static rb_digest_metadata_t rmd160 = {
+ RUBY_DIGEST_API_VERSION,
RMD160_DIGEST_LENGTH,
+ RMD160_BLOCK_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,
+ (rb_digest_hash_init_func_t)RMD160_Init,
+ (rb_digest_hash_update_func_t)RMD160_Update,
+ (rb_digest_hash_finish_func_t)RMD160_Finish,
};
+/*
+ * A class for calculating message digests using RIPEMD-160
+ * cryptographic hash function, designed by Hans Dobbertin, Antoon
+ * Bosselaers, and Bart Preneel.
+ */
void
Init_rmd160()
{
VALUE mDigest, cDigest_Base, cDigest_RMD160;
- ID id_metadata;
- rb_require("digest.so");
+ rb_require("digest");
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);
+ rb_ivar_set(cDigest_RMD160, rb_intern("metadata"),
+ Data_Wrap_Struct(rb_cObject, 0, 0, &rmd160));
}
diff --git a/ext/digest/rmd160/rmd160ossl.c b/ext/digest/rmd160/rmd160ossl.c
index 1a8436dfb8..f24e63e3d8 100644
--- a/ext/digest/rmd160/rmd160ossl.c
+++ b/ext/digest/rmd160/rmd160ossl.c
@@ -1,45 +1,8 @@
-/* $Id: rmd160ossl.c,v 1.1.2.1 2006/08/07 09:01:27 matz Exp $ */
+/* $Id$ */
#include "defs.h"
#include "rmd160ossl.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;
+void RMD160_Finish(RMD160_CTX *ctx, char *buf) {
+ RIPEMD160_Final((unsigned char *)buf, ctx);
}
diff --git a/ext/digest/rmd160/rmd160ossl.h b/ext/digest/rmd160/rmd160ossl.h
index 30840ca598..3df38a01c0 100644
--- a/ext/digest/rmd160/rmd160ossl.h
+++ b/ext/digest/rmd160/rmd160ossl.h
@@ -1,4 +1,4 @@
-/* $Id: rmd160ossl.h,v 1.1.2.1 2005/08/30 10:43:35 gotoyuzo Exp $ */
+/* $Id$ */
#ifndef RMD160OSSL_H_INCLUDED
#define RMD160OSSL_H_INCLUDED
@@ -10,12 +10,10 @@
#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);
+void RMD160_Finish(RMD160_CTX *ctx, char *buf);
#endif
diff --git a/ext/digest/sha1/depend b/ext/digest/sha1/depend
index a159f456d3..61607844d0 100644
--- a/ext/digest/sha1/depend
+++ b/ext/digest/sha1/depend
@@ -1,7 +1,5 @@
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
diff --git a/ext/digest/sha1/extconf.rb b/ext/digest/sha1/extconf.rb
index 861c5563f9..87b74c34af 100644
--- a/ext/digest/sha1/extconf.rb
+++ b/ext/digest/sha1/extconf.rb
@@ -1,5 +1,5 @@
# $RoughId: extconf.rb,v 1.3 2001/08/14 19:54:51 knu Exp $
-# $Id: extconf.rb,v 1.5.2.1 2006/05/25 23:44:05 nobu Exp $
+# $Id$
require "mkmf"
@@ -14,7 +14,7 @@ if !with_config("bundled-sha1") &&
have_library("crypto") && have_header("openssl/sha.h")
$objs << "sha1ossl.#{$OBJEXT}"
else
- $objs << "sha1.#{$OBJEXT}" << "sha1hl.#{$OBJEXT}"
+ $objs << "sha1.#{$OBJEXT}"
end
have_header("sys/cdefs.h")
@@ -23,4 +23,6 @@ have_header("inttypes.h")
have_header("unistd.h")
+$preload = %w[digest]
+
create_makefile("digest/sha1")
diff --git a/ext/digest/sha1/sha1.c b/ext/digest/sha1/sha1.c
index ba926e1fad..6196ca6b82 100644
--- a/ext/digest/sha1/sha1.c
+++ b/ext/digest/sha1/sha1.c
@@ -1,7 +1,7 @@
/* $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: sha1.c,v 1.1 2001/07/13 20:06:14 knu Exp $ */
+/* $Id$ */
/*
* SHA-1 in C
@@ -129,9 +129,7 @@ do_R4(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LON
/*
* 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];
+void SHA1_Transform(uint32_t state[5], const uint8_t buffer[64])
{
uint32_t a, b, c, d, e;
CHAR64LONG16 *block;
@@ -201,8 +199,7 @@ void SHA1_Transform(state, buffer)
/*
* SHA1_Init - Initialize new context
*/
-void SHA1_Init(context)
- SHA1_CTX *context;
+void SHA1_Init(SHA1_CTX *context)
{
_DIAGASSERT(context != 0);
@@ -220,10 +217,7 @@ void SHA1_Init(context)
/*
* Run your data through this.
*/
-void SHA1_Update(context, data, len)
- SHA1_CTX *context;
- const uint8_t *data;
- size_t len;
+void SHA1_Update(SHA1_CTX *context, const uint8_t *data, size_t len)
{
uint32_t i, j;
@@ -250,9 +244,7 @@ void SHA1_Update(context, data, len)
/*
* Add padding and return the message digest.
*/
-void SHA1_Final(digest, context)
- uint8_t digest[20];
- SHA1_CTX* context;
+void SHA1_Finish(SHA1_CTX* context, uint8_t digest[20])
{
size_t i;
uint8_t finalcount[8];
@@ -275,9 +267,3 @@ void SHA1_Final(digest, context)
((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
index 5a1143ea0d..60e3b01fe2 100644
--- a/ext/digest/sha1/sha1.h
+++ b/ext/digest/sha1/sha1.h
@@ -1,6 +1,6 @@
/* $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: sha1.h,v 1.2 2002/02/24 08:20:22 knu Exp $ */
+/* $Id$ */
/*
* SHA-1 in C
@@ -20,28 +20,17 @@ typedef struct {
} SHA1_CTX;
#ifdef RUBY
+/* avoid name clash */
#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 */
+#define SHA1_Finish rb_Digest_SHA1_Finish
#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 */
+void SHA1_Finish _((SHA1_CTX *context, uint8_t digest[20]));
#define SHA1_BLOCK_LENGTH 64
#define SHA1_DIGEST_LENGTH 20
diff --git a/ext/digest/sha1/sha1hl.c b/ext/digest/sha1/sha1hl.c
deleted file mode 100644
index 47b802085d..0000000000
--- a/ext/digest/sha1/sha1hl.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/* $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,v 1.1 2001/07/13 20:06:14 knu Exp $ */
-
-/* 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
index 829a363921..b2146f05a9 100644
--- a/ext/digest/sha1/sha1init.c
+++ b/ext/digest/sha1/sha1init.c
@@ -1,5 +1,5 @@
/* $RoughId: sha1init.c,v 1.2 2001/07/13 19:49:10 knu Exp $ */
-/* $Id: sha1init.c,v 1.3 2002/09/26 17:44:33 knu Exp $ */
+/* $Id$ */
#include "digest.h"
#if defined(HAVE_OPENSSL_SHA_H)
@@ -8,31 +8,33 @@
#include "sha1.h"
#endif
-static algo_t sha1 = {
+static rb_digest_metadata_t sha1 = {
+ RUBY_DIGEST_API_VERSION,
SHA1_DIGEST_LENGTH,
+ SHA1_BLOCK_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,
+ (rb_digest_hash_init_func_t)SHA1_Init,
+ (rb_digest_hash_update_func_t)SHA1_Update,
+ (rb_digest_hash_finish_func_t)SHA1_Finish,
};
+/*
+ * A class for calculating message digests using the SHA-1 Secure Hash
+ * Algorithm by NIST (the US' National Institute of Standards and
+ * Technology), described in FIPS PUB 180-1.
+ */
void
Init_sha1()
{
VALUE mDigest, cDigest_Base, cDigest_SHA1;
- ID id_metadata;
-
- rb_require("digest.so");
-
+
+ rb_require("digest");
+
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);
+ rb_ivar_set(cDigest_SHA1, rb_intern("metadata"),
+ Data_Wrap_Struct(rb_cObject, 0, 0, &sha1));
}
diff --git a/ext/digest/sha1/sha1ossl.c b/ext/digest/sha1/sha1ossl.c
index 72c6eb4092..452cf35084 100644
--- a/ext/digest/sha1/sha1ossl.c
+++ b/ext/digest/sha1/sha1ossl.c
@@ -1,45 +1,10 @@
-/* $Id: sha1ossl.c,v 1.1.2.1 2006/08/07 09:01:27 matz Exp $ */
+/* $Id$ */
#include "defs.h"
#include "sha1ossl.h"
-#include <assert.h>
-#include <stdlib.h>
-#ifndef _DIAGASSERT
-#define _DIAGASSERT(cond) assert(cond)
-#endif
-
-char *
-SHA1_End(SHA1_CTX *ctx, char *buf)
+void
+SHA1_Finish(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;
+ SHA1_Final((unsigned char *)buf, ctx);
}
diff --git a/ext/digest/sha1/sha1ossl.h b/ext/digest/sha1/sha1ossl.h
index 24b84b4274..8f9984cc64 100644
--- a/ext/digest/sha1/sha1ossl.h
+++ b/ext/digest/sha1/sha1ossl.h
@@ -1,4 +1,4 @@
-/* $Id: sha1ossl.h,v 1.1.2.1 2005/08/30 10:43:36 gotoyuzo Exp $ */
+/* $Id$ */
#ifndef SHA1OSSL_H_INCLUDED
#define SHA1OSSL_H_INCLUDED
@@ -8,10 +8,13 @@
#define SHA1_CTX SHA_CTX
+#ifdef SHA_BLOCK_LENGTH
#define SHA1_BLOCK_LENGTH SHA_BLOCK_LENGTH
+#else
+#define SHA1_BLOCK_LENGTH SHA_CBLOCK
+#endif
#define SHA1_DIGEST_LENGTH SHA_DIGEST_LENGTH
-char *SHA1_End(SHA1_CTX *ctx, char *buf);
-int SHA1_Equal(SHA1_CTX *pctx1, SHA1_CTX *pctx2);
+void SHA1_Finish(SHA1_CTX *ctx, char *buf);
#endif
diff --git a/ext/digest/sha2/depend b/ext/digest/sha2/depend
index 2587415fdc..225d6ad52b 100644
--- a/ext/digest/sha2/depend
+++ b/ext/digest/sha2/depend
@@ -1,7 +1,5 @@
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
index 5d078f4bd6..c084a51a64 100644
--- a/ext/digest/sha2/extconf.rb
+++ b/ext/digest/sha2/extconf.rb
@@ -1,5 +1,5 @@
# $RoughId: extconf.rb,v 1.4 2001/08/14 19:54:51 knu Exp $
-# $Id: extconf.rb,v 1.7.2.2 2006/05/25 23:44:06 nobu Exp $
+# $Id$
require "mkmf"
@@ -8,7 +8,6 @@ $INCFLAGS << " -I$(srcdir)/.."
$objs = [
"sha2.#{$OBJEXT}",
- "sha2hl.#{$OBJEXT}",
"sha2init.#{$OBJEXT}",
]
@@ -18,6 +17,8 @@ have_header("inttypes.h")
have_header("unistd.h")
+$preload = %w[digest]
+
if have_type("uint64_t", "defs.h", $defs.join(' '))
create_makefile("digest/sha2")
end
diff --git a/ext/digest/sha2/lib/sha2.rb b/ext/digest/sha2/lib/sha2.rb
new file mode 100644
index 0000000000..52dd639f9b
--- /dev/null
+++ b/ext/digest/sha2/lib/sha2.rb
@@ -0,0 +1,73 @@
+#--
+# sha2.rb - defines Digest::SHA2 class which wraps up the SHA256,
+# SHA384, and SHA512 classes.
+#++
+# Copyright (c) 2006 Akinori MUSHA <knu@iDaemons.org>
+#
+# All rights reserved. You can redistribute and/or modify it under the same
+# terms as Ruby.
+#
+# $Id$
+
+require 'digest'
+
+module Digest
+ #
+ # A meta digest provider class for SHA256, SHA384 and SHA512.
+ #
+ class SHA2 < Digest::Class
+ # call-seq:
+ # Digest::SHA2.new(bitlen = 256) -> digest_obj
+ #
+ # Creates a new SHA2 hash object with a given bit length.
+ def initialize(bitlen = 256)
+ case bitlen
+ when 256
+ @sha2 = Digest::SHA256.new
+ when 384
+ @sha2 = Digest::SHA384.new
+ when 512
+ @sha2 = Digest::SHA512.new
+ else
+ raise ArgumentError, "unsupported bit length: %s" % bitlen.inspect
+ end
+ @bitlen = bitlen
+ end
+
+ # :nodoc:
+ def reset
+ @sha2.reset
+ self
+ end
+
+ # :nodoc:
+ def update(str)
+ @sha2.update(str)
+ self
+ end
+ alias << update
+
+ def finish
+ @sha2.digest!
+ end
+ private :finish
+
+ def block_length
+ @sha2.block_length
+ end
+
+ def digest_length
+ @sha2.digest_length
+ end
+
+ # :nodoc:
+ def initialize_copy(other)
+ @sha2 = other.instance_eval { @sha2.clone }
+ end
+
+ # :nodoc:
+ def inspect
+ "#<%s:%d %s>" % [self.class.name, @bitlen, hexdigest]
+ end
+ end
+end
diff --git a/ext/digest/sha2/sha2.c b/ext/digest/sha2/sha2.c
index 22e7d59cd3..aca9ee926f 100644
--- a/ext/digest/sha2/sha2.c
+++ b/ext/digest/sha2/sha2.c
@@ -34,7 +34,7 @@
*/
/* $RoughId: sha2.c,v 1.3 2002/02/26 22:03:36 knu Exp $ */
-/* $Id: sha2.c,v 1.4.2.1 2005/12/24 09:58:56 matz Exp $ */
+/* $Id$ */
#include "sha2.h"
#include <stdio.h>
@@ -515,7 +515,7 @@ void SHA256_Update(SHA256_CTX* context, const sha2_byte *data, size_t len) {
usedspace = freespace = 0;
}
-void SHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
+void SHA256_Finish(SHA256_CTX* context, sha2_byte digest[]) {
sha2_word32 *d = (sha2_word32*)digest;
unsigned int usedspace;
@@ -578,12 +578,6 @@ void SHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
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) {
@@ -852,7 +846,7 @@ void SHA512_Last(SHA512_CTX* context) {
SHA512_Transform(context, (const sha2_word64*)context->buffer);
}
-void SHA512_Final(sha2_byte digest[], SHA512_CTX* context) {
+void SHA512_Finish(SHA512_CTX* context, sha2_byte digest[]) {
sha2_word64 *d = (sha2_word64*)digest;
/* Sanity check: */
@@ -881,12 +875,6 @@ void SHA512_Final(sha2_byte digest[], SHA512_CTX* context) {
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) {
@@ -901,7 +889,7 @@ 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) {
+void SHA384_Finish(SHA384_CTX* context, sha2_byte digest[]) {
sha2_word64 *d = (sha2_word64*)digest;
/* Sanity check: */
@@ -929,9 +917,3 @@ void SHA384_Final(sha2_byte digest[], SHA384_CTX* context) {
/* 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
index 7ccf012b77..917d415b73 100644
--- a/ext/digest/sha2/sha2.h
+++ b/ext/digest/sha2/sha2.h
@@ -34,7 +34,7 @@
*/
/* $RoughId: sha2.h,v 1.3 2002/02/24 08:14:32 knu Exp $ */
-/* $Id: sha2.h,v 1.2 2002/02/24 08:20:22 knu Exp $ */
+/* $Id$ */
#ifndef __SHA2_H__
#define __SHA2_H__
@@ -77,53 +77,29 @@ 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 SHA256_Finish rb_Digest_SHA256_Finish
#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 SHA384_Finish rb_Digest_SHA384_Finish
#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
+#define SHA512_Finish rb_Digest_SHA512_Finish
#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 SHA256_Finish _((SHA256_CTX*, uint8_t[SHA256_DIGEST_LENGTH]));
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 SHA384_Finish _((SHA384_CTX*, uint8_t[SHA384_DIGEST_LENGTH]));
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*));
+void SHA512_Finish _((SHA512_CTX*, uint8_t[SHA512_DIGEST_LENGTH]));
#ifdef __cplusplus
}
diff --git a/ext/digest/sha2/sha2hl.c b/ext/digest/sha2/sha2hl.c
deleted file mode 100644
index 8f09bd6e5a..0000000000
--- a/ext/digest/sha2/sha2hl.c
+++ /dev/null
@@ -1,252 +0,0 @@
-/* $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,v 1.1 2001/07/13 20:06:14 knu Exp $ */
-
-/*
- * 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
index 9c0f9854fb..c83a29316a 100644
--- a/ext/digest/sha2/sha2init.c
+++ b/ext/digest/sha2/sha2init.c
@@ -1,5 +1,5 @@
/* $RoughId: sha2init.c,v 1.3 2001/07/13 20:00:43 knu Exp $ */
-/* $Id: sha2init.c,v 1.2 2002/02/17 12:43:44 nobu Exp $ */
+/* $Id$ */
#include "digest.h"
#include "sha2.h"
@@ -7,18 +7,23 @@
#define FOREACH_BITLEN(func) func(256) func(384) func(512)
#define DEFINE_ALGO_METADATA(bitlen) \
-static algo_t sha##bitlen = { \
+static rb_digest_metadata_t sha##bitlen = { \
+ RUBY_DIGEST_API_VERSION, \
SHA##bitlen##_DIGEST_LENGTH, \
+ SHA##bitlen##_BLOCK_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, \
+ (rb_digest_hash_init_func_t)SHA##bitlen##_Init, \
+ (rb_digest_hash_update_func_t)SHA##bitlen##_Update, \
+ (rb_digest_hash_finish_func_t)SHA##bitlen##_Finish, \
};
FOREACH_BITLEN(DEFINE_ALGO_METADATA)
+/*
+ * Classes for calculating message digests using 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.
+ */
void
Init_sha2()
{
@@ -30,7 +35,7 @@ Init_sha2()
FOREACH_BITLEN(DECLARE_ALGO_CLASS)
- rb_require("digest.so");
+ rb_require("digest");
id_metadata = rb_intern("metadata");
@@ -40,8 +45,8 @@ Init_sha2()
#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);
+ rb_ivar_set(cDigest_SHA##bitlen, id_metadata, \
+ Data_Wrap_Struct(rb_cObject, 0, 0, &sha##bitlen));
FOREACH_BITLEN(DEFINE_ALGO_CLASS)
}
diff --git a/ext/digest/test.sh b/ext/digest/test.sh
index 2ae2688e4d..328c7575e6 100644
--- a/ext/digest/test.sh
+++ b/ext/digest/test.sh
@@ -1,7 +1,7 @@
#!/bin/sh
#
# $RoughId: test.sh,v 1.5 2001/07/13 15:38:27 knu Exp $
-# $Id: test.sh,v 1.2 2002/09/26 17:55:16 knu Exp $
+# $Id$
RUBY=${RUBY:=ruby}
MAKE=${MAKE:=make}
@@ -11,8 +11,6 @@ ${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}"
@@ -27,7 +25,6 @@ for algo in md5 rmd160 sha1 sha2; do
ln -sf ../../$algo/$algo.so lib/digest/
done
-${RUBY} -I. -I./lib test.rb
+${RUBY} -I. -I./lib ../../test/digest/test_digest.rb
rm lib/digest/*.so
-rmdir lib/digest
diff --git a/ext/dl/dl.c b/ext/dl/dl.c
index 71c353bda3..5ba3646ea3 100644
--- a/ext/dl/dl.c
+++ b/ext/dl/dl.c
@@ -1,5 +1,5 @@
/*
- * $Id: dl.c,v 1.20.2.5 2005/12/16 13:32:06 ttate Exp $
+ * $Id$
*/
#include <ruby.h>
diff --git a/ext/dl/dl.h b/ext/dl/dl.h
index 9e4e01eea5..1faa316cf1 100644
--- a/ext/dl/dl.h
+++ b/ext/dl/dl.h
@@ -1,5 +1,5 @@
/* -*- C -*-
- * $Id: dl.h,v 1.9 2003/12/01 23:02:44 ttate Exp $
+ * $Id$
*/
#ifndef RUBY_DL_H
diff --git a/ext/dl/h2rb b/ext/dl/h2rb
index d5ebd6ee2c..00fbd60c82 100644
--- a/ext/dl/h2rb
+++ b/ext/dl/h2rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
# -*- ruby -*-
-# $Id: h2rb,v 1.1 2002/04/02 10:56:13 ttate Exp $
+# $Id$
require 'mkmf'
require 'ftools'
diff --git a/ext/dl/handle.c b/ext/dl/handle.c
index 1e8c17e501..69d47caac0 100644
--- a/ext/dl/handle.c
+++ b/ext/dl/handle.c
@@ -1,5 +1,5 @@
/* -*- C -*-
- * $Id: handle.c,v 1.11.2.1 2005/02/28 02:45:17 matz Exp $
+ * $Id$
*/
#include <ruby.h>
@@ -66,12 +66,12 @@ rb_dlhandle_initialize(int argc, VALUE argv[], VALUE self)
ptr = dlopen(clib, cflag);
#if defined(HAVE_DLERROR)
if (!ptr && (err = dlerror())) {
- rb_raise(rb_eRuntimeError, err);
+ rb_raise(rb_eRuntimeError, "%s", err);
}
#else
if (!ptr) {
err = dlerror();
- rb_raise(rb_eRuntimeError, err);
+ rb_raise(rb_eRuntimeError, "%s", err);
}
#endif
Data_Get_Struct(self, struct dl_handle, dlhandle);
diff --git a/ext/dl/lib/dl/import.rb b/ext/dl/lib/dl/import.rb
index 63c9b2c050..01ee2490e8 100644
--- a/ext/dl/lib/dl/import.rb
+++ b/ext/dl/lib/dl/import.rb
@@ -87,7 +87,7 @@ module DL
" rs = dec.call(rs) if (dec && rs)",
" @retval = r",
" @args = rs",
- " @retval",
+ " r",
"}",
].join("\n"))
@@ -169,7 +169,7 @@ module DL
" rs = dec.call(rs) if dec",
" @retval = r",
" @args = rs",
- " return @retval",
+ " return r",
"end",
"module_function :#{mname}",
].join("\n")
diff --git a/ext/dl/lib/dl/win32.rb b/ext/dl/lib/dl/win32.rb
index 0fed47c324..92f473d392 100644
--- a/ext/dl/lib/dl/win32.rb
+++ b/ext/dl/lib/dl/win32.rb
@@ -6,7 +6,7 @@ class Win32API
DLL = {}
def initialize(dllname, func, import, export = "0")
- prototype = (export + import.to_s).tr("VPpNnLlIi", "0SSI").sub(/^(.)0*$/, '\1')
+ prototype = (export + import.to_s).tr("VPpNnLlIi", "0SSI")
handle = DLL[dllname] ||= DL::Handle.new(dllname)
@sym = handle.sym(func, prototype)
end
diff --git a/ext/dl/ptr.c b/ext/dl/ptr.c
index a3bbcc915c..4d75a3ddf2 100644
--- a/ext/dl/ptr.c
+++ b/ext/dl/ptr.c
@@ -1,25 +1,33 @@
/* -*- C -*-
- * $Id: ptr.c,v 1.19.2.1 2006/05/25 16:37:57 ttate Exp $
+ * $Id$
*/
#include <ruby.h>
#include <ctype.h>
-#include "st.h"
+#include <version.h> /* for ruby version code */
#include "dl.h"
VALUE rb_cDLPtrData;
VALUE rb_mDLMemorySpace;
-static st_table* st_memory_table;
+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);
- st_delete(st_memory_table, (st_data_t*)&ptr, NULL);
+ rb_hash_delete(DLMemoryTable, DLLONG2NUM(ptr));
}
static void
@@ -29,7 +37,7 @@ rb_dlmem_aset(void *ptr, VALUE obj)
rb_dlmem_delete(ptr);
}
else{
- st_insert(st_memory_table, (st_data_t)ptr, (st_data_t)obj);
+ rb_hash_aset(DLMemoryTable, DLLONG2NUM(ptr), DLLONG2NUM(obj));
}
}
@@ -38,8 +46,8 @@ rb_dlmem_aref(void *ptr)
{
VALUE val;
- if(!st_lookup(st_memory_table, (st_data_t)ptr, &val)) return Qnil;
- return val == Qundef ? Qnil : val;
+ val = rb_hash_aref(DLMemoryTable, DLLONG2NUM(ptr));
+ return val == Qnil ? Qnil : (VALUE)DLNUM2LONG(val);
}
void
@@ -458,9 +466,8 @@ rb_dlptr_inspect(VALUE self)
char str[1024];
Data_Get_Struct(self, struct ptr_data, data);
- snprintf(str, 1023, "#<%s:0x%lx ptr=0x%lx size=%ld free=0x%lx>",
- rb_class2name(CLASS_OF(self)), data, data->ptr, data->size,
- (long)data->free);
+ snprintf(str, 1023, "#<%s:0x%x ptr=0x%x size=%ld free=0x%x>",
+ rb_class2name(CLASS_OF(self)), data, data->ptr, data->size, data->free);
return rb_str_new2(str);
}
@@ -1002,18 +1009,20 @@ rb_dlptr_size(int argc, VALUE argv[], VALUE self)
}
}
-static int
-dlmem_each_i(void* key, VALUE value, void* arg)
+static VALUE
+dlmem_each_i(VALUE assoc, void *data)
{
- VALUE vkey = DLLONG2NUM(key);
- rb_yield(rb_assoc_new(vkey, value));
+ 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)
{
- st_foreach(st_memory_table, dlmem_each_i, 0);
+ rb_iterate(rb_each, DLMemoryTable, dlmem_each_i, 0);
return Qnil;
}
@@ -1052,7 +1061,7 @@ Init_dlptr()
rb_define_method(rb_cDLPtrData, "size=", rb_dlptr_size, -1);
rb_mDLMemorySpace = rb_define_module_under(rb_mDL, "MemorySpace");
- st_memory_table = st_init_numtable();
- rb_define_const(rb_mDLMemorySpace, "MemoryTable", Qnil); /* historical */
+ 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/sym.c b/ext/dl/sym.c
index 2ca16a8698..87d07e7cbe 100644
--- a/ext/dl/sym.c
+++ b/ext/dl/sym.c
@@ -1,5 +1,5 @@
/* -*- C -*-
- * $Id: sym.c,v 1.24.2.3 2005/06/15 23:39:27 ocean Exp $
+ * $Id$
*/
#include <ruby.h>
@@ -268,7 +268,7 @@ rb_dlsym_inspect(VALUE self)
str_size = RSTRING(proto)->len + 100;
str = dlmalloc(str_size);
snprintf(str, str_size - 1,
- "#<DL::Symbol:0x%lx func=0x%lx '%s'>",
+ "#<DL::Symbol:0x%x func=0x%x '%s'>",
sym, sym->func, RSTRING(proto)->ptr);
val = rb_tainted_str_new2(str);
dlfree(str);
diff --git a/ext/enumerator/enumerator.c b/ext/enumerator/enumerator.c
index 7b8f109e38..1c6e1d1ace 100644
--- a/ext/enumerator/enumerator.c
+++ b/ext/enumerator/enumerator.c
@@ -2,13 +2,13 @@
enumerator.c - provides Enumerator class
- $Author: matz $
+ $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: enumerator.c,v 1.3.2.3 2005/10/24 00:07:00 matz Exp $
+ $Id$
************************************************/
diff --git a/ext/enumerator/enumerator.txt b/ext/enumerator/enumerator.txt
index 1b84c0c088..64c7d50226 100644
--- a/ext/enumerator/enumerator.txt
+++ b/ext/enumerator/enumerator.txt
@@ -1,7 +1,7 @@
.\" 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: enumerator.txt,v 1.2 2003/10/17 14:09:43 knu Exp $
+$Id$
** Enumerable::Enumerator(Class)
diff --git a/ext/etc/etc.c b/ext/etc/etc.c
index 084405408f..486963378b 100644
--- a/ext/etc/etc.c
+++ b/ext/etc/etc.c
@@ -2,8 +2,8 @@
etc.c -
- $Author: shyouhei $
- $Date: 2007/01/09 12:24:20 $
+ $Author$
+ $Date$
created at: Tue Mar 22 18:39:19 JST 1994
************************************************/
diff --git a/ext/extmk.rb b/ext/extmk.rb
index 86d59b0946..c3ba27aaf4 100644
--- a/ext/extmk.rb
+++ b/ext/extmk.rb
@@ -1,13 +1,19 @@
#! /usr/local/bin/ruby
# -*- ruby -*-
+$extension = nil
+$extstatic = nil
$force_static = nil
$install = nil
$destdir = nil
+$dryrun = false
$clean = nil
$nodynamic = nil
$extinit = nil
$extobjs = nil
+$extflags = ""
+$extlibs = nil
+$extpath = nil
$ignore = nil
$message = nil
@@ -79,6 +85,8 @@ def extract_makefile(makefile, keep = true)
s.sub!(/ *#{Regexp.quote($LIBS)}$/, "")
$libs = s
end
+ $objs = (m[/^OBJS[ \t]*=[ \t](.*)/, 1] || "").split
+ $srcs = (m[/^SRCS[ \t]*=[ \t](.*)/, 1] || "").split
$LOCAL_LIBS = m[/^LOCAL_LIBS[ \t]*=[ \t]*(.*)/, 1] || ""
$LIBPATH = Shellwords.shellwords(m[/^libpath[ \t]*=[ \t]*(.*)/, 1] || "") - %w[$(libdir) $(topdir)]
true
@@ -104,50 +112,33 @@ def extmake(target)
Dir.chdir target
top_srcdir = $top_srcdir
topdir = $topdir
- hdrdir = $hdrdir
+ mk_srcdir = CONFIG["srcdir"]
+ mk_topdir = CONFIG["topdir"]
prefix = "../" * (target.count("/")+1)
- $top_srcdir = relative_from(top_srcdir, prefix)
- $hdrdir = relative_from(hdrdir, prefix)
+ $hdrdir = $top_srcdir = relative_from(top_srcdir, prefix)
$topdir = prefix + $topdir
$target = target
$mdir = target
$srcdir = File.join($top_srcdir, "ext", $mdir)
$preload = nil
+ $objs = ""
+ $srcs = ""
$compiled[target] = false
makefile = "./Makefile"
ok = File.exist?(makefile)
unless $ignore
- rbconfig0 = Config::CONFIG
- mkconfig0 = CONFIG
- rbconfig = {
- "hdrdir" => $hdrdir,
- "srcdir" => $srcdir,
- "topdir" => $topdir,
- }
- mkconfig = {
- "top_srcdir" => ($hdrdir == top_srcdir) ? top_srcdir : "$(topdir)"+top_srcdir[2..-1],
- "hdrdir" => "$(top_srcdir)",
- "srcdir" => "$(top_srcdir)/ext/#{$mdir}",
- "topdir" => $topdir,
- }
- rbconfig0.each_pair {|key, val| rbconfig[key] ||= val.dup}
- mkconfig0.each_pair {|key, val| mkconfig[key] ||= val.dup}
- Config.module_eval {
- remove_const(:CONFIG)
- const_set(:CONFIG, rbconfig)
- remove_const(:MAKEFILE_CONFIG)
- const_set(:MAKEFILE_CONFIG, mkconfig)
- }
- Object.class_eval {
- remove_const(:CONFIG)
- const_set(:CONFIG, mkconfig)
- }
+ Config::CONFIG["hdrdir"] = $hdrdir
+ Config::CONFIG["srcdir"] = $srcdir
+ Config::CONFIG["topdir"] = $topdir
+ CONFIG["hdrdir"] = ($hdrdir == top_srcdir) ? top_srcdir : "$(topdir)"+top_srcdir[2..-1]
+ CONFIG["srcdir"] = "$(hdrdir)/ext/#{$mdir}"
+ CONFIG["topdir"] = $topdir
begin
$extconf_h = nil
ok &&= extract_makefile(makefile)
if (($extconf_h && !File.exist?($extconf_h)) ||
!(t = modified?(makefile, MTIMES)) ||
- %W"#{$srcdir}/makefile.rb #{$srcdir}/extconf.rb #{$srcdir}/depend".any? {|f| modified?(f, [t])})
+ ["#{$srcdir}/makefile.rb", "#{$srcdir}/extconf.rb", "#{$srcdir}/depend"].any? {|f| modified?(f, [t])})
then
ok = false
init_mkmf
@@ -190,11 +181,7 @@ def extmake(target)
$ignore or $continue or return false
end
$compiled[target] = true
- if $clean
- FileUtils.rm_f("mkmf.log")
- if $clean != true
- FileUtils.rm_f([makefile, $extconf_h || "extconf.h"])
- end
+ if $clean and $clean != true
File.unlink(makefile) rescue nil
end
if $static
@@ -208,21 +195,13 @@ def extmake(target)
$extpath |= $LIBPATH
end
ensure
- unless $ignore
- Config.module_eval {
- remove_const(:CONFIG)
- const_set(:CONFIG, rbconfig0)
- remove_const(:MAKEFILE_CONFIG)
- const_set(:MAKEFILE_CONFIG, mkconfig0)
- }
- Object.class_eval {
- remove_const(:CONFIG)
- const_set(:CONFIG, mkconfig0)
- }
- end
- $top_srcdir = top_srcdir
+ Config::CONFIG["srcdir"] = $top_srcdir
+ Config::CONFIG["topdir"] = topdir
+ CONFIG["srcdir"] = mk_srcdir
+ CONFIG["topdir"] = mk_topdir
+ CONFIG.delete("hdrdir")
+ $hdrdir = $top_srcdir = top_srcdir
$topdir = topdir
- $hdrdir = hdrdir
Dir.chdir dir
end
begin
@@ -306,7 +285,6 @@ def parse_args()
$continue = $mflags.set?(?k)
if $extout
$extout = '$(topdir)/'+$extout
- Config::CONFIG["extout"] = CONFIG["extout"] = $extout
$extout_prefix = $extout ? "$(extout)$(target_prefix)/" : ""
$mflags << "extout=#$extout" << "extout_prefix=#$extout_prefix"
end
@@ -345,8 +323,12 @@ elsif sep = config_string('BUILD_FILE_SEPARATOR')
else
$ruby = '$(topdir)/miniruby' + EXEEXT
end
-$ruby << " -I'$(topdir)' -I'$(top_srcdir)/lib'"
+$ruby << " -I'$(topdir)' -I'$(hdrdir)/lib'"
+$ruby << " -I'$(extout)/$(arch)' -I'$(extout)/common'" if $extout
+$ruby << " -I'$(hdrdir)/ext' -rpurelib.rb"
$config_h = '$(topdir)/config.h'
+ENV["RUBYLIB"] = "-"
+ENV["RUBYOPT"] = "-rpurelib.rb"
MTIMES = [__FILE__, 'rbconfig.rb', srcdir+'/lib/mkmf.rb'].collect {|f| File.mtime(f)}
@@ -395,12 +377,12 @@ else
elsif (w = w.grep(String)).empty?
proc {true}
else
- w.collect {|opt| opt.split(/,/)}.flatten.method(:any?)
+ proc {|c1| w.collect {|opt| opt.split(/,/)}.flatten.any?(&c1)}
end
}
cond = proc {|ext|
cond1 = proc {|n| File.fnmatch(n, ext, File::FNM_PATHNAME)}
- withes.call(&cond1) or !withouts.call(&cond1)
+ withes.call(cond1) or !withouts.call(cond1)
}
exts |= Dir.glob("#{ext_prefix}/*/**/extconf.rb").collect {|d|
d = File.dirname(d)
@@ -412,15 +394,7 @@ else
end
if $extout
- Config.expand(extout = "#$extout", Config::CONFIG.merge("topdir"=>$topdir))
- if $install
- dest = Config.expand($rubylibdir.dup)
- unless $destdir.empty?
- dest.sub!($dest_prefix_pattern, Config.expand($destdir.dup))
- end
- FileUtils.cp_r(extout+"/.", dest, :verbose => true, :noop => $dryrun)
- exit
- end
+ extout = Config.expand("#{$extout}", Config::CONFIG.merge("topdir"=>$topdir))
unless $ignore
FileUtils.mkpath(extout)
end
@@ -430,14 +404,12 @@ dir = Dir.pwd
FileUtils::makedirs('ext')
Dir::chdir('ext')
-hdrdir = $hdrdir
$hdrdir = $top_srcdir = relative_from(srcdir, $topdir = "..")
exts.each do |d|
extmake(d) or abort
end
-$top_srcdir = srcdir
+$hdrdir = $top_srcdir = srcdir
$topdir = "."
-$hdrdir = hdrdir
extinit = Struct.new(:c, :o) {
def initialize(src)
@@ -454,9 +426,13 @@ if $ignore
exit
end
-if $extlist.size > 0
- $extinit ||= ""
- $extobjs ||= ""
+$extinit ||= ""
+$extobjs ||= ""
+$extpath ||= []
+$extflags ||= ""
+$extlibs ||= []
+unless $extlist.empty?
+ $extinit << "\n" unless $extinit.empty?
list = $extlist.dup
built = []
while e = list.shift
@@ -470,28 +446,33 @@ if $extlist.size > 0
end
f = format("%s/%s.%s", s, i, $LIBEXT)
if File.exist?(f)
- $extinit += "\tinit(Init_#{i}, \"#{t}.so\");\n"
- $extobjs += "ext/#{f} "
+ $extinit << " init(Init_#{i}, \"#{t}.so\");\n"
+ $extobjs << "ext/#{f} "
built << t
end
end
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}
+#include "ruby.h"
+
+#define init(func, name) {void func _((void)); ruby_init_ext(name, func);}
+
+void ruby_init_ext _((const char *name, void (*init)(void)));
+
+void Init_ext _((void))\n{\n#$extinit}
}
if !modified?(extinit.c, MTIMES) || IO.read(extinit.c) != src
open(extinit.c, "w") {|f| f.print src}
end
- $extobjs = "ext/#{extinit.o} " + $extobjs
+ $extobjs = "ext/#{extinit.o} #{$extobjs}"
if RUBY_PLATFORM =~ /m68k-human|beos/
$extflags.delete("-L/usr/local/lib")
end
$extpath.delete("$(topdir)")
$extflags = libpathflag($extpath) << " " << $extflags.strip
conf = [
+ ['LIBRUBY_SO_UPDATE', '$(LIBRUBY_EXTS)'],
['SETUP', $setup],
[enable_config("shared", $enable_shared) ? 'DLDOBJS' : 'EXTOBJS', $extobjs],
['EXTLIBS', $extlibs.join(' ')], ['EXTLDFLAGS', $extflags]
@@ -508,7 +489,7 @@ rubies = []
%w[RUBY RUBYW STATIC_RUBY].each {|r|
n = r
if r = arg_config("--"+r.downcase) || config_string(r+"_INSTALL_NAME")
- rubies << r+EXEEXT
+ rubies << Config.expand(r+=EXEEXT)
$mflags << "#{n}=#{r}"
end
}
@@ -517,15 +498,21 @@ Dir.chdir ".."
unless $destdir.to_s.empty?
$mflags.defined?("DESTDIR") or $mflags << "DESTDIR=#{$destdir}"
end
-unless $extlist.empty?
- rm_f(Config::CONFIG["LIBRUBY_SO"])
-end
puts "making #{rubies.join(', ')}"
$stdout.flush
$mflags.concat(rubies)
if $nmake == ?b
- $mflags.collect {|flag| flag.sub!(/\A(?=\w+=)/, "-D")}
+ unless (vars = $mflags.grep(/\A\w+=/n)).empty?
+ open(mkf = "libruby.mk", "wb") do |tmf|
+ tmf.puts("!include Makefile")
+ tmf.puts
+ tmf.puts(*vars.map {|v| v.sub(/=/, " = ")})
+ tmf.puts("PRE_LIBRUBY_UPDATE = del #{mkf}")
+ end
+ $mflags.unshift("-f#{mkf}")
+ vars.each {|flag| flag.sub!(/\A/, "-D")}
+ end
end
system($make, *sysquote($mflags)) or exit($?.exitstatus)
diff --git a/ext/fcntl/fcntl.c b/ext/fcntl/fcntl.c
index 8f9cb43d0c..57cca103f4 100644
--- a/ext/fcntl/fcntl.c
+++ b/ext/fcntl/fcntl.c
@@ -2,7 +2,7 @@
fcntl.c -
- $Author: matz $
+ $Author$
created at: Mon Apr 7 18:53:05 JST 1997
Copyright (C) 1997-2001 Yukihiro Matsumoto
diff --git a/ext/gdbm/gdbm.c b/ext/gdbm/gdbm.c
index 691d512460..82109fda90 100644
--- a/ext/gdbm/gdbm.c
+++ b/ext/gdbm/gdbm.c
@@ -2,10 +2,12 @@
gdbm.c -
- $Author: usa $
- $Date: 2005/06/20 07:53:20 $
+ $Author$
+ $Date$
modified at: Mon Jan 24 15:59:52 JST 1994
+ Documentation by Peter Adolphs < futzilogik at users dot sourceforge dot net >
+
************************************************/
#include "ruby.h"
@@ -14,6 +16,62 @@
#include <fcntl.h>
#include <errno.h>
+/*
+ * Document-class: GDBM
+ *
+ * == Summary
+ *
+ * Ruby extension for GNU dbm (gdbm) -- a simple database engine for storing
+ * key-value pairs on disk.
+ *
+ * == Description
+ *
+ * GNU dbm is a library for simple databases. A database is a file that stores
+ * key-value pairs. Gdbm allows the user to store, retrieve, and delete data by
+ * key. It furthermore allows a non-sorted traversal of all key-value pairs.
+ * A gdbm database thus provides the same functionality as a hash. As
+ * with objects of the Hash class, elements can be accessed with <tt>[]</tt>.
+ * Furthermore, GDBM mixes in the Enumerable module, thus providing convenient
+ * methods such as #find, #collect, #map, etc.
+ *
+ * A process is allowed to open several different databases at the same time.
+ * A process can open a database as a "reader" or a "writer". Whereas a reader
+ * has only read-access to the database, a writer has read- and write-access.
+ * A database can be accessed either by any number of readers or by exactly one
+ * writer at the same time.
+ *
+ * == Examples
+ *
+ * 1. Opening/creating a database, and filling it with some entries:
+ *
+ * require 'gdbm'
+ *
+ * gdbm = GDBM.new("fruitstore.db")
+ * gdbm["ananas"] = "3"
+ * gdbm["banana"] = "8"
+ * gdbm["cranberry"] = "4909"
+ * gdbm.close
+ *
+ * 2. Reading out a database:
+ *
+ * require 'gdbm'
+ *
+ * gdbm = GDBM.new("fruitstore.db")
+ * gdbm.each_pair do |key, value|
+ * print "#{key}: #{value}\n"
+ * end
+ * gdbm.close
+ *
+ * produces
+ *
+ * banana: 8
+ * ananas: 3
+ * cranberry: 4909
+ *
+ * == Links
+ *
+ * * http://www.gnu.org/software/gdbm/
+ */
static VALUE rb_cGDBM, rb_eGDBMError, rb_eGDBMFatalError;
#define RUBY_GDBM_RW_BIT 0x20000000
@@ -24,7 +82,7 @@ static void
rb_gdbm_fatal(msg)
char *msg;
{
- rb_raise(rb_eGDBMFatalError, msg);
+ rb_raise(rb_eGDBMFatalError, "%s", msg);
}
struct dbmdata {
@@ -54,11 +112,17 @@ free_dbm(dbmp)
struct dbmdata *dbmp;
{
if (dbmp) {
- if (dbmp->di_dbm) gdbm_close(dbmp->di_dbm);
- free(dbmp);
+ if (dbmp->di_dbm) gdbm_close(dbmp->di_dbm);
+ free(dbmp);
}
}
+/*
+ * call-seq:
+ * gdbm.close -> nil
+ *
+ * Closes the associated database file.
+ */
static VALUE
fgdbm_close(obj)
VALUE obj;
@@ -72,6 +136,12 @@ fgdbm_close(obj)
return Qnil;
}
+/*
+ * call-seq:
+ * gdbm.closed? -> true or false
+ *
+ * Returns true if the associated database file has been closed.
+ */
static VALUE
fgdbm_closed(obj)
VALUE obj;
@@ -80,9 +150,9 @@ fgdbm_closed(obj)
Data_Get_Struct(obj, struct dbmdata, dbmp);
if (dbmp == 0)
- return Qtrue;
+ return Qtrue;
if (dbmp->di_dbm == 0)
- return Qtrue;
+ return Qtrue;
return Qfalse;
}
@@ -96,6 +166,29 @@ fgdbm_s_alloc(klass)
return Data_Wrap_Struct(klass, 0, free_dbm, 0);
}
+/*
+ * call-seq:
+ * GDBM.new(filename, mode = 0666, flags = nil)
+ *
+ * Creates a new GDBM instance by opening a gdbm file named _filename_.
+ * If the file does not exist, a new file with file mode _mode_ will be
+ * created. _flags_ may be one of the following:
+ * * *READER* - open as a reader
+ * * *WRITER* - open as a writer
+ * * *WRCREAT* - open as a writer; if the database does not exist, create a new one
+ * * *NEWDB* - open as a writer; overwrite any existing databases
+ *
+ * The values *WRITER*, *WRCREAT* and *NEWDB* may be combined with the following
+ * values by bitwise or:
+ * * *SYNC* - cause all database operations to be synchronized to the disk
+ * * *NOLOCK* - do not lock the database file
+ *
+ * If no _flags_ are specified, the GDBM object will try to open the database
+ * file as a writer and will create it if it does not already exist
+ * (cf. flag <tt>WRCREAT</tt>). If this fails (for instance, if another process
+ * has already opened the database as a reader), it will try to open the
+ * database file as a reader (cf. flag <tt>READER</tt>).
+ */
static VALUE
fgdbm_initialize(argc, argv, obj)
int argc;
@@ -108,13 +201,13 @@ fgdbm_initialize(argc, argv, obj)
int mode, flags = 0;
if (rb_scan_args(argc, argv, "12", &file, &vmode, &vflags) == 1) {
- mode = 0666; /* default value */
+ mode = 0666; /* default value */
}
else if (NIL_P(vmode)) {
- mode = -1; /* return nil if DB not exist */
+ mode = -1; /* return nil if DB does not exist */
}
else {
- mode = NUM2INT(vmode);
+ mode = NUM2INT(vmode);
}
if (!NIL_P(vflags))
@@ -160,6 +253,25 @@ fgdbm_initialize(argc, argv, obj)
return obj;
}
+/*
+ * call-seq:
+ * GDBM.open(filename, mode = 0666, flags = nil)
+ * GDBM.open(filename, mode = 0666, flags = nil) { |gdbm| ... }
+ *
+ * If called without a block, this is synonymous to GDBM::new.
+ * If a block is given, the new GDBM instance will be passed to the block
+ * as a parameter, and the corresponding database file will be closed
+ * after the execution of the block code has been finished.
+ *
+ * Example for an open call with a block:
+ *
+ * require 'gdbm'
+ * GDBM.open("fruitstore.db") do |gdbm|
+ * gdbm.each_pair do |key, value|
+ * print "#{key}: #{value}\n"
+ * end
+ * end
+ */
static VALUE
fgdbm_s_open(argc, argv, klass)
int argc;
@@ -286,6 +398,12 @@ fgdbm_fetch(obj, keystr, ifnone)
return valstr;
}
+/*
+ * call-seq:
+ * gdbm[key] -> value
+ *
+ * Retrieves the _value_ corresponding to _key_.
+ */
static VALUE
fgdbm_aref(obj, keystr)
VALUE obj, keystr;
@@ -293,6 +411,13 @@ fgdbm_aref(obj, keystr)
return rb_gdbm_fetch3(obj, keystr);
}
+/*
+ * call-seq:
+ * gdbm.fetch(key [, default]) -> value
+ *
+ * Retrieves the _value_ corresponding to _key_. If there is no value
+ * associated with _key_, _default_ will be returned instead.
+ */
static VALUE
fgdbm_fetch_m(argc, argv, obj)
int argc;
@@ -304,11 +429,18 @@ fgdbm_fetch_m(argc, argv, obj)
rb_scan_args(argc, argv, "11", &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");
+ rb_raise(rb_eIndexError, "key not found");
return valstr;
}
+/*
+ * call-seq:
+ * gdbm.index(value) -> key
+ *
+ * Returns the _key_ for a given _value_. If several keys may map to the
+ * same value, the key that is found first will be returned.
+ */
static VALUE
fgdbm_index(obj, valstr)
VALUE obj, valstr;
@@ -350,6 +482,13 @@ fgdbm_indexes(argc, argv, obj)
return new;
}
+/*
+ * call-seq:
+ * gdbm.select { |value| block } -> array
+ *
+ * Returns a new array of all values of the database for which _block_
+ * evaluates to true.
+ */
static VALUE
fgdbm_select(argc, argv, obj)
int argc;
@@ -390,6 +529,12 @@ fgdbm_select(argc, argv, obj)
return new;
}
+/*
+ * call-seq:
+ * gdbm.values_at(key, ...) -> array
+ *
+ * Returns an array of the values associated with each specified _key_.
+ */
static VALUE
fgdbm_values_at(argc, argv, obj)
int argc;
@@ -429,19 +574,26 @@ rb_gdbm_delete(obj, keystr)
GetDBM2(obj, dbmp, dbm);
if (!gdbm_exists(dbm, key)) {
- return Qnil;
+ return Qnil;
}
if (gdbm_delete(dbm, key)) {
- dbmp->di_size = -1;
- rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno));
+ dbmp->di_size = -1;
+ rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno));
}
else if (dbmp->di_size >= 0) {
- dbmp->di_size--;
+ dbmp->di_size--;
}
return obj;
}
+/*
+ * call-seq:
+ * gdbm.delete(key) -> value or nil
+ *
+ * Removes the key-value-pair with the specified _key_ from this database and
+ * returns the corresponding _value_. Returns nil if the database is empty.
+ */
static VALUE
fgdbm_delete(obj, keystr)
VALUE obj, keystr;
@@ -453,6 +605,13 @@ fgdbm_delete(obj, keystr)
return valstr;
}
+/*
+ * call-seq:
+ * gdbm.shift -> (key, value) or nil
+ *
+ * Removes a key-value-pair from this database and returns it as a
+ * two-item array [ _key_, _value_ ]. Returns nil if the database is empty.
+ */
static VALUE
fgdbm_shift(obj)
VALUE obj;
@@ -471,6 +630,13 @@ fgdbm_shift(obj)
return rb_assoc_new(keystr, valstr);
}
+/*
+ * call-seq:
+ * gdbm.delete_if { |key, value| block } -> gdbm
+ * gdbm.reject! { |key, value| block } -> gdbm
+ *
+ * Deletes every key-value pair from _gdbm_ for which _block_ evaluates to true.
+ */
static VALUE
fgdbm_delete_if(obj)
VALUE obj;
@@ -489,11 +655,11 @@ fgdbm_delete_if(obj)
for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
keystr = rb_gdbm_nextkey(dbm, keystr)) {
- valstr = rb_gdbm_fetch2(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);
- GetDBM2(obj, dbmp, dbm);
+ if (RTEST(ret)) rb_ary_push(ary, keystr);
+ GetDBM2(obj, dbmp, dbm);
}
for (i = 0; i < RARRAY(ary)->len; i++)
@@ -504,6 +670,12 @@ fgdbm_delete_if(obj)
return obj;
}
+/*
+ * call-seq:
+ * gdbm.clear -> gdbm
+ *
+ * Removes all the key-value pairs within _gdbm_.
+ */
static VALUE
fgdbm_clear(obj)
VALUE obj;
@@ -518,11 +690,11 @@ fgdbm_clear(obj)
#if 0
while (key = gdbm_firstkey(dbm), key.dptr) {
- if (gdbm_delete(dbm, key)) {
- free(key.dptr);
- rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno));
- }
- free(key.dptr);
+ if (gdbm_delete(dbm, key)) {
+ free(key.dptr);
+ rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno));
+ }
+ free(key.dptr);
}
#else
while (key = gdbm_firstkey(dbm), key.dptr) {
@@ -542,6 +714,13 @@ fgdbm_clear(obj)
return obj;
}
+/*
+ * call-seq:
+ * gdbm.invert -> hash
+ *
+ * Returns a hash created by using _gdbm_'s values as keys, and the keys
+ * as values.
+ */
static VALUE
fgdbm_invert(obj)
VALUE obj;
@@ -584,6 +763,14 @@ update_i(pair, dbm)
return Qnil;
}
+/*
+ * call-seq:
+ * gdbm.update(other) -> gdbm
+ *
+ * Adds the key-value pairs of _other_ to _gdbm_, overwriting entries with
+ * duplicate keys with those from _other_. _other_ must have an each_pair
+ * method.
+ */
static VALUE
fgdbm_update(obj, other)
VALUE obj, other;
@@ -592,6 +779,13 @@ fgdbm_update(obj, other)
return obj;
}
+/*
+ * call-seq:
+ * gdbm.replace(other) -> gdbm
+ *
+ * Replaces the content of _gdbm_ with the key-value pairs of _other_.
+ * _other_ must have an each_pair method.
+ */
static VALUE
fgdbm_replace(obj, other)
VALUE obj, other;
@@ -601,6 +795,13 @@ fgdbm_replace(obj, other)
return obj;
}
+/*
+ * call-seq:
+ * gdbm[key]= value -> value
+ * gdbm.store(key, value) -> value
+ *
+ * Associates the value _value_ with the specified _key_.
+ */
static VALUE
fgdbm_store(obj, keystr, valstr)
VALUE obj, keystr, valstr;
@@ -622,13 +823,20 @@ fgdbm_store(obj, keystr, valstr)
GetDBM2(obj, dbmp, dbm);
dbmp->di_size = -1;
if (gdbm_store(dbm, key, val, GDBM_REPLACE)) {
- if (errno == EPERM) rb_sys_fail(0);
- rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno));
+ if (errno == EPERM) rb_sys_fail(0);
+ rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno));
}
return valstr;
}
+/*
+ * call-seq:
+ * gdbm.length -> fixnum
+ * gdbm.size -> fixnum
+ *
+ * Returns the number of key-value pairs in this database.
+ */
static VALUE
fgdbm_length(obj)
VALUE obj;
@@ -651,6 +859,12 @@ fgdbm_length(obj)
return INT2FIX(i);
}
+/*
+ * call-seq:
+ * gdbm.empty? -> true or false
+ *
+ * Returns true if the database is empty.
+ */
static VALUE
fgdbm_empty_p(obj)
VALUE obj;
@@ -675,6 +889,13 @@ fgdbm_empty_p(obj)
return Qfalse;
}
+/*
+ * call-seq:
+ * gdbm.each_value { |value| block } -> gdbm
+ *
+ * Executes _block_ for each key in the database, passing the corresponding
+ * _value_ as a parameter.
+ */
static VALUE
fgdbm_each_value(obj)
VALUE obj;
@@ -693,6 +914,13 @@ fgdbm_each_value(obj)
return obj;
}
+/*
+ * call-seq:
+ * gdbm.each_key { |key| block } -> gdbm
+ *
+ * Executes _block_ for each key in the database, passing the
+ * _key_ as a parameter.
+ */
static VALUE
fgdbm_each_key(obj)
VALUE obj;
@@ -711,6 +939,13 @@ fgdbm_each_key(obj)
return obj;
}
+/*
+ * call-seq:
+ * gdbm.each_pair { |key, value| block } -> gdbm
+ *
+ * Executes _block_ for each key in the database, passing the _key_ and the
+ * correspoding _value_ as a parameter.
+ */
static VALUE
fgdbm_each_pair(obj)
VALUE obj;
@@ -724,12 +959,18 @@ fgdbm_each_pair(obj)
keystr = rb_gdbm_nextkey(dbm, keystr)) {
rb_yield(rb_assoc_new(keystr, rb_gdbm_fetch2(dbm, keystr)));
- GetDBM2(obj, dbmp, dbm);
+ GetDBM2(obj, dbmp, dbm);
}
return obj;
}
+/*
+ * call-seq:
+ * gdbm.keys -> array
+ *
+ * Returns an array of all keys of this database.
+ */
static VALUE
fgdbm_keys(obj)
VALUE obj;
@@ -749,6 +990,12 @@ fgdbm_keys(obj)
return ary;
}
+/*
+ * call-seq:
+ * gdbm.values -> array
+ *
+ * Returns an array of all values of this database.
+ */
static VALUE
fgdbm_values(obj)
VALUE obj;
@@ -762,14 +1009,22 @@ fgdbm_values(obj)
ary = rb_ary_new();
for (key = gdbm_firstkey(dbm); key.dptr; key = nextkey) {
nextkey = gdbm_nextkey(dbm, key);
- valstr = rb_gdbm_fetch(dbm, key);
+ valstr = rb_gdbm_fetch(dbm, key);
free(key.dptr);
- rb_ary_push(ary, valstr);
+ rb_ary_push(ary, valstr);
}
return ary;
}
+/*
+ * call-seq:
+ * gdbm.has_key?(k) -> true or false
+ * gdbm.key?(k) -> true or false
+ *
+ * Returns true if the given key _k_ exists within the database.
+ * Returns false otherwise.
+ */
static VALUE
fgdbm_has_key(obj, keystr)
VALUE obj, keystr;
@@ -788,6 +1043,14 @@ fgdbm_has_key(obj, keystr)
return Qfalse;
}
+/*
+ * call-seq:
+ * gdbm.has_value?(v) -> true or false
+ * gdbm.value?(v) -> true or false
+ *
+ * Returns true if the given value _v_ exists within the database.
+ * Returns false otherwise.
+ */
static VALUE
fgdbm_has_value(obj, valstr)
VALUE obj, valstr;
@@ -813,6 +1076,12 @@ fgdbm_has_value(obj, valstr)
return Qfalse;
}
+/*
+ * call-seq:
+ * gdbm.to_a -> array
+ *
+ * Returns an array of all key-value pairs contained in the database.
+ */
static VALUE
fgdbm_to_a(obj)
VALUE obj;
@@ -832,6 +1101,14 @@ fgdbm_to_a(obj)
return ary;
}
+/*
+ * call-seq:
+ * gdbm.reorganize -> gdbm
+ *
+ * Reorganizes the database file. This operation removes reserved space of
+ * elements that have already been deleted. It is only useful after a lot of
+ * deletions in the database.
+ */
static VALUE
fgdbm_reorganize(obj)
VALUE obj;
@@ -845,6 +1122,16 @@ fgdbm_reorganize(obj)
return obj;
}
+/*
+ * call-seq:
+ * gdbm.sync -> gdbm
+ *
+ * Unless the _gdbm_ object has been opened with the *SYNC* flag, it is not
+ * guarenteed that database modification operations are immediately applied to
+ * the database file. This method ensures that all recent modifications
+ * to the database are written to the file. Blocks until all writing operations
+ * to the disk have been finished.
+ */
static VALUE
fgdbm_sync(obj)
VALUE obj;
@@ -858,6 +1145,12 @@ fgdbm_sync(obj)
return obj;
}
+/*
+ * call-seq:
+ * gdbm.cachesize = size -> size
+ *
+ * Sets the size of the internal bucket cache to _size_.
+ */
static VALUE
fgdbm_set_cachesize(obj, val)
VALUE obj, val;
@@ -869,11 +1162,21 @@ fgdbm_set_cachesize(obj, val)
GetDBM2(obj, dbmp, dbm);
optval = FIX2INT(val);
if (gdbm_setopt(dbm, GDBM_CACHESIZE, &optval, sizeof(optval)) == -1) {
- rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno));
+ rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno));
}
return val;
}
+/*
+ * call-seq:
+ * gdbm.fastmode = boolean -> boolean
+ *
+ * Turns the database's fast mode on or off. If fast mode is turned on, gdbm
+ * does not wait for writes to be flushed to the disk before continuing.
+ *
+ * This option is obsolete for gdbm >= 1.8 since fast mode is turned on by
+ * default. See also: #syncmode=
+ */
static VALUE
fgdbm_set_fastmode(obj, val)
VALUE obj, val;
@@ -888,11 +1191,24 @@ fgdbm_set_fastmode(obj, val)
optval = 1;
if (gdbm_setopt(dbm, GDBM_FASTMODE, &optval, sizeof(optval)) == -1) {
- rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno));
+ rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno));
}
return val;
}
+/*
+ * call-seq:
+ * gdbm.syncmode = boolean -> boolean
+ *
+ * Turns the database's synchronization mode on or off. If the synchronization
+ * mode is turned on, the database's in-memory state will be synchronized to
+ * disk after every database modification operation. If the synchronization
+ * mode is turned off, GDBM does not wait for writes to be flushed to the disk
+ * before continuing.
+ *
+ * This option is only available for gdbm >= 1.8 where syncmode is turned off
+ * by default. See also: #fastmode=
+ */
static VALUE
fgdbm_set_syncmode(obj, val)
VALUE obj, val;
@@ -911,12 +1227,18 @@ fgdbm_set_syncmode(obj, val)
optval = 1;
if (gdbm_setopt(dbm, GDBM_FASTMODE, &optval, sizeof(optval)) == -1) {
- rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno));
+ rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno));
}
return val;
#endif
}
+/*
+ * call-seq:
+ * gdbm.to_hash -> hash
+ *
+ * Returns a hash of all key-value pairs contained in the database.
+ */
static VALUE
fgdbm_to_hash(obj)
VALUE obj;
@@ -936,6 +1258,13 @@ fgdbm_to_hash(obj)
return hash;
}
+/*
+ * call-seq:
+ * gdbm.reject { |key, value| block } -> hash
+ *
+ * Returns a hash copy of _gdbm_ where all key-value pairs from _gdbm_ for
+ * which _block_ evaluates to true are removed. See also: #delete_if
+ */
static VALUE
fgdbm_reject(obj)
VALUE obj;
@@ -981,15 +1310,15 @@ Init_gdbm()
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, "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);
@@ -1001,22 +1330,29 @@ Init_gdbm()
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() */
+ /* flag for #new and #open: open database as a reader */
rb_define_const(rb_cGDBM, "READER", INT2FIX(GDBM_READER|RUBY_GDBM_RW_BIT));
+ /* flag for #new and #open: open database as a writer */
rb_define_const(rb_cGDBM, "WRITER", INT2FIX(GDBM_WRITER|RUBY_GDBM_RW_BIT));
+ /* flag for #new and #open: open database as a writer; if the database does not exist, create a new one */
rb_define_const(rb_cGDBM, "WRCREAT", INT2FIX(GDBM_WRCREAT|RUBY_GDBM_RW_BIT));
+ /* flag for #new and #open: open database as a writer; overwrite any existing databases */
rb_define_const(rb_cGDBM, "NEWDB", INT2FIX(GDBM_NEWDB|RUBY_GDBM_RW_BIT));
+ /* flag for #new and #open. this flag is obsolete for gdbm >= 1.8 */
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)
+ /* flag for #new and #open. only for gdbm >= 1.8 */
rb_define_const(rb_cGDBM, "SYNC", INT2FIX(GDBM_SYNC));
#endif
#if defined(GDBM_NOLOCK)
+ /* flag for #new and #open */
rb_define_const(rb_cGDBM, "NOLOCK", INT2FIX(GDBM_NOLOCK));
#endif
+ /* version of the gdbm library*/
rb_define_const(rb_cGDBM, "VERSION", rb_str_new2(gdbm_version));
}
diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c
index 484abd203d..65fed33bd2 100644
--- a/ext/iconv/iconv.c
+++ b/ext/iconv/iconv.c
@@ -3,8 +3,8 @@
iconv.c -
- $Author: matz $
- $Date: 2005/12/12 00:36:51 $
+ $Author$
+ $Date$
created at: Wed Dec 1 20:28:09 JST 1999
All the files in this distribution are covered under the Ruby's
@@ -423,11 +423,8 @@ iconv_convert
length = 0;
else if ((length -= start) < 0)
length = 0;
- else {
+ else
inptr += start;
- if (length > slen)
- length = slen;
- }
}
instart = inptr;
inlen = length;
@@ -652,7 +649,7 @@ iconv_s_iconv
/*
* Document-method: Iconv::conv
- * call-seq: Iconv.iconv(to, from, *strs)
+ * call-seq: Iconv.conv(to, from, str)
*
* Shorthand for
* Iconv.iconv(to, from, str).join
diff --git a/ext/io/wait/extconf.rb b/ext/io/wait/extconf.rb
index 1352ef202e..e8181d25f5 100644
--- a/ext/io/wait/extconf.rb
+++ b/ext/io/wait/extconf.rb
@@ -3,7 +3,7 @@ target = "io/wait"
unless macro_defined?("DOSISH", "#include <ruby.h>")
fionread = %w[sys/ioctl.h sys/filio.h].find do |h|
- checking_for("FIONREAD") {have_macro("FIONREAD", h)}
+ have_macro("FIONREAD", h)
end
if fionread
$defs << "-DFIONREAD_HEADER=\"<#{fionread}>\""
diff --git a/ext/io/wait/wait.c b/ext/io/wait/wait.c
index 0e48f705d2..61d6527b36 100644
--- a/ext/io/wait/wait.c
+++ b/ext/io/wait/wait.c
@@ -2,8 +2,8 @@
io/wait.c -
- $Author: nobu $
- $Date: 2005/07/18 03:24:04 $
+ $Author$
+ $Date$
created at: Tue Aug 28 09:08:06 JST 2001
All the files in this distribution are covered under the Ruby's
diff --git a/ext/nkf/lib/kconv.rb b/ext/nkf/lib/kconv.rb
index 711a3c10a1..4ffe8d984e 100644
--- a/ext/nkf/lib/kconv.rb
+++ b/ext/nkf/lib/kconv.rb
@@ -1,7 +1,7 @@
#
# kconv.rb - Kanji Converter.
#
-# $Id: kconv.rb,v 1.3.6.6 2006/06/19 14:52:54 naruse Exp $
+# $Id$
#
# ----
#
@@ -49,7 +49,7 @@ module Kconv
#
# Revision of kconv.rb
- REVISION = %q$Revision: 1.3.6.6 $
+ REVISION = %q$Revision$
#Regexp of Encoding
@@ -63,8 +63,8 @@ module Kconv
RegexpEucjp = /\A(?:
[\x00-\x7f] |
\x8e [\xa1-\xdf] |
- \x8f [\xa1-\xdf] [\xa1-\xfe] |
- [\xa1-\xdf] [\xa1-\xfe]
+ \x8f [\xa1-\xfe] [\xa1-\xfe] |
+ [\xa1-\xfe] [\xa1-\xfe]
)*\z/nx
# Regexp of UTF-8 string (private constant)
@@ -156,7 +156,7 @@ module Kconv
# convert halfwidth katakana to fullwidth katakana.
# If you don't want it, use NKF.nkf('-exm0', str).
def toeuc(str)
- ::NKF::nkf('-em0', str)
+ ::NKF::nkf('-em', str)
end
module_function :toeuc
diff --git a/ext/nkf/nkf-utf8/nkf.c b/ext/nkf/nkf-utf8/nkf.c
index 0d82562326..3cd1b160da 100644
--- a/ext/nkf/nkf-utf8/nkf.c
+++ b/ext/nkf/nkf-utf8/nkf.c
@@ -39,9 +39,9 @@
** E-Mail: furukawa@tcp-ip.or.jp
** $B$^$G8fO"Mm$r$*4j$$$7$^$9!#(B
***********************************************************************/
-/* $Id: nkf.c,v 1.2.2.11 2006/06/19 14:52:55 naruse Exp $ */
-#define NKF_VERSION "2.0.7"
-#define NKF_RELEASE_DATE "2006-06-13"
+/* $Id$ */
+#define NKF_VERSION "2.0.8"
+#define NKF_RELEASE_DATE "2007-01-28"
#include "config.h"
#include "utf8tbl.h"
@@ -62,7 +62,7 @@
**
** t no operation
**
-** j Outout code is JIS 7 bit (DEFAULT SELECT)
+** j Output 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)
@@ -219,6 +219,7 @@ void djgpp_setbinmode(FILE *fp)
/* Input Assumption */
#define JIS_INPUT 4
+#define EUC_INPUT 16
#define SJIS_INPUT 5
#define LATIN1_INPUT 6
#define FIXED_MIME 7
@@ -232,8 +233,15 @@ void djgpp_setbinmode(FILE *fp)
#define UTF8 12
#define UTF8_INPUT 13
-#define UTF16BE_INPUT 14
-#define UTF16LE_INPUT 15
+#define UTF16_INPUT 1015
+#define UTF32_INPUT 1017
+
+/* byte order */
+
+#define ENDIAN_BIG 1234
+#define ENDIAN_LITTLE 4321
+#define ENDIAN_2143 2143
+#define ENDIAN_3412 3412
#define WISH_TRUE 15
@@ -353,8 +361,8 @@ static int ms_ucs_map_f = UCS_MAP_ASCII;
/* no NEC special, NEC-selected IBM extended and IBM extended characters */
static int no_cp932ext_f = FALSE;
/* ignore ZERO WIDTH NO-BREAK SPACE */
-static int ignore_zwnbsp_f = TRUE;
static int no_best_fit_chars_f = FALSE;
+static int input_endian = ENDIAN_BIG;
static nkf_char unicode_subchar = '?'; /* the regular substitution character */
static void nkf_each_char_to_hex(void (*f)(nkf_char c2,nkf_char c1), nkf_char c);
static void encode_fallback_html(nkf_char c);
@@ -366,18 +374,21 @@ static void (*encode_fallback)(nkf_char c) = NULL;
static nkf_char w2e_conv(nkf_char c2,nkf_char c1,nkf_char c0,nkf_char *p2,nkf_char *p1);
static nkf_char w_iconv(nkf_char c2,nkf_char c1,nkf_char c0);
static nkf_char w_iconv16(nkf_char c2,nkf_char c1,nkf_char c0);
+static nkf_char w_iconv32(nkf_char c2,nkf_char c1,nkf_char c0);
static nkf_char unicode_to_jis_common(nkf_char c2,nkf_char c1,nkf_char c0,nkf_char *p2,nkf_char *p1);
static nkf_char w_iconv_common(nkf_char c1,nkf_char c0,const unsigned short *const *pp,nkf_char psize,nkf_char *p2,nkf_char *p1);
static void w16w_conv(nkf_char val, nkf_char *p2, nkf_char *p1, nkf_char *p0);
static nkf_char ww16_conv(nkf_char c2, nkf_char c1, nkf_char c0);
static nkf_char w16e_conv(nkf_char val,nkf_char *p2,nkf_char *p1);
+static void w_status(struct input_code *, nkf_char);
#endif
#ifdef UTF8_OUTPUT_ENABLE
-static int unicode_bom_f= 0; /* Output Unicode BOM */
-static int w_oconv16_LE = 0; /* utf-16 little endian */
+static int output_bom_f = FALSE;
+static int output_endian = ENDIAN_BIG;
static nkf_char e2w_conv(nkf_char c2,nkf_char c1);
static void w_oconv(nkf_char c2,nkf_char c1);
static void w_oconv16(nkf_char c2,nkf_char c1);
+static void w_oconv32(nkf_char c2,nkf_char c1);
#endif
static void e_oconv(nkf_char c2,nkf_char c1);
static nkf_char e2s_conv(nkf_char c2, nkf_char c1, nkf_char *p2, nkf_char *p1);
@@ -437,7 +448,7 @@ static unsigned char stdibuf[IOBUF_SIZE];
static unsigned char stdobuf[IOBUF_SIZE];
#endif
static unsigned char hold_buf[HOLD_SIZE*2];
-static int hold_count;
+static int hold_count = 0;
/* MIME preprocessor fifo */
@@ -501,10 +512,10 @@ static nkf_char url_ungetc(nkf_char c,FILE *f);
#endif
#define PREFIX_EUCG3 NKF_INT32_C(0x8F00)
#define CLASS_MASK NKF_INT32_C(0xFF000000)
-#define CLASS_UTF16 NKF_INT32_C(0x01000000)
+#define CLASS_UNICODE NKF_INT32_C(0x01000000)
#define VALUE_MASK NKF_INT32_C(0x00FFFFFF)
#define UNICODE_MAX NKF_INT32_C(0x0010FFFF)
-#define is_unicode_capsule(c) ((c & CLASS_MASK) == CLASS_UTF16)
+#define is_unicode_capsule(c) ((c & CLASS_MASK) == CLASS_UNICODE)
#define is_unicode_bmp(c) ((c & VALUE_MASK) <= NKF_INT32_C(0xFFFF))
#ifdef NUMCHAR_OPTION
@@ -537,7 +548,7 @@ static int exec_f = 0;
#ifdef SHIFTJIS_CP932
/* invert IBM extended characters to others */
-static int cp51932_f = TRUE;
+static int cp51932_f = FALSE;
/* invert NEC-selected IBM extended characters to IBM extended characters */
static int cp932inv_f = TRUE;
@@ -565,18 +576,13 @@ static void status_check(struct input_code *ptr, nkf_char c);
static void e_status(struct input_code *, nkf_char);
static void s_status(struct input_code *, nkf_char);
-#ifdef UTF8_INPUT_ENABLE
-static void w_status(struct input_code *, nkf_char);
-static void w16_status(struct input_code *, nkf_char);
-static int utf16_mode = UTF16BE_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},
#ifdef UTF8_INPUT_ENABLE
{"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},
+ {"UTF-16", 0, 0, 0, {0, 0, 0}, NULL, w_iconv16, 0},
+ {"UTF-32", 0, 0, 0, {0, 0, 0}, NULL, w_iconv32, 0},
#endif
{0}
};
@@ -848,6 +854,7 @@ int main(int argc, char **argv)
}
} else {
int nfiles = argc;
+ int is_argument_error = FALSE;
while (argc--) {
is_inputcode_mixed = FALSE;
is_inputcode_set = FALSE;
@@ -857,7 +864,9 @@ int main(int argc, char **argv)
#endif
if ((fin = fopen((origfname = *argv++), "r")) == NULL) {
perror(*--argv);
- return(-1);
+ *argv++;
+ is_argument_error = TRUE;
+ continue;
} else {
#ifdef OVERWRITE
int fd = 0;
@@ -1005,6 +1014,8 @@ int main(int argc, char **argv)
#endif
}
}
+ if (is_argument_error)
+ return(-1);
}
#ifdef EASYWIN /*Easy Win */
if (file_out_f == FALSE)
@@ -1185,13 +1196,19 @@ void options(unsigned char *cp)
codeset[i] = nkf_toupper(p[i]);
}
codeset[i] = 0;
- if(strcmp(codeset, "ISO-2022-JP") == 0 ||
- strcmp(codeset, "X-ISO2022JP-CP932") == 0 ||
+ if(strcmp(codeset, "ISO-2022-JP") == 0){
+ input_f = JIS_INPUT;
+ }else if(strcmp(codeset, "X-ISO2022JP-CP932") == 0 ||
strcmp(codeset, "CP50220") == 0 ||
strcmp(codeset, "CP50221") == 0 ||
- strcmp(codeset, "CP50222") == 0 ||
- strcmp(codeset, "ISO-2022-JP-MS") == 0){
+ strcmp(codeset, "CP50222") == 0){
input_f = JIS_INPUT;
+#ifdef SHIFTJIS_CP932
+ cp51932_f = TRUE;
+#endif
+#ifdef UTF8_OUTPUT_ENABLE
+ ms_ucs_map_f = UCS_MAP_CP932;
+#endif
}else if(strcmp(codeset, "ISO-2022-JP-1") == 0){
input_f = JIS_INPUT;
#ifdef X0212_ENABLE
@@ -1205,13 +1222,11 @@ void options(unsigned char *cp)
x0213_f = TRUE;
}else if(strcmp(codeset, "SHIFT_JIS") == 0){
input_f = SJIS_INPUT;
- if (x0201_f==NO_X0201) x0201_f=TRUE;
}else if(strcmp(codeset, "WINDOWS-31J") == 0 ||
strcmp(codeset, "CSWINDOWS31J") == 0 ||
strcmp(codeset, "CP932") == 0 ||
strcmp(codeset, "MS932") == 0){
input_f = SJIS_INPUT;
- x0201_f = FALSE;
#ifdef SHIFTJIS_CP932
cp51932_f = TRUE;
#endif
@@ -1220,10 +1235,9 @@ void options(unsigned char *cp)
#endif
}else if(strcmp(codeset, "EUCJP") == 0 ||
strcmp(codeset, "EUC-JP") == 0){
- input_f = JIS_INPUT;
+ input_f = EUC_INPUT;
}else if(strcmp(codeset, "CP51932") == 0){
- input_f = JIS_INPUT;
- x0201_f = FALSE;
+ input_f = EUC_INPUT;
#ifdef SHIFTJIS_CP932
cp51932_f = TRUE;
#endif
@@ -1233,8 +1247,7 @@ void options(unsigned char *cp)
}else if(strcmp(codeset, "EUC-JP-MS") == 0 ||
strcmp(codeset, "EUCJP-MS") == 0 ||
strcmp(codeset, "EUCJPMS") == 0){
- input_f = JIS_INPUT;
- x0201_f = FALSE;
+ input_f = EUC_INPUT;
#ifdef SHIFTJIS_CP932
cp51932_f = FALSE;
#endif
@@ -1243,8 +1256,7 @@ void options(unsigned char *cp)
#endif
}else if(strcmp(codeset, "EUC-JP-ASCII") == 0 ||
strcmp(codeset, "EUCJP-ASCII") == 0){
- input_f = JIS_INPUT;
- x0201_f = FALSE;
+ input_f = EUC_INPUT;
#ifdef SHIFTJIS_CP932
cp51932_f = FALSE;
#endif
@@ -1257,17 +1269,13 @@ void options(unsigned char *cp)
x0213_f = TRUE;
#ifdef SHIFTJIS_CP932
cp51932_f = FALSE;
- cp932inv_f = FALSE;
#endif
- if (x0201_f==NO_X0201) x0201_f=TRUE;
}else if(strcmp(codeset, "EUC-JISX0213") == 0 ||
strcmp(codeset, "EUC-JIS-2004") == 0){
- input_f = JIS_INPUT;
- x0201_f = FALSE;
+ input_f = EUC_INPUT;
x0213_f = TRUE;
#ifdef SHIFTJIS_CP932
cp51932_f = FALSE;
- cp932inv_f = FALSE;
#endif
#ifdef UTF8_INPUT_ENABLE
}else if(strcmp(codeset, "UTF-8") == 0 ||
@@ -1280,61 +1288,78 @@ void options(unsigned char *cp)
input_f = UTF8_INPUT;
nfc_f = TRUE;
#endif
- }else if(strcmp(codeset, "UTF-16") == 0){
- input_f = UTF16BE_INPUT;
- utf16_mode = UTF16BE_INPUT;
- }else if(strcmp(codeset, "UTF-16BE") == 0 ||
+ }else if(strcmp(codeset, "UTF-16") == 0 ||
+ strcmp(codeset, "UTF-16BE") == 0 ||
strcmp(codeset, "UTF-16BE-BOM") == 0){
- input_f = UTF16BE_INPUT;
- utf16_mode = UTF16BE_INPUT;
+ input_f = UTF16_INPUT;
+ input_endian = ENDIAN_BIG;
}else if(strcmp(codeset, "UTF-16LE") == 0 ||
strcmp(codeset, "UTF-16LE-BOM") == 0){
- input_f = UTF16LE_INPUT;
- utf16_mode = UTF16LE_INPUT;
+ input_f = UTF16_INPUT;
+ input_endian = ENDIAN_LITTLE;
+ }else if(strcmp(codeset, "UTF-32") == 0 ||
+ strcmp(codeset, "UTF-32BE") == 0 ||
+ strcmp(codeset, "UTF-32BE-BOM") == 0){
+ input_f = UTF32_INPUT;
+ input_endian = ENDIAN_BIG;
+ }else if(strcmp(codeset, "UTF-32LE") == 0 ||
+ strcmp(codeset, "UTF-32LE-BOM") == 0){
+ input_f = UTF32_INPUT;
+ input_endian = ENDIAN_LITTLE;
#endif
}
continue;
}
if (strcmp(long_option[i].name, "oc=") == 0){
+ x0201_f = FALSE;
for (i=0; i < 16 && SPACE < p[i] && p[i] < DEL; i++){
codeset[i] = nkf_toupper(p[i]);
}
codeset[i] = 0;
- if(strcmp(codeset, "ISO-2022-JP") == 0 ||
- strcmp(codeset, "CP50220") == 0){
+ if(strcmp(codeset, "ISO-2022-JP") == 0){
output_conv = j_oconv;
}else if(strcmp(codeset, "X-ISO2022JP-CP932") == 0){
output_conv = j_oconv;
no_cp932ext_f = TRUE;
- }else if(strcmp(codeset, "CP50221") == 0 ||
- strcmp(codeset, "ISO-2022-JP-MS") == 0){
- output_conv = j_oconv;
- x0201_f = FALSE;
- }else if(strcmp(codeset, "ISO-2022-JP-1") == 0){
+#ifdef SHIFTJIS_CP932
+ cp932inv_f = FALSE;
+#endif
+#ifdef UTF8_OUTPUT_ENABLE
+ ms_ucs_map_f = UCS_MAP_CP932;
+#endif
+ }else if(strcmp(codeset, "CP50220") == 0){
output_conv = j_oconv;
-#ifdef X0212_ENABLE
- x0212_f = TRUE;
+ x0201_f = TRUE;
+#ifdef SHIFTJIS_CP932
+ cp932inv_f = FALSE;
#endif
+#ifdef UTF8_OUTPUT_ENABLE
+ ms_ucs_map_f = UCS_MAP_CP932;
+#endif
+ }else if(strcmp(codeset, "CP50221") == 0){
+ output_conv = j_oconv;
#ifdef SHIFTJIS_CP932
- cp51932_f = FALSE;
+ cp932inv_f = FALSE;
#endif
- }else if(strcmp(codeset, "ISO-2022-JP-3") == 0){
+#ifdef UTF8_OUTPUT_ENABLE
+ ms_ucs_map_f = UCS_MAP_CP932;
+#endif
+ }else if(strcmp(codeset, "ISO-2022-JP-1") == 0){
output_conv = j_oconv;
#ifdef X0212_ENABLE
x0212_f = TRUE;
#endif
- x0213_f = TRUE;
#ifdef SHIFTJIS_CP932
- cp51932_f = FALSE;
+ cp932inv_f = FALSE;
#endif
- }else if(strcmp(codeset, "ISO-2022-JP-MS") == 0){
+ }else if(strcmp(codeset, "ISO-2022-JP-3") == 0){
output_conv = j_oconv;
- x0201_f = FALSE;
#ifdef X0212_ENABLE
x0212_f = TRUE;
#endif
+ x0213_f = TRUE;
#ifdef SHIFTJIS_CP932
- cp51932_f = FALSE;
+ cp932inv_f = FALSE;
#endif
}else if(strcmp(codeset, "SHIFT_JIS") == 0){
output_conv = s_oconv;
@@ -1343,11 +1368,6 @@ void options(unsigned char *cp)
strcmp(codeset, "CP932") == 0 ||
strcmp(codeset, "MS932") == 0){
output_conv = s_oconv;
- x0201_f = FALSE;
-#ifdef SHIFTJIS_CP932
- cp51932_f = TRUE;
- cp932inv_f = TRUE;
-#endif
#ifdef UTF8_OUTPUT_ENABLE
ms_ucs_map_f = UCS_MAP_CP932;
#endif
@@ -1356,9 +1376,8 @@ void options(unsigned char *cp)
output_conv = e_oconv;
}else if(strcmp(codeset, "CP51932") == 0){
output_conv = e_oconv;
- x0201_f = FALSE;
#ifdef SHIFTJIS_CP932
- cp51932_f = TRUE;
+ cp932inv_f = FALSE;
#endif
#ifdef UTF8_OUTPUT_ENABLE
ms_ucs_map_f = UCS_MAP_CP932;
@@ -1367,26 +1386,18 @@ void options(unsigned char *cp)
strcmp(codeset, "EUCJP-MS") == 0 ||
strcmp(codeset, "EUCJPMS") == 0){
output_conv = e_oconv;
- x0201_f = FALSE;
#ifdef X0212_ENABLE
x0212_f = TRUE;
#endif
-#ifdef SHIFTJIS_CP932
- cp51932_f = FALSE;
-#endif
#ifdef UTF8_OUTPUT_ENABLE
ms_ucs_map_f = UCS_MAP_MS;
#endif
}else if(strcmp(codeset, "EUC-JP-ASCII") == 0 ||
strcmp(codeset, "EUCJP-ASCII") == 0){
output_conv = e_oconv;
- x0201_f = FALSE;
#ifdef X0212_ENABLE
x0212_f = TRUE;
#endif
-#ifdef SHIFTJIS_CP932
- cp51932_f = FALSE;
-#endif
#ifdef UTF8_OUTPUT_ENABLE
ms_ucs_map_f = UCS_MAP_ASCII;
#endif
@@ -1405,32 +1416,42 @@ void options(unsigned char *cp)
#endif
x0213_f = TRUE;
#ifdef SHIFTJIS_CP932
- cp51932_f = FALSE;
+ cp932inv_f = FALSE;
#endif
#ifdef UTF8_OUTPUT_ENABLE
}else if(strcmp(codeset, "UTF-8") == 0){
output_conv = w_oconv;
}else if(strcmp(codeset, "UTF-8N") == 0){
output_conv = w_oconv;
- unicode_bom_f=1;
}else if(strcmp(codeset, "UTF-8-BOM") == 0){
output_conv = w_oconv;
- unicode_bom_f=2;
+ output_bom_f = TRUE;
}else if(strcmp(codeset, "UTF-16BE") == 0){
- output_conv = w_oconv16;
- unicode_bom_f=1;
+ output_conv = w_oconv16;
}else if(strcmp(codeset, "UTF-16") == 0 ||
strcmp(codeset, "UTF-16BE-BOM") == 0){
- output_conv = w_oconv16;
- unicode_bom_f=2;
+ output_conv = w_oconv16;
+ output_bom_f = TRUE;
}else if(strcmp(codeset, "UTF-16LE") == 0){
- output_conv = w_oconv16;
- w_oconv16_LE = 1;
- unicode_bom_f=1;
+ output_conv = w_oconv16;
+ output_endian = ENDIAN_LITTLE;
}else if(strcmp(codeset, "UTF-16LE-BOM") == 0){
- output_conv = w_oconv16;
- w_oconv16_LE = 1;
- unicode_bom_f=2;
+ output_conv = w_oconv16;
+ output_endian = ENDIAN_LITTLE;
+ output_bom_f = TRUE;
+ }else if(strcmp(codeset, "UTF-32") == 0 ||
+ strcmp(codeset, "UTF-32BE") == 0){
+ output_conv = w_oconv32;
+ }else if(strcmp(codeset, "UTF-32BE-BOM") == 0){
+ output_conv = w_oconv32;
+ output_bom_f = TRUE;
+ }else if(strcmp(codeset, "UTF-32LE") == 0){
+ output_conv = w_oconv32;
+ output_endian = ENDIAN_LITTLE;
+ }else if(strcmp(codeset, "UTF-32LE-BOM") == 0){
+ output_conv = w_oconv32;
+ output_endian = ENDIAN_LITTLE;
+ output_bom_f = TRUE;
#endif
}
continue;
@@ -1649,6 +1670,7 @@ void options(unsigned char *cp)
continue;
case 'e': /* AT&T EUC output */
output_conv = e_oconv;
+ cp932inv_f = FALSE;
continue;
case 's': /* SJIS output */
output_conv = s_oconv;
@@ -1695,57 +1717,72 @@ void options(unsigned char *cp)
#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] == '8') {
+ output_conv = w_oconv; cp++;
+ if (cp[0] == '0'){
+ cp++;
+ } else {
+ output_bom_f = TRUE;
+ }
+ } else {
+ if ('1'== cp[0] && '6'==cp[1]) {
+ output_conv = w_oconv16; cp+=2;
+ } else if ('3'== cp[0] && '2'==cp[1]) {
+ output_conv = w_oconv32; cp+=2;
+ } else {
+ output_conv = w_oconv;
+ continue;
+ }
if (cp[0]=='L') {
- unicode_bom_f=2; cp++;
- w_oconv16_LE = 1;
- if (cp[0] == '0'){
- unicode_bom_f=1; cp++;
- }
+ cp++;
+ output_endian = ENDIAN_LITTLE;
} else if (cp[0] == 'B') {
- unicode_bom_f=2; cp++;
- if (cp[0] == '0'){
- unicode_bom_f=1; cp++;
- }
- }
- } else if (cp[0] == '8') {
- output_conv = w_oconv; cp++;
- unicode_bom_f=2;
+ cp++;
+ } else {
+ continue;
+ }
if (cp[0] == '0'){
- unicode_bom_f=1; cp++;
+ cp++;
+ } else {
+ output_bom_f = TRUE;
}
- } 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 = UTF16BE_INPUT;
- utf16_mode = UTF16BE_INPUT;
- cp += 2;
+ case 'W': /* UTF input */
+ if (cp[0] == '8') {
+ cp++;
+ input_f = UTF8_INPUT;
+ }else{
+ if ('1'== cp[0] && '6'==cp[1]) {
+ cp += 2;
+ input_f = UTF16_INPUT;
+ input_endian = ENDIAN_BIG;
+ } else if ('3'== cp[0] && '2'==cp[1]) {
+ cp += 2;
+ input_f = UTF32_INPUT;
+ input_endian = ENDIAN_BIG;
+ } else {
+ input_f = UTF8_INPUT;
+ continue;
+ }
if (cp[0]=='L') {
cp++;
- input_f = UTF16LE_INPUT;
- utf16_mode = UTF16LE_INPUT;
+ input_endian = ENDIAN_LITTLE;
} else if (cp[0] == 'B') {
cp++;
- input_f = UTF16BE_INPUT;
- utf16_mode = UTF16BE_INPUT;
}
- } else if (cp[0] == '8') {
- cp++;
- input_f = UTF8_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 'E': /* AT&T EUC input */
+ input_f = EUC_INPUT;
+ continue;
case 'S': /* MS Kanji input */
input_f = SJIS_INPUT;
if (x0201_f==NO_X0201) x0201_f=TRUE;
@@ -1874,12 +1911,7 @@ void options(unsigned char *cp)
}
}
-#ifdef ANSI_C_PROTOTYPE
struct input_code * find_inputcode_byfunc(nkf_char (*iconv_func)(nkf_char c2,nkf_char c1,nkf_char c0))
-#else
-struct input_code * find_inputcode_byfunc(iconv_func)
- nkf_char (*iconv_func)();
-#endif
{
if (iconv_func){
struct input_code *p = input_code_list;
@@ -2135,52 +2167,6 @@ void e_status(struct input_code *ptr, nkf_char c)
}
#ifdef UTF8_INPUT_ENABLE
-void w16_status(struct input_code *ptr, nkf_char 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(struct input_code *ptr, nkf_char c)
{
switch (ptr->stat){
@@ -2200,6 +2186,9 @@ void w_status(struct input_code *ptr, nkf_char c)
}else if (0xe0 <= c && c <= 0xef){
ptr->stat = 2;
status_push_ch(ptr, c);
+ }else if (0xf0 <= c && c <= 0xf4){
+ ptr->stat = 3;
+ status_push_ch(ptr, c);
}else{
status_disable(ptr);
}
@@ -2222,6 +2211,17 @@ void w_status(struct input_code *ptr, nkf_char c)
status_disable(ptr);
}
break;
+ case 3:
+ if (0x80 <= c && c <= 0xbf){
+ if (ptr->index < ptr->stat){
+ status_push_ch(ptr, c);
+ } else {
+ status_clear(ptr);
+ }
+ }else{
+ status_disable(ptr);
+ }
+ break;
}
}
#endif
@@ -2232,6 +2232,12 @@ void code_status(nkf_char c)
struct input_code *result = 0;
struct input_code *p = input_code_list;
while (p->name){
+ if (!p->status_func) {
+ ++p;
+ continue;
+ }
+ if (!p->status_func)
+ continue;
(p->status_func)(p, c);
if (p->stat > 0){
action_flag = 0;
@@ -2374,17 +2380,17 @@ void module_connection(void)
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) {
+ if (input_f == JIS_INPUT || input_f == EUC_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 == UTF16BE_INPUT) {
- set_iconv(-TRUE, w_iconv16);
- } else if (input_f == UTF16LE_INPUT) {
+ } else if (input_f == UTF16_INPUT) {
set_iconv(-TRUE, w_iconv16);
+ } else if (input_f == UTF32_INPUT) {
+ set_iconv(-TRUE, w_iconv32);
#endif
} else {
set_iconv(FALSE, e_iconv);
@@ -2399,27 +2405,133 @@ void module_connection(void)
}
/*
+ * Check and Ignore BOM
+ */
+void check_bom(FILE *f)
+{
+ int c2;
+ switch(c2 = (*i_getc)(f)){
+ case 0x00:
+ if((c2 = (*i_getc)(f)) == 0x00){
+ if((c2 = (*i_getc)(f)) == 0xFE){
+ if((c2 = (*i_getc)(f)) == 0xFF){
+ if(!input_f){
+ set_iconv(TRUE, w_iconv32);
+ }
+ if (iconv == w_iconv32) {
+ input_endian = ENDIAN_BIG;
+ return;
+ }
+ (*i_ungetc)(0xFF,f);
+ }else (*i_ungetc)(c2,f);
+ (*i_ungetc)(0xFE,f);
+ }else if(c2 == 0xFF){
+ if((c2 = (*i_getc)(f)) == 0xFE){
+ if(!input_f){
+ set_iconv(TRUE, w_iconv32);
+ }
+ if (iconv == w_iconv32) {
+ input_endian = ENDIAN_2143;
+ return;
+ }
+ (*i_ungetc)(0xFF,f);
+ }else (*i_ungetc)(c2,f);
+ (*i_ungetc)(0xFF,f);
+ }else (*i_ungetc)(c2,f);
+ (*i_ungetc)(0x00,f);
+ }else (*i_ungetc)(c2,f);
+ (*i_ungetc)(0x00,f);
+ break;
+ case 0xEF:
+ if((c2 = (*i_getc)(f)) == 0xBB){
+ if((c2 = (*i_getc)(f)) == 0xBF){
+ if(!input_f){
+ set_iconv(TRUE, w_iconv);
+ }
+ if (iconv == w_iconv) {
+ return;
+ }
+ (*i_ungetc)(0xBF,f);
+ }else (*i_ungetc)(c2,f);
+ (*i_ungetc)(0xBB,f);
+ }else (*i_ungetc)(c2,f);
+ (*i_ungetc)(0xEF,f);
+ break;
+ case 0xFE:
+ if((c2 = (*i_getc)(f)) == 0xFF){
+ if((c2 = (*i_getc)(f)) == 0x00){
+ if((c2 = (*i_getc)(f)) == 0x00){
+ if(!input_f){
+ set_iconv(TRUE, w_iconv32);
+ }
+ if (iconv == w_iconv32) {
+ input_endian = ENDIAN_3412;
+ return;
+ }
+ (*i_ungetc)(0x00,f);
+ }else (*i_ungetc)(c2,f);
+ (*i_ungetc)(0x00,f);
+ }else (*i_ungetc)(c2,f);
+ if(!input_f){
+ set_iconv(TRUE, w_iconv16);
+ }
+ if (iconv == w_iconv16) {
+ input_endian = ENDIAN_BIG;
+ return;
+ }
+ (*i_ungetc)(0xFF,f);
+ }else (*i_ungetc)(c2,f);
+ (*i_ungetc)(0xFE,f);
+ break;
+ case 0xFF:
+ if((c2 = (*i_getc)(f)) == 0xFE){
+ if((c2 = (*i_getc)(f)) == 0x00){
+ if((c2 = (*i_getc)(f)) == 0x00){
+ if(!input_f){
+ set_iconv(TRUE, w_iconv32);
+ }
+ if (iconv == w_iconv32) {
+ input_endian = ENDIAN_LITTLE;
+ return;
+ }
+ (*i_ungetc)(0x00,f);
+ }else (*i_ungetc)(c2,f);
+ (*i_ungetc)(0x00,f);
+ }else (*i_ungetc)(c2,f);
+ if(!input_f){
+ set_iconv(TRUE, w_iconv16);
+ }
+ if (iconv == w_iconv16) {
+ input_endian = ENDIAN_LITTLE;
+ return;
+ }
+ (*i_ungetc)(0xFE,f);
+ }else (*i_ungetc)(c2,f);
+ (*i_ungetc)(0xFF,f);
+ break;
+ default:
+ (*i_ungetc)(c2,f);
+ break;
+ }
+}
+
+/*
Conversion main loop. Code detection only.
*/
nkf_char kanji_convert(FILE *f)
{
- nkf_char c1,
- c2, c3;
+ nkf_char c3, c2=0, c1, c0=0;
int is_8bit = FALSE;
- module_connection();
- c2 = 0;
-
- if(input_f == SJIS_INPUT
+ if(input_f == SJIS_INPUT || input_f == EUC_INPUT
#ifdef UTF8_INPUT_ENABLE
- || input_f == UTF8_INPUT || input_f == UTF16BE_INPUT || input_f == UTF16LE_INPUT
+ || input_f == UTF8_INPUT || input_f == UTF16_INPUT
#endif
){
is_8bit = TRUE;
}
-
input_mode = ASCII;
output_mode = ASCII;
shift_mode = FALSE;
@@ -2428,6 +2540,9 @@ nkf_char kanji_convert(FILE *f)
#define SEND ; /* output c1 and c2, get next */
#define LAST break /* end of loop, go closing */
+ module_connection();
+ check_bom(f);
+
while ((c1 = (*i_getc)(f)) != EOF) {
#ifdef INPUT_CODE_FIX
if (!input_f)
@@ -2435,7 +2550,7 @@ nkf_char kanji_convert(FILE *f)
code_status(c1);
if (c2) {
/* second byte */
- if (c2 > DEL) {
+ if (c2 > ((input_f == JIS_INPUT && ms_ucs_map_f) ? 0x92 : DEL)) {
/* in case of 8th bit is on */
if (!estab_f&&!mime_decode_mode) {
/* in case of not established yet */
@@ -2445,14 +2560,16 @@ nkf_char kanji_convert(FILE *f)
else
c2 = 0;
NEXT;
- } else
- /* in case of already established */
- if (c1 < AT) {
- /* ignore bogus code */
- c2 = 0;
- NEXT;
- } else
- SEND;
+ } else {
+ /* in case of already established */
+ if (c1 < AT) {
+ /* ignore bogus code and not CP5022x UCD */
+ c2 = 0;
+ NEXT;
+ } else {
+ SEND;
+ }
+ }
} else
/* second byte, 7 bit code */
/* it might be kanji shitfted */
@@ -2464,25 +2581,68 @@ nkf_char kanji_convert(FILE *f)
SEND;
} else {
/* first byte */
- if (
#ifdef UTF8_INPUT_ENABLE
- iconv == w_iconv16
-#else
- 0
-#endif
- ) {
- c2 = c1;
- c1 = (*i_getc)(f);
+ if (iconv == w_iconv16) {
+ if (input_endian == ENDIAN_BIG) {
+ c2 = c1;
+ if ((c1 = (*i_getc)(f)) != EOF) {
+ if (0xD8 <= c2 && c2 <= 0xDB) {
+ if ((c0 = (*i_getc)(f)) != EOF) {
+ c0 <<= 8;
+ if ((c3 = (*i_getc)(f)) != EOF) {
+ c0 |= c3;
+ } else c2 = EOF;
+ } else c2 = EOF;
+ }
+ } else c2 = EOF;
+ } else {
+ if ((c2 = (*i_getc)(f)) != EOF) {
+ if (0xD8 <= c2 && c2 <= 0xDB) {
+ if ((c3 = (*i_getc)(f)) != EOF) {
+ if ((c0 = (*i_getc)(f)) != EOF) {
+ c0 <<= 8;
+ c0 |= c3;
+ } else c2 = EOF;
+ } else c2 = EOF;
+ }
+ } else c2 = EOF;
+ }
SEND;
+ } else if(iconv == w_iconv32){
+ int c3 = c1;
+ if((c2 = (*i_getc)(f)) != EOF &&
+ (c1 = (*i_getc)(f)) != EOF &&
+ (c0 = (*i_getc)(f)) != EOF){
+ switch(input_endian){
+ case ENDIAN_BIG:
+ c1 = (c2&0xFF)<<16 | (c1&0xFF)<<8 | (c0&0xFF);
+ break;
+ case ENDIAN_LITTLE:
+ c1 = (c3&0xFF) | (c2&0xFF)<<8 | (c1&0xFF)<<16;
+ break;
+ case ENDIAN_2143:
+ c1 = (c3&0xFF)<<16 | (c1&0xFF) | (c0&0xFF)<<8;
+ break;
+ case ENDIAN_3412:
+ c1 = (c3&0xFF)<<8 | (c2&0xFF) | (c0&0xFF)<<16;
+ break;
+ }
+ c2 = 0;
+ }else{
+ c2 = EOF;
+ }
+ SEND;
+ } else
+#endif
#ifdef NUMCHAR_OPTION
- } else if (is_unicode_capsule(c1)){
+ if (is_unicode_capsule(c1)){
SEND;
+ } else
#endif
- } else if (c1 > DEL) {
+ if (c1 > ((input_f == JIS_INPUT && ms_ucs_map_f) ? 0x92 : DEL)) {
/* 8 bit code */
if (!estab_f && !iso8859_f) {
/* not established yet */
- if (!is_8bit) is_8bit = TRUE;
c2 = c1;
NEXT;
} else { /* estab_f==TRUE */
@@ -2573,13 +2733,13 @@ nkf_char kanji_convert(FILE *f)
/* normal ASCII code */
SEND;
}
- } else if (!is_8bit && c1 == SI) {
+ } else if (c1 == SI && (!is_8bit || mime_decode_mode)) {
shift_mode = FALSE;
NEXT;
- } else if (!is_8bit && c1 == SO) {
+ } else if (c1 == SO && (!is_8bit || mime_decode_mode)) {
shift_mode = TRUE;
NEXT;
- } else if (!is_8bit && c1 == ESC ) {
+ } else if (c1 == ESC && (!is_8bit || mime_decode_mode)) {
if ((c1 = (*i_getc)(f)) == EOF) {
/* (*oconv)(0, ESC); don't send bogus code */
LAST;
@@ -2687,6 +2847,44 @@ nkf_char kanji_convert(FILE *f)
(*oconv)(0, ESC);
SEND;
}
+ } else if (c1 == ESC && iconv == s_iconv) {
+ /* ESC in Shift_JIS */
+ if ((c1 = (*i_getc)(f)) == EOF) {
+ /* (*oconv)(0, ESC); don't send bogus code */
+ LAST;
+ } else if (c1 == '$') {
+ /* J-PHONE emoji */
+ if ((c1 = (*i_getc)(f)) == EOF) {
+ /*
+ (*oconv)(0, ESC); don't send bogus code
+ (*oconv)(0, '$'); */
+ LAST;
+ } else {
+ if (('E' <= c1 && c1 <= 'G') ||
+ ('O' <= c1 && c1 <= 'Q')) {
+ /*
+ NUM : 0 1 2 3 4 5
+ BYTE: G E F O P Q
+ C%7 : 1 6 0 2 3 4
+ C%7 : 0 1 2 3 4 5 6
+ NUM : 2 0 3 4 5 X 1
+ */
+ static const int jphone_emoji_first_table[7] = {2, 0, 3, 4, 5, 0, 1};
+ c0 = (jphone_emoji_first_table[c1 % 7] << 8) - SPACE + 0xE000 + CLASS_UNICODE;
+ while ((c1 = (*i_getc)(f)) != EOF) {
+ if (SPACE <= c1 && c1 <= 'z') {
+ (*oconv)(0, c1 + c0);
+ } else break; /* c1 == SO */
+ }
+ }
+ }
+ if (c1 == EOF) LAST;
+ NEXT;
+ } else {
+ /* lonely ESC */
+ (*oconv)(0, ESC);
+ SEND;
+ }
} else if ((c1 == NL || c1 == CR) && broken_f&4) {
input_mode = ASCII; set_iconv(FALSE, 0);
SEND;
@@ -2716,22 +2914,47 @@ nkf_char kanji_convert(FILE *f)
}
c1 = CR;
SEND;
+ } else if (c1 == DEL && input_mode == X0208 ) {
+ /* CP5022x */
+ c2 = c1;
+ NEXT;
} else
SEND;
}
/* send: */
switch(input_mode){
case ASCII:
- if ((*iconv)(c2, c1, 0) < 0){ /* can be EUC/SJIS */
- nkf_char c0 = (*i_getc)(f);
- if (c0 != EOF){
+ switch ((*iconv)(c2, c1, c0)) { /* can be EUC / SJIS / UTF-8 / UTF-16 */
+ case -2:
+ /* 4 bytes UTF-8 */
+ if ((c0 = (*i_getc)(f)) != EOF) {
+ code_status(c0);
+ c0 <<= 8;
+ if ((c3 = (*i_getc)(f)) != EOF) {
+ code_status(c3);
+ (*iconv)(c2, c1, c0|c3);
+ }
+ }
+ break;
+ case -1:
+ /* 3 bytes EUC or UTF-8 */
+ if ((c0 = (*i_getc)(f)) != EOF) {
code_status(c0);
(*iconv)(c2, c1, c0);
}
+ break;
}
break;
case X0208:
case X0213_1:
+ if (ms_ucs_map_f &&
+ 0x7F <= c2 && c2 <= 0x92 &&
+ 0x21 <= c1 && c1 <= 0x7E) {
+ /* CP932 UDC */
+ if(c1 == 0x7F) return 0;
+ c1 = (c2 - 0x7F) * 94 + c1 - 0x21 + 0xE000 + CLASS_UNICODE;
+ c2 = 0;
+ }
(*oconv)(c2, c1); /* this is JIS, not SJIS/EUC case */
break;
#ifdef X0212_ENABLE
@@ -2747,6 +2970,7 @@ nkf_char kanji_convert(FILE *f)
}
c2 = 0;
+ c0 = 0;
continue;
/* goto next_word */
}
@@ -2771,7 +2995,8 @@ nkf_char kanji_convert(FILE *f)
nkf_char
h_conv(FILE *f, nkf_char c2, nkf_char c1)
{
- nkf_char wc,c3;
+ nkf_char ret, c3, c0;
+ int hold_index;
/** it must NOT be in the kanji shifte sequence */
@@ -2818,10 +3043,10 @@ h_conv(FILE *f, nkf_char c2, nkf_char c1)
** Kanji codes by oconv and leave estab_f unchanged.
**/
- c3=c1;
- wc = 0;
- while (wc < hold_count){
- c2 = hold_buf[wc++];
+ ret = c1;
+ hold_index = 0;
+ while (hold_index < hold_count){
+ c2 = hold_buf[hold_index++];
if (c2 <= DEL
#ifdef NUMCHAR_OPTION
|| is_unicode_capsule(c2)
@@ -2833,8 +3058,8 @@ h_conv(FILE *f, nkf_char c2, nkf_char c1)
(*iconv)(X0201, c2, 0);
continue;
}
- if (wc < hold_count){
- c1 = hold_buf[wc++];
+ if (hold_index < hold_count){
+ c1 = hold_buf[hold_index++];
}else{
c1 = (*i_getc)(f);
if (c1 == EOF){
@@ -2843,28 +3068,48 @@ h_conv(FILE *f, nkf_char c2, nkf_char c1)
}
code_status(c1);
}
- if ((*iconv)(c2, c1, 0) < 0){
- nkf_char c0;
- if (wc < hold_count){
- c0 = hold_buf[wc++];
- }else{
- c0 = (*i_getc)(f);
- if (c0 == EOF){
- c3 = EOF;
- break;
- }
+ c0 = 0;
+ switch ((*iconv)(c2, c1, 0)) { /* can be EUC/SJIS/UTF-8 */
+ case -2:
+ /* 4 bytes UTF-8 */
+ if (hold_index < hold_count){
+ c0 = hold_buf[hold_index++];
+ } else if ((c0 = (*i_getc)(f)) == EOF) {
+ ret = EOF;
+ break;
+ } else {
+ code_status(c0);
+ c0 <<= 8;
+ if (hold_index < hold_count){
+ c3 = hold_buf[hold_index++];
+ } else if ((c3 = (*i_getc)(f)) == EOF) {
+ c0 = ret = EOF;
+ break;
+ } else {
+ code_status(c3);
+ (*iconv)(c2, c1, c0|c3);
+ }
+ }
+ break;
+ case -1:
+ /* 3 bytes EUC or UTF-8 */
+ if (hold_index < hold_count){
+ c0 = hold_buf[hold_index++];
+ } else if ((c0 = (*i_getc)(f)) == EOF) {
+ ret = EOF;
+ break;
+ } else {
code_status(c0);
}
(*iconv)(c2, c1, c0);
- }
+ break;
+ }
+ if (c0 == EOF) break;
}
- return c3;
+ return ret;
}
-
-
-nkf_char
-push_hold_buf(nkf_char c2)
+nkf_char push_hold_buf(nkf_char c2)
{
if (hold_count >= HOLD_SIZE*2)
return (EOF);
@@ -2879,7 +3124,7 @@ nkf_char s2e_conv(nkf_char c2, nkf_char c1, nkf_char *p2, nkf_char *p1)
#endif
static const nkf_char shift_jisx0213_s1a3_table[5][2] ={ { 1, 8}, { 3, 4}, { 5,12}, {13,14}, {15, 0} };
#ifdef SHIFTJIS_CP932
- if (cp51932_f && is_ibmext_in_sjis(c2)){
+ if (!cp932inv_f && is_ibmext_in_sjis(c2)){
#if 0
extern const unsigned short shiftjis_cp932[3][189];
#endif
@@ -2889,6 +3134,17 @@ nkf_char s2e_conv(nkf_char c2, nkf_char c1, nkf_char *p2, nkf_char *p1)
c1 = val & 0xff;
}
}
+ if (cp932inv_f
+ && CP932INV_TABLE_BEGIN <= c2 && c2 <= CP932INV_TABLE_END){
+#if 0
+ extern const unsigned short cp932inv[2][189];
+#endif
+ nkf_char c = cp932inv[c2 - CP932INV_TABLE_BEGIN][c1 - 0x40];
+ if (c){
+ c2 = c >> 8;
+ c1 = c & 0xff;
+ }
+ }
#endif /* SHIFTJIS_CP932 */
#ifdef X0212_ENABLE
if (!x0213_f && is_ibmext_in_sjis(c2)){
@@ -2898,7 +3154,7 @@ nkf_char s2e_conv(nkf_char c2, nkf_char c1, nkf_char *p2, nkf_char *p1)
val = shiftjis_x0212[c2 - 0xfa][c1 - 0x40];
if (val){
if (val > 0x7FFF){
- c2 = PREFIX_EUCG3 | (val >> 8);
+ c2 = PREFIX_EUCG3 | ((val >> 8) & 0x7f);
c1 = val & 0xff;
}else{
c2 = val >> 8;
@@ -2943,6 +3199,11 @@ nkf_char s_iconv(nkf_char c2, nkf_char c1, nkf_char c0)
c1 &= 0x7f;
} else if ((c2 == EOF) || (c2 == 0) || c2 < SPACE) {
/* NOP */
+ } else if (!x0213_f && 0xF0 <= c2 && c2 <= 0xF9 && 0x40 <= c1 && c1 <= 0xFC) {
+ /* CP932 UDC */
+ if(c1 == 0x7F) return 0;
+ c1 = (c2 - 0xF0) * 188 + (c1 - 0x40 - (0x7E < c1)) + 0xE000 + CLASS_UNICODE;
+ c2 = 0;
} else {
nkf_char ret = s2e_conv(c2, c1, &c2, &c1);
if (ret) return ret;
@@ -2960,20 +3221,26 @@ nkf_char e_iconv(nkf_char c2, nkf_char c1, nkf_char c0)
if (c0 == 0){
return -1;
}
- c2 = (c2 << 8) | (c1 & 0x7f);
- c1 = c0 & 0x7f;
+ if (!cp51932_f && !x0213_f && 0xF5 <= c1 && c1 <= 0xFE && 0xA1 <= c0 && c0 <= 0xFE) {
+ /* encoding is eucJP-ms, so invert to Unicode Private User Area */
+ c1 = (c1 - 0xF5) * 94 + c0 - 0xA1 + 0xE3AC + CLASS_UNICODE;
+ c2 = 0;
+ } else {
+ c2 = (c2 << 8) | (c1 & 0x7f);
+ c1 = c0 & 0x7f;
#ifdef SHIFTJIS_CP932
- if (cp51932_f){
- nkf_char s2, s1;
- if (e2s_conv(c2, c1, &s2, &s1) == 0){
- s2e_conv(s2, s1, &c2, &c1);
- if (c2 < 0x100){
- c1 &= 0x7f;
- c2 &= 0x7f;
- }
- }
- }
+ if (cp51932_f){
+ nkf_char s2, s1;
+ if (e2s_conv(c2, c1, &s2, &s1) == 0){
+ s2e_conv(s2, s1, &c2, &c1);
+ if (c2 < 0x100){
+ c1 &= 0x7f;
+ c2 &= 0x7f;
+ }
+ }
+ }
#endif /* SHIFTJIS_CP932 */
+ }
#endif /* X0212_ENABLE */
} else if (c2 == SSO){
c2 = X0201;
@@ -2981,8 +3248,26 @@ nkf_char e_iconv(nkf_char c2, nkf_char c1, nkf_char c0)
} else if ((c2 == EOF) || (c2 == 0) || c2 < SPACE) {
/* NOP */
} else {
- c1 &= 0x7f;
- c2 &= 0x7f;
+ if (!cp51932_f && ms_ucs_map_f && 0xF5 <= c2 && c2 <= 0xFE && 0xA1 <= c1 && c1 <= 0xFE) {
+ /* encoding is eucJP-ms, so invert to Unicode Private User Area */
+ c1 = (c2 - 0xF5) * 94 + c1 - 0xA1 + 0xE000 + CLASS_UNICODE;
+ c2 = 0;
+ } else {
+ c1 &= 0x7f;
+ c2 &= 0x7f;
+#ifdef SHIFTJIS_CP932
+ if (cp51932_f && 0x79 <= c2 && c2 <= 0x7c){
+ nkf_char s2, s1;
+ if (e2s_conv(c2, c1, &s2, &s1) == 0){
+ s2e_conv(s2, s1, &c2, &c1);
+ if (c2 < 0x100){
+ c1 &= 0x7f;
+ c2 &= 0x7f;
+ }
+ }
+ }
+#endif /* SHIFTJIS_CP932 */
+ }
}
(*oconv)(c2, c1);
return 0;
@@ -3001,7 +3286,7 @@ nkf_char w2e_conv(nkf_char c2, nkf_char c1, nkf_char c0, nkf_char *p2, nkf_char
#ifdef NUMCHAR_OPTION
if (ret > 0){
if (p2) *p2 = 0;
- if (p1) *p1 = CLASS_UTF16 | ww16_conv(c2, c1, c0);
+ if (p1) *p1 = CLASS_UNICODE | ww16_conv(c2, c1, c0);
ret = 0;
}
#endif
@@ -3012,43 +3297,63 @@ nkf_char w2e_conv(nkf_char c2, nkf_char c1, nkf_char c0, nkf_char *p2, nkf_char
nkf_char w_iconv(nkf_char c2, nkf_char c1, nkf_char c0)
{
nkf_char ret = 0;
+ static const int w_iconv_utf8_1st_byte[] =
+ { /* 0xC0 - 0xFF */
+ 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
+ 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 33, 33,
+ 40, 41, 41, 41, 42, 43, 43, 43, 50, 50, 50, 50, 60, 60, 70, 70};
- /* throw away ZERO WIDTH NO-BREAK SPACE (U+FEFF) */
- if(ignore_zwnbsp_f){
- ignore_zwnbsp_f = FALSE;
- if(c2 == 0xef && c1 == 0xbb && c0 == 0xbf)
- return 0;
- }
-
- if (c2 == 0) /* 0x00-0x7f */
- c1 &= 0x7F; /* 1byte */
- else if (c0 == 0){
- if ((c2 & 0xe0) == 0xc0){ /* 0xc0-0xdf */
- /* 2ytes */
- if((c2 & 0xFE) == 0xC0 || c1 < 0x80 || 0xBF < c1) return 0;
- }else if ((c2 & 0xf0) == 0xe0) /* 0xe0-0xef */
- return -1; /* 3bytes */
-#ifdef __COMMENT__
- else if (0xf0 <= c2)
- return 0; /* 4,5,6bytes */
- else if ((c2 & 0xc0) == 0x80) /* 0x80-0xbf */
- return 0; /* trail byte */
-#endif
- else return 0;
- }else{
- /* must be 3bytes */
- if(c2 == 0xE0){
- if(c1 < 0xA0 || 0xBF < c1 || c0 < 0x80 || 0xBF < c0)
+ if (c2 < 0 || 0xff < c2) {
+ }else if (c2 == 0) { /* 0 : 1 byte*/
+ c0 = 0;
+ } else if ((c2 & 0xc0) == 0x80) { /* 0x80-0xbf : trail byte */
+ return 0;
+ } else{
+ switch (w_iconv_utf8_1st_byte[c2 - 0xC0]) {
+ case 21:
+ if (c1 < 0x80 || 0xBF < c1) return 0;
+ break;
+ case 30:
+ if (c0 == 0) return -1;
+ if (c1 < 0xA0 || 0xBF < c1 || (c0 & 0xc0) != 0x80)
+ return 0;
+ break;
+ case 31:
+ case 33:
+ if (c0 == 0) return -1;
+ if ((c1 & 0xc0) != 0x80 || (c0 & 0xc0) != 0x80)
+ return 0;
+ break;
+ case 32:
+ if (c0 == 0) return -1;
+ if (c1 < 0x80 || 0x9F < c1 || (c0 & 0xc0) != 0x80)
+ return 0;
+ break;
+ case 40:
+ if (c0 == 0) return -2;
+ if (c1 < 0x90 || 0xBF < c1 || (c0 & 0xc0c0) != 0x8080)
return 0;
- }else if(c2 == 0xED){
- if(c1 < 0x80 || 0x9F < c1 || c0 < 0x80 || 0xBF < c0)
+ break;
+ case 41:
+ if (c0 == 0) return -2;
+ if (c1 < 0x80 || 0xBF < c1 || (c0 & 0xc0c0) != 0x8080)
return 0;
- }else if((c2 & 0xf0) == 0xe0){
- if(c1 < 0x80 || 0xBF < c1 || c0 < 0x80 || 0xBF < c0)
+ break;
+ case 42:
+ if (c0 == 0) return -2;
+ if (c1 < 0x80 || 0x8F < c1 || (c0 & 0xc0c0) != 0x8080)
return 0;
- }else return 0;
+ break;
+ default:
+ return 0;
+ break;
+ }
}
if (c2 == 0 || c2 == EOF){
+ } else if ((c2 & 0xf8) == 0xf0) { /* 4 bytes */
+ c1 = CLASS_UNICODE | ww16_conv(c2, c1, c0);
+ c2 = 0;
} else {
ret = w2e_conv(c2, c1, c0, &c2, &c1);
}
@@ -3075,6 +3380,10 @@ void w16w_conv(nkf_char val, nkf_char *p2, nkf_char *p1, nkf_char *p0)
*p2 = 0xe0 | (val >> 12);
*p1 = 0x80 | ((val >> 6) & 0x3f);
*p0 = 0x80 | (val & 0x3f);
+ } else if (val <= NKF_INT32_C(0x10FFFF)) {
+ *p2 = 0xe0 | (val >> 16);
+ *p1 = 0x80 | ((val >> 12) & 0x3f);
+ *p0 = 0x8080 | ((val << 2) & 0x3f00)| (val & 0x3f);
} else {
*p2 = 0;
*p1 = 0;
@@ -3087,8 +3396,14 @@ void w16w_conv(nkf_char val, nkf_char *p2, nkf_char *p1, nkf_char *p0)
nkf_char ww16_conv(nkf_char c2, nkf_char c1, nkf_char c0)
{
nkf_char val;
- if (c2 >= 0xf0){
+ if (c2 >= 0xf8) {
val = -1;
+ } else if (c2 >= 0xf0){
+ /* c2: 1st, c1: 2nd, c0: 3rd/4th */
+ val = (c2 & 0x0f) << 18;
+ val |= (c1 & 0x3f) << 12;
+ val |= (c0 & 0x3f00) >> 2;
+ val |= (c0 & 0x3f);
}else if (c2 >= 0xe0){
val = (c2 & 0x0f) << 12;
val |= (c1 & 0x3f) << 6;
@@ -3116,7 +3431,7 @@ nkf_char w16e_conv(nkf_char val, nkf_char *p2, nkf_char *p1)
#ifdef NUMCHAR_OPTION
if (ret > 0){
*p2 = 0;
- *p1 = CLASS_UTF16 | val;
+ *p1 = CLASS_UNICODE | val;
ret = 0;
}
#endif
@@ -3128,27 +3443,19 @@ nkf_char w16e_conv(nkf_char val, nkf_char *p2, nkf_char *p1)
#ifdef UTF8_INPUT_ENABLE
nkf_char w_iconv16(nkf_char c2, nkf_char c1, nkf_char c0)
{
- nkf_char ret;
-
- /* throw away ZERO WIDTH NO-BREAK SPACE (U+FEFF) */
- if(ignore_zwnbsp_f){
- ignore_zwnbsp_f = FALSE;
- if (c2==0376 && c1==0377){
- utf16_mode = UTF16BE_INPUT;
- return 0;
- }else if(c2==0377 && c1==0376){
- utf16_mode = UTF16LE_INPUT;
- return 0;
- }
- }
- if (c2 != EOF && utf16_mode == UTF16LE_INPUT) {
- nkf_char tmp;
- tmp=c1; c1=c2; c2=tmp;
- }
+ nkf_char ret = 0;
if ((c2==0 && c1 < 0x80) || c2==EOF) {
(*oconv)(c2, c1);
return 0;
- }else if((c2>>3)==27){ /* surrogate pair */
+ }else if (0xD8 <= c2 && c2 <= 0xDB) {
+ if (c0 < NKF_INT32_C(0xDC00) || NKF_INT32_C(0xDFFF) < c0)
+ return -2;
+ c1 = CLASS_UNICODE | ((c2 << 18) + (c1 << 10) + c0 - NKF_INT32_C(0x35FDC00));
+ c2 = 0;
+ }else if ((c2>>3) == 27) { /* unpaired surrogate */
+ /*
+ return 2;
+ */
return 1;
}else ret = w16e_conv(((c2 & 0xff)<<8) + c1, &c2, &c1);
if (ret) return ret;
@@ -3156,6 +3463,22 @@ nkf_char w_iconv16(nkf_char c2, nkf_char c1, nkf_char c0)
return 0;
}
+nkf_char w_iconv32(nkf_char c2, nkf_char c1, nkf_char c0)
+{
+ int ret = 0;
+
+ if ((c2 == 0 && c1 < 0x80) || c2==EOF) {
+ } else if (is_unicode_bmp(c1)) {
+ ret = w16e_conv(c1, &c2, &c1);
+ } else {
+ c2 = 0;
+ c1 = CLASS_UNICODE | c1;
+ }
+ if (ret) return ret;
+ (*oconv)(c2, c1);
+ return 0;
+}
+
nkf_char unicode_to_jis_common(nkf_char c2, nkf_char c1, nkf_char c0, nkf_char *p2, nkf_char *p1)
{
#if 0
@@ -3204,7 +3527,7 @@ nkf_char unicode_to_jis_common(nkf_char c2, nkf_char c1, nkf_char c0, nkf_char *
if(no_best_fit_chars_table_932_C3[c1&0x3F]) return 1;
break;
}
- }else if(cp51932_f){
+ }else if(!cp932inv_f){
switch(c2){
case 0xC2:
if(no_best_fit_chars_table_C2[c1&0x3F]) return 1;
@@ -3260,7 +3583,7 @@ nkf_char unicode_to_jis_common(nkf_char c2, nkf_char c1, nkf_char c0, nkf_char *
if(c0 == 0x8D) return 1;
break;
case 0xBD:
- if(c0 == 0x9E && cp51932_f) return 1;
+ if(c0 == 0x9E && !cp932inv_f) return 1;
break;
case 0xBF:
if(0xA0 <= c0 && c0 <= 0xA5) return 1;
@@ -3277,7 +3600,7 @@ nkf_char unicode_to_jis_common(nkf_char c2, nkf_char c1, nkf_char c0, nkf_char *
ret = w_iconv_common(c1, c0, ppp[c2 - 0xE0], sizeof_utf8_to_euc_C2, p2, p1);
}else return -1;
#ifdef SHIFTJIS_CP932
- if (!ret && cp51932_f && is_eucg3(*p2)) {
+ if (!ret && !cp932inv_f && is_eucg3(*p2)) {
nkf_char s2, s1;
if (e2s_conv(*p2, *p1, &s2, &s1) == 0) {
s2e_conv(s2, s1, p2, p1);
@@ -3456,16 +3779,17 @@ void w_oconv(nkf_char c2, nkf_char c1)
{
nkf_char c0;
nkf_char val;
- if (c2 == EOF) {
- (*o_putc)(EOF);
- return;
- }
- if (unicode_bom_f==2) {
- (*o_putc)('\357');
+ if (output_bom_f) {
+ output_bom_f = FALSE;
+ (*o_putc)('\357');
(*o_putc)('\273');
(*o_putc)('\277');
- unicode_bom_f=1;
+ }
+
+ if (c2 == EOF) {
+ (*o_putc)(EOF);
+ return;
}
#ifdef NUMCHAR_OPTION
@@ -3481,7 +3805,7 @@ void w_oconv(nkf_char c2, nkf_char c1)
(*o_putc)(0x80 | ((val >> 6) & 0x3f));
(*o_putc)(0x80 | (val & 0x3f));
} else if (val <= NKF_INT32_C(0x10FFFF)) {
- (*o_putc)(0xE0 | ( val>>18));
+ (*o_putc)(0xF0 | ( val>>18));
(*o_putc)(0x80 | ((val>>12) & 0x3f));
(*o_putc)(0x80 | ((val>> 6) & 0x3f));
(*o_putc)(0x80 | ( val & 0x3f));
@@ -3512,20 +3836,20 @@ void w_oconv(nkf_char c2, nkf_char c1)
void w_oconv16(nkf_char c2, nkf_char c1)
{
- if (c2 == EOF) {
- (*o_putc)(EOF);
- return;
- }
-
- if (unicode_bom_f==2) {
- if (w_oconv16_LE){
+ if (output_bom_f) {
+ output_bom_f = FALSE;
+ if (output_endian == ENDIAN_LITTLE){
(*o_putc)((unsigned char)'\377');
(*o_putc)('\376');
}else{
(*o_putc)('\376');
(*o_putc)((unsigned char)'\377');
}
- unicode_bom_f=1;
+ }
+
+ if (c2 == EOF) {
+ (*o_putc)(EOF);
+ return;
}
if (c2 == ISO8859_1) {
@@ -3541,7 +3865,7 @@ void w_oconv16(nkf_char c2, nkf_char c1)
if (c1 <= UNICODE_MAX) {
c2 = (c1 >> 10) + NKF_INT32_C(0xD7C0); /* high surrogate */
c1 = (c1 & 0x3FF) + NKF_INT32_C(0xDC00); /* low surrogate */
- if (w_oconv16_LE){
+ if (output_endian == ENDIAN_LITTLE){
(*o_putc)(c2 & 0xff);
(*o_putc)((c2 >> 8) & 0xff);
(*o_putc)(c1 & 0xff);
@@ -3560,8 +3884,9 @@ void w_oconv16(nkf_char c2, nkf_char c1)
nkf_char val = e2w_conv(c2, c1);
c2 = (val >> 8) & 0xff;
c1 = val & 0xff;
+ if (!val) return;
}
- if (w_oconv16_LE){
+ if (output_endian == ENDIAN_LITTLE){
(*o_putc)(c1);
(*o_putc)(c2);
}else{
@@ -3570,6 +3895,50 @@ void w_oconv16(nkf_char c2, nkf_char c1)
}
}
+void w_oconv32(nkf_char c2, nkf_char c1)
+{
+ if (output_bom_f) {
+ output_bom_f = FALSE;
+ if (output_endian == ENDIAN_LITTLE){
+ (*o_putc)((unsigned char)'\377');
+ (*o_putc)('\376');
+ (*o_putc)('\000');
+ (*o_putc)('\000');
+ }else{
+ (*o_putc)('\000');
+ (*o_putc)('\000');
+ (*o_putc)('\376');
+ (*o_putc)((unsigned char)'\377');
+ }
+ }
+
+ if (c2 == EOF) {
+ (*o_putc)(EOF);
+ return;
+ }
+
+ if (c2 == ISO8859_1) {
+ c1 |= 0x80;
+#ifdef NUMCHAR_OPTION
+ } else if (c2 == 0 && is_unicode_capsule(c1)) {
+ c1 &= VALUE_MASK;
+#endif
+ } else if (c2) {
+ c1 = e2w_conv(c2, c1);
+ if (!c1) return;
+ }
+ if (output_endian == ENDIAN_LITTLE){
+ (*o_putc)( c1 & NKF_INT32_C(0x000000FF));
+ (*o_putc)((c1 & NKF_INT32_C(0x0000FF00)) >> 8);
+ (*o_putc)((c1 & NKF_INT32_C(0x00FF0000)) >> 16);
+ (*o_putc)('\000');
+ }else{
+ (*o_putc)('\000');
+ (*o_putc)((c1 & NKF_INT32_C(0x00FF0000)) >> 16);
+ (*o_putc)((c1 & NKF_INT32_C(0x0000FF00)) >> 8);
+ (*o_putc)( c1 & NKF_INT32_C(0x000000FF));
+ }
+}
#endif
void e_oconv(nkf_char c2, nkf_char c1)
@@ -3578,8 +3947,26 @@ void e_oconv(nkf_char c2, nkf_char c1)
if (c2 == 0 && is_unicode_capsule(c1)){
w16e_conv(c1, &c2, &c1);
if (c2 == 0 && is_unicode_capsule(c1)){
- if(encode_fallback)(*encode_fallback)(c1);
- return;
+ c2 = c1 & VALUE_MASK;
+ if (x0212_f && 0xE000 <= c2 && c2 <= 0xE757) {
+ /* eucJP-ms UDC */
+ c1 &= 0xFFF;
+ c2 = c1 / 94;
+ c2 += c2 < 10 ? 0x75 : 0x8FEB;
+ c1 = 0x21 + c1 % 94;
+ if (is_eucg3(c2)){
+ (*o_putc)(0x8f);
+ (*o_putc)((c2 & 0x7f) | 0x080);
+ (*o_putc)(c1 | 0x080);
+ }else{
+ (*o_putc)((c2 & 0x7f) | 0x080);
+ (*o_putc)(c1 | 0x080);
+ }
+ return;
+ } else {
+ if (encode_fallback) (*encode_fallback)(c1);
+ return;
+ }
}
}
#endif
@@ -3599,7 +3986,7 @@ void e_oconv(nkf_char c2, nkf_char c1)
} else if (is_eucg3(c2)){
output_mode = JAPANESE_EUC;
#ifdef SHIFTJIS_CP932
- if (cp51932_f){
+ if (!cp932inv_f){
nkf_char s2, s1;
if (e2s_conv(c2, c1, &s2, &s1) == 0){
s2e_conv(s2, s1, &c2, &c1);
@@ -3665,7 +4052,7 @@ nkf_char e2s_conv(nkf_char c2, nkf_char c1, nkf_char *p2, nkf_char *p1)
{
nkf_char ndx;
if (is_eucg3(c2)){
- ndx = c2 & 0xff;
+ ndx = c2 & 0x7f;
if (x0213_f){
if((0x21 <= ndx && ndx <= 0x2F)){
if (p2) *p2 = ((ndx - 1) >> 1) + 0xec - ndx / 8 * 3;
@@ -3712,9 +4099,21 @@ void s_oconv(nkf_char c2, nkf_char c1)
if (c2 == 0 && is_unicode_capsule(c1)){
w16e_conv(c1, &c2, &c1);
if (c2 == 0 && is_unicode_capsule(c1)){
- if(encode_fallback)(*encode_fallback)(c1);
- return;
- }
+ c2 = c1 & VALUE_MASK;
+ if (!x0213_f && 0xE000 <= c2 && c2 <= 0xE757) {
+ /* CP932 UDC */
+ c1 &= 0xFFF;
+ c2 = c1 / 188 + 0xF0;
+ c1 = c1 % 188;
+ c1 += 0x40 + (c1 > 0x3e);
+ (*o_putc)(c2);
+ (*o_putc)(c1);
+ return;
+ } else {
+ if(encode_fallback)(*encode_fallback)(c1);
+ return;
+ }
+ }
}
#endif
if (c2 == EOF) {
@@ -3773,8 +4172,16 @@ void j_oconv(nkf_char c2, nkf_char c1)
if (c2 == 0 && is_unicode_capsule(c1)){
w16e_conv(c1, &c2, &c1);
if (c2 == 0 && is_unicode_capsule(c1)){
- if(encode_fallback)(*encode_fallback)(c1);
- return;
+ c2 = c1 & VALUE_MASK;
+ if (ms_ucs_map_f && 0xE000 <= c2 && c2 <= 0xE757) {
+ /* CP5022x UDC */
+ c1 &= 0xFFF;
+ c2 = 0x7F + c1 / 94;
+ c1 = 0x21 + c1 % 94;
+ } else {
+ if (encode_fallback) (*encode_fallback)(c1);
+ return;
+ }
}
}
#endif
@@ -3831,7 +4238,9 @@ void j_oconv(nkf_char c2, nkf_char c1)
}
(*o_putc)(c1);
} else {
- if(c2<0x20 || 0x7e<c2 || c1<0x20 || 0x7e<c1) return;
+ if(ms_ucs_map_f
+ ? c2<0x20 || 0x92<c2 || c1<0x20 || 0x7e<c1
+ : c2<0x20 || 0x7e<c2 || c1<0x20 || 0x7e<c1) return;
if(x0213_f){
if (output_mode!=X0213_1) {
output_mode = X0213_1;
@@ -4235,7 +4644,7 @@ void hira_conv(nkf_char c2, nkf_char c1)
return;
} else if (c1 == 0x74 && (output_conv == w_oconv || output_conv == w_oconv16)) {
c2 = 0;
- c1 = CLASS_UTF16 | 0x3094;
+ c1 = CLASS_UNICODE | 0x3094;
(*o_hira_conv)(c2,c1);
return;
}
@@ -4246,7 +4655,7 @@ void hira_conv(nkf_char c2, nkf_char c1)
}
}
if (hira_f & 2) {
- if (c2 == 0 && c1 == (CLASS_UTF16 | 0x3094)) {
+ if (c2 == 0 && c1 == (CLASS_UNICODE | 0x3094)) {
c2 = 0x25;
c1 = 0x74;
} else if (c2 == 0x24 && 0x20 < c1 && c1 < 0x74) {
@@ -4634,7 +5043,7 @@ nkf_char numchar_getc(FILE *f)
}
}
if (c != -1){
- return CLASS_UTF16 | c;
+ return CLASS_UNICODE | c;
}
while (i > 0){
(*u)(buf[i], f);
@@ -5409,14 +5818,14 @@ void reinit(void)
#endif
#ifdef UTF8_INPUT_ENABLE
no_cp932ext_f = FALSE;
- ignore_zwnbsp_f = TRUE;
no_best_fit_chars_f = FALSE;
encode_fallback = NULL;
unicode_subchar = '?';
+ input_endian = ENDIAN_BIG;
#endif
#ifdef UTF8_OUTPUT_ENABLE
- unicode_bom_f = 0;
- w_oconv16_LE = 0;
+ output_bom_f = FALSE;
+ output_endian = ENDIAN_BIG;
#endif
#ifdef UNICODE_NORMALIZATION
nfc_f = FALSE;
@@ -5450,9 +5859,7 @@ void reinit(void)
prefix_table[i] = 0;
}
}
-#ifdef UTF8_INPUT_ENABLE
- utf16_mode = UTF16BE_INPUT;
-#endif
+ hold_count = 0;
mimeout_buf_count = 0;
mimeout_mode = 0;
base64_count = 0;
@@ -5525,16 +5932,16 @@ void usage(void)
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), EUC-JP, UTF-8N\n");
+ fprintf(stderr,"j,s,e,w Output code is JIS 7 bit, Shift_JIS (DEFAULT), EUC-JP, UTF-8N\n");
#endif
#ifdef DEFAULT_CODE_JIS
- fprintf(stderr,"j,s,e,w Outout code is JIS 7 bit (DEFAULT), Shift JIS, EUC-JP, UTF-8N\n");
+ fprintf(stderr,"j,s,e,w Output code is JIS 7 bit (DEFAULT), Shift JIS, EUC-JP, UTF-8N\n");
#endif
#ifdef DEFAULT_CODE_EUC
- fprintf(stderr,"j,s,e,w Outout code is JIS 7 bit, Shift JIS, EUC-JP (DEFAULT), UTF-8N\n");
+ fprintf(stderr,"j,s,e,w Output code is JIS 7 bit, Shift JIS, EUC-JP (DEFAULT), UTF-8N\n");
#endif
#ifdef DEFAULT_CODE_UTF8
- fprintf(stderr,"j,s,e,w Outout code is JIS 7 bit, Shift JIS, EUC-JP, UTF-8N (DEFAULT)\n");
+ fprintf(stderr,"j,s,e,w Output code is JIS 7 bit, Shift JIS, EUC-JP, UTF-8N (DEFAULT)\n");
#endif
#ifdef UTF8_OUTPUT_ENABLE
fprintf(stderr," After 'w' you can add more options. -w[ 8 [0], 16 [[BL] [0]] ]\n");
diff --git a/ext/nkf/nkf-utf8/utf8tbl.c b/ext/nkf/nkf-utf8/utf8tbl.c
index 9e59956a0a..e43ad553d6 100644
--- a/ext/nkf/nkf-utf8/utf8tbl.c
+++ b/ext/nkf/nkf-utf8/utf8tbl.c
@@ -7544,7 +7544,7 @@ const unsigned short cp932inv[2][189] = {
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,
+ 0xFA49, 0x81CA, 0xFA55, 0xFA56, 0xFA57,
},
};
#endif /* SHIFTJIS_CP932 */
diff --git a/ext/nkf/nkf.c b/ext/nkf/nkf.c
index 8bcb6d15f7..2bb0340a64 100644
--- a/ext/nkf/nkf.c
+++ b/ext/nkf/nkf.c
@@ -3,11 +3,11 @@
*
* original nkf2.x is maintained at http://sourceforge.jp/projects/nkf/
*
- * $Id: nkf.c,v 1.9.2.4 2006/03/27 13:28:14 naruse Exp $
+ * $Id$
*
*/
-#define RUBY_NKF_REVISION "$Revision: 1.9.2.4 $"
+#define RUBY_NKF_REVISION "$Revision$"
#define RUBY_NKF_VERSION NKF_VERSION " (" NKF_RELEASE_DATE ")"
#include "ruby.h"
@@ -63,7 +63,7 @@ rb_nkf_putchar(c)
o_len += incsize;
rb_str_resize(result, o_len);
incsize *= 2;
- output = RSTRING(result)->ptr;
+ output = (unsigned char *)RSTRING(result)->ptr;
}
output[output_ctr++] = c;
@@ -158,13 +158,13 @@ rb_nkf_kconv(obj, opt, src)
input_ctr = 0;
StringValue(src);
- input = RSTRING(src)->ptr;
+ input = (unsigned char *)RSTRING(src)->ptr;
i_len = RSTRING(src)->len;
result = rb_str_new(0, i_len*3 + 10);
v = result;
output_ctr = 0;
- output = RSTRING(result)->ptr;
+ output = (unsigned char *)RSTRING(result)->ptr;
o_len = RSTRING(result)->len;
*output = '\0';
@@ -213,7 +213,7 @@ rb_nkf_guess1(obj, src)
int sequence_counter = 0;
StringValue(src);
- p = RSTRING(src)->ptr;
+ p = (unsigned char *)RSTRING(src)->ptr;
pend = p + RSTRING(src)->len;
if (p == pend) return INT2FIX(_UNKNOWN);
@@ -328,7 +328,7 @@ rb_nkf_guess2(obj, src)
input_ctr = 0;
StringValue(src);
- input = RSTRING(src)->ptr;
+ input = (unsigned char *)RSTRING(src)->ptr;
i_len = RSTRING(src)->len;
if(x0201_f == WISH_TRUE)
diff --git a/ext/openssl/extconf.rb b/ext/openssl/extconf.rb
index b2c5ca5ef8..98921bc468 100644
--- a/ext/openssl/extconf.rb
+++ b/ext/openssl/extconf.rb
@@ -1,5 +1,5 @@
=begin
-= $RCSfile: extconf.rb,v $ -- Generator for Makefile
+= $RCSfile$ -- Generator for Makefile
= Info
'OpenSSL for Ruby 2' project
@@ -11,7 +11,7 @@
(See the file 'LICENCE'.)
= Version
- $Id: extconf.rb,v 1.21.2.9 2006/06/20 11:18:15 gotoyuzo Exp $
+ $Id$
=end
require "mkmf"
@@ -36,8 +36,6 @@ 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"
diff --git a/ext/openssl/lib/net/ftptls.rb b/ext/openssl/lib/net/ftptls.rb
index e82eff72fa..f433457923 100644
--- a/ext/openssl/lib/net/ftptls.rb
+++ b/ext/openssl/lib/net/ftptls.rb
@@ -1,5 +1,5 @@
=begin
-= $RCSfile: ftptls.rb,v $ -- SSL/TLS enhancement for Net::HTTP.
+= $RCSfile$ -- SSL/TLS enhancement for Net::HTTP.
= Info
'OpenSSL for Ruby 2' project
@@ -13,7 +13,7 @@
= Requirements
= Version
- $Id: ftptls.rb,v 1.1 2003/07/23 16:11:30 gotoyuzo Exp $
+ $Id$
= Notes
Tested on FreeBSD 5-CURRENT and 4-STABLE
@@ -29,23 +29,13 @@ require 'net/ftp'
module Net
class FTPTLS < FTP
- def connect(host, port=FTP_PORT)
- @hostname = host
- super
- end
-
def login(user = "anonymous", passwd = nil, acct = nil)
- store = OpenSSL::X509::Store.new
- store.set_default_paths
ctx = OpenSSL::SSL::SSLContext.new('SSLv23')
- ctx.cert_store = store
- ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER
ctx.key = nil
ctx.cert = nil
voidcmd("AUTH TLS")
@sock = OpenSSL::SSL::SSLSocket.new(@sock, ctx)
@sock.connect
- @sock.post_connection_check(@hostname)
super(user, passwd, acct)
voidcmd("PBSZ 0")
end
diff --git a/ext/openssl/lib/net/telnets.rb b/ext/openssl/lib/net/telnets.rb
index c869b5da1c..a872f41e6a 100644
--- a/ext/openssl/lib/net/telnets.rb
+++ b/ext/openssl/lib/net/telnets.rb
@@ -1,5 +1,5 @@
=begin
-= $RCSfile: telnets.rb,v $ -- SSL/TLS enhancement for Net::Telnet.
+= $RCSfile$ -- SSL/TLS enhancement for Net::Telnet.
= Info
'OpenSSL for Ruby 2' project
@@ -11,7 +11,7 @@
(See the file 'LICENCE'.)
= Version
- $Id: telnets.rb,v 1.1.2.1 2004/12/20 03:49:16 gotoyuzo Exp $
+ $Id$
2001/11/06: Contiributed to Ruby/OpenSSL project.
@@ -134,9 +134,6 @@ module Net
@sock.verify_callback = @options['VerifyCallback']
@sock.verify_depth = @options['VerifyDepth']
@sock.connect
- if @options['VerifyMode'] != OpenSSL::SSL::VERIFY_NONE
- @sock.post_connection_check(@options['Host'])
- end
@ssl = true
end
''
diff --git a/ext/openssl/lib/openssl.rb b/ext/openssl/lib/openssl.rb
index 58fd3887e3..24a9eed136 100644
--- a/ext/openssl/lib/openssl.rb
+++ b/ext/openssl/lib/openssl.rb
@@ -1,5 +1,5 @@
=begin
-= $RCSfile: openssl.rb,v $ -- Loader for all OpenSSL C-space and Ruby-space definitions
+= $RCSfile$ -- Loader for all OpenSSL C-space and Ruby-space definitions
= Info
'OpenSSL for Ruby 2' project
@@ -11,7 +11,7 @@
(See the file 'LICENCE'.)
= Version
- $Id: openssl.rb,v 1.1 2003/07/23 16:11:29 gotoyuzo Exp $
+ $Id$
=end
require 'openssl.so'
diff --git a/ext/openssl/lib/openssl/bn.rb b/ext/openssl/lib/openssl/bn.rb
index 4a1595c7ab..e7cbf2cfaf 100644
--- a/ext/openssl/lib/openssl/bn.rb
+++ b/ext/openssl/lib/openssl/bn.rb
@@ -1,5 +1,5 @@
=begin
-= $RCSfile: bn.rb,v $ -- Ruby-space definitions that completes C-space funcs for BN
+= $RCSfile$ -- Ruby-space definitions that completes C-space funcs for BN
= Info
'OpenSSL for Ruby 2' project
@@ -11,7 +11,7 @@
(See the file 'LICENCE'.)
= Version
- $Id: bn.rb,v 1.1 2003/07/23 16:11:30 gotoyuzo Exp $
+ $Id$
=end
##
diff --git a/ext/openssl/lib/openssl/buffering.rb b/ext/openssl/lib/openssl/buffering.rb
index 9eeb19d959..761a017487 100644
--- a/ext/openssl/lib/openssl/buffering.rb
+++ b/ext/openssl/lib/openssl/buffering.rb
@@ -1,5 +1,5 @@
=begin
-= $RCSfile: buffering.rb,v $ -- Buffering mix-in module.
+= $RCSfile$ -- Buffering mix-in module.
= Info
'OpenSSL for Ruby 2' project
@@ -11,7 +11,7 @@
(See the file 'LICENCE'.)
= Version
- $Id: buffering.rb,v 1.5.2.4 2005/09/04 22:03:24 gotoyuzo Exp $
+ $Id$
=end
module Buffering
diff --git a/ext/openssl/lib/openssl/cipher.rb b/ext/openssl/lib/openssl/cipher.rb
index 7825e5e9e6..049533d06b 100644
--- a/ext/openssl/lib/openssl/cipher.rb
+++ b/ext/openssl/lib/openssl/cipher.rb
@@ -1,5 +1,5 @@
=begin
-= $RCSfile: cipher.rb,v $ -- Ruby-space predefined Cipher subclasses
+= $RCSfile$ -- Ruby-space predefined Cipher subclasses
= Info
'OpenSSL for Ruby 2' project
@@ -11,7 +11,7 @@
(See the file 'LICENCE'.)
= Version
- $Id: cipher.rb,v 1.1.2.2 2006/06/20 11:18:15 gotoyuzo Exp $
+ $Id$
=end
##
diff --git a/ext/openssl/lib/openssl/digest.rb b/ext/openssl/lib/openssl/digest.rb
index 6f2c998ff6..b3e4484805 100644
--- a/ext/openssl/lib/openssl/digest.rb
+++ b/ext/openssl/lib/openssl/digest.rb
@@ -1,5 +1,5 @@
=begin
-= $RCSfile: digest.rb,v $ -- Ruby-space predefined Digest subclasses
+= $RCSfile$ -- Ruby-space predefined Digest subclasses
= Info
'OpenSSL for Ruby 2' project
@@ -11,7 +11,7 @@
(See the file 'LICENCE'.)
= Version
- $Id: digest.rb,v 1.1.2.2 2006/06/20 11:18:15 gotoyuzo Exp $
+ $Id$
=end
##
diff --git a/ext/openssl/lib/openssl/ssl.rb b/ext/openssl/lib/openssl/ssl.rb
index d1007ce6d0..ef7415f478 100644
--- a/ext/openssl/lib/openssl/ssl.rb
+++ b/ext/openssl/lib/openssl/ssl.rb
@@ -1,5 +1,5 @@
=begin
-= $RCSfile: ssl.rb,v $ -- Ruby-space definitions that completes C-space funcs for SSL
+= $RCSfile$ -- Ruby-space definitions that completes C-space funcs for SSL
= Info
'OpenSSL for Ruby 2' project
@@ -11,7 +11,7 @@
(See the file 'LICENCE'.)
= Version
- $Id: ssl.rb,v 1.5.2.6 2006/05/23 18:14:05 gotoyuzo Exp $
+ $Id$
=end
require "openssl"
@@ -88,7 +88,7 @@ module OpenSSL
end
}
end
- raise SSLError, "hostname was not match with the server certificate"
+ raise SSLError, "hostname not match"
end
end
diff --git a/ext/openssl/lib/openssl/x509.rb b/ext/openssl/lib/openssl/x509.rb
index 2ad3f8e96e..e711bda39c 100644
--- a/ext/openssl/lib/openssl/x509.rb
+++ b/ext/openssl/lib/openssl/x509.rb
@@ -1,5 +1,5 @@
=begin
-= $RCSfile: x509.rb,v $ -- Ruby-space definitions that completes C-space funcs for X509 and subclasses
+= $RCSfile$ -- Ruby-space definitions that completes C-space funcs for X509 and subclasses
= Info
'OpenSSL for Ruby 2' project
@@ -11,7 +11,7 @@
(See the file 'LICENCE'.)
= Version
- $Id: x509.rb,v 1.4.2.2 2004/12/19 08:28:33 gotoyuzo Exp $
+ $Id$
=end
require "openssl"
diff --git a/ext/openssl/openssl_missing.c b/ext/openssl/openssl_missing.c
index 2c005f41e5..f77731ed65 100644
--- a/ext/openssl/openssl_missing.c
+++ b/ext/openssl/openssl_missing.c
@@ -1,5 +1,5 @@
/*
- * $Id: openssl_missing.c,v 1.2.2.4 2006/06/02 10:02:56 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
diff --git a/ext/openssl/openssl_missing.h b/ext/openssl/openssl_missing.h
index 8d580f5ee8..e8c75ca42c 100644
--- a/ext/openssl/openssl_missing.h
+++ b/ext/openssl/openssl_missing.h
@@ -1,5 +1,5 @@
/*
- * $Id: openssl_missing.h,v 1.2.2.2 2005/04/15 19:16:18 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
diff --git a/ext/openssl/ossl.c b/ext/openssl/ossl.c
index 01c5ca2a04..a98f2641cc 100644
--- a/ext/openssl/ossl.c
+++ b/ext/openssl/ossl.c
@@ -1,5 +1,5 @@
/*
- * $Id: ossl.c,v 1.11.2.6 2005/11/01 01:52:13 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
diff --git a/ext/openssl/ossl.h b/ext/openssl/ossl.h
index 336b468eb2..c0325229c1 100644
--- a/ext/openssl/ossl.h
+++ b/ext/openssl/ossl.h
@@ -1,5 +1,5 @@
/*
- * $Id: ossl.h,v 1.14.2.4.2.1 2006/12/25 11:16:49 shyouhei Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -18,10 +18,13 @@ extern "C" {
#endif
/*
- *_FILE_OFFSET_BITS needs to be defined before some system headers on
- * Solaris.
- */
-#include "config.h"
+* 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>
/*
* Check the OpenSSL version
@@ -66,15 +69,6 @@ extern "C" {
#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;
@@ -208,7 +202,6 @@ void ossl_debug(const char *, ...);
#include "ossl_ocsp.h"
#include "ossl_pkcs12.h"
#include "ossl_pkcs7.h"
-#include "ossl_pkcs5.h"
#include "ossl_pkey.h"
#include "ossl_rand.h"
#include "ossl_ssl.h"
diff --git a/ext/openssl/ossl_asn1.c b/ext/openssl/ossl_asn1.c
index 6bc5b88e8f..3614f470d9 100644
--- a/ext/openssl/ossl_asn1.c
+++ b/ext/openssl/ossl_asn1.c
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_asn1.c,v 1.5.2.9 2006/04/29 13:52:15 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' team members
* Copyright (C) 2003
* All rights reserved.
@@ -1087,6 +1087,10 @@ Init_ossl_asn1()
VALUE ary;
int i;
+#if 0 /* let rdoc know about mOSSL */
+ mOSSL = rb_define_module("OpenSSL");
+#endif
+
sUNIVERSAL = rb_intern("UNIVERSAL");
sCONTEXT_SPECIFIC = rb_intern("CONTEXT_SPECIFIC");
sAPPLICATION = rb_intern("APPLICATION");
diff --git a/ext/openssl/ossl_asn1.h b/ext/openssl/ossl_asn1.h
index 6a1c97b902..8aad9f970d 100644
--- a/ext/openssl/ossl_asn1.h
+++ b/ext/openssl/ossl_asn1.h
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_asn1.h,v 1.3.2.1 2005/09/10 01:17:00 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' team members
* Copyright (C) 2003
* All rights reserved.
diff --git a/ext/openssl/ossl_bio.c b/ext/openssl/ossl_bio.c
index 4e3248eb1d..9c9aa24197 100644
--- a/ext/openssl/ossl_bio.c
+++ b/ext/openssl/ossl_bio.c
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_bio.c,v 1.2.2.1 2005/06/19 16:29:17 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' team members
* Copyright (C) 2003
* All rights reserved.
diff --git a/ext/openssl/ossl_bio.h b/ext/openssl/ossl_bio.h
index ca312679fa..2d8f675c5b 100644
--- a/ext/openssl/ossl_bio.h
+++ b/ext/openssl/ossl_bio.h
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_bio.h,v 1.2 2003/09/17 09:05:01 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' team members
* Copyright (C) 2003
* All rights reserved.
diff --git a/ext/openssl/ossl_bn.c b/ext/openssl/ossl_bn.c
index fb86c8721c..cc7689eef5 100644
--- a/ext/openssl/ossl_bn.c
+++ b/ext/openssl/ossl_bn.c
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_bn.c,v 1.5.2.1 2004/12/15 01:54:39 matz Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Technorama team <oss-ruby@technorama.net>
* All rights reserved.
@@ -600,6 +600,10 @@ ossl_bn_is_prime_fasttest(int argc, VALUE *argv, VALUE self)
void
Init_ossl_bn()
{
+#if 0 /* let rdoc know about mOSSL */
+ mOSSL = rb_define_module("OpenSSL");
+#endif
+
if (!(ossl_bn_ctx = BN_CTX_new())) {
ossl_raise(rb_eRuntimeError, "Cannot init BN_CTX");
}
diff --git a/ext/openssl/ossl_bn.h b/ext/openssl/ossl_bn.h
index bccdbc0cd6..12aa484873 100644
--- a/ext/openssl/ossl_bn.h
+++ b/ext/openssl/ossl_bn.h
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_bn.h,v 1.1 2003/07/23 16:11:29 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
diff --git a/ext/openssl/ossl_cipher.c b/ext/openssl/ossl_cipher.c
index 8d96d0b35a..57b7976617 100644
--- a/ext/openssl/ossl_cipher.c
+++ b/ext/openssl/ossl_cipher.c
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_cipher.c,v 1.4.2.6 2006/06/20 11:18:15 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -380,6 +380,10 @@ CIPHER_0ARG_INT(block_size)
void
Init_ossl_cipher(void)
{
+#if 0 /* let rdoc know about mOSSL */
+ mOSSL = rb_define_module("OpenSSL");
+#endif
+
mCipher = rb_define_module_under(mOSSL, "Cipher");
eCipherError = rb_define_class_under(mOSSL, "CipherError", eOSSLError);
cCipher = rb_define_class_under(mCipher, "Cipher", rb_cObject);
diff --git a/ext/openssl/ossl_cipher.h b/ext/openssl/ossl_cipher.h
index 870927c37c..63c7a875e8 100644
--- a/ext/openssl/ossl_cipher.h
+++ b/ext/openssl/ossl_cipher.h
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_cipher.h,v 1.2 2003/09/05 09:08:40 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
diff --git a/ext/openssl/ossl_config.c b/ext/openssl/ossl_config.c
index 64998bb86a..ef89fdfe0d 100644
--- a/ext/openssl/ossl_config.c
+++ b/ext/openssl/ossl_config.c
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_config.c,v 1.8.2.3 2004/12/15 01:54:39 matz Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -245,10 +245,7 @@ set_conf_section_i(VALUE i, VALUE *arg)
static VALUE
ossl_config_set_section(VALUE self, VALUE section, VALUE hash)
{
- VALUE arg[2];
-
- arg[0] = self;
- arg[1] = section;
+ VALUE arg[2] = { self, section };
rb_iterate(rb_each, hash, set_conf_section_i, (VALUE)arg);
return hash;
}
diff --git a/ext/openssl/ossl_config.h b/ext/openssl/ossl_config.h
index 452d430b5e..cb226b27e5 100644
--- a/ext/openssl/ossl_config.h
+++ b/ext/openssl/ossl_config.h
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_config.h,v 1.2 2003/09/08 10:31:38 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
diff --git a/ext/openssl/ossl_digest.c b/ext/openssl/ossl_digest.c
index 8b9c273f4d..4096b097a2 100644
--- a/ext/openssl/ossl_digest.c
+++ b/ext/openssl/ossl_digest.c
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_digest.c,v 1.4.2.2 2004/12/15 01:54:39 matz Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -264,6 +264,10 @@ ossl_digest_size(VALUE self)
void
Init_ossl_digest()
{
+#if 0 /* let rdoc know about mOSSL */
+ mOSSL = rb_define_module("OpenSSL");
+#endif
+
mDigest = rb_define_module_under(mOSSL, "Digest");
eDigestError = rb_define_class_under(mDigest, "DigestError", eOSSLError);
diff --git a/ext/openssl/ossl_digest.h b/ext/openssl/ossl_digest.h
index b35bd217b3..8a1f7964f2 100644
--- a/ext/openssl/ossl_digest.h
+++ b/ext/openssl/ossl_digest.h
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_digest.h,v 1.2 2003/09/05 09:08:40 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
diff --git a/ext/openssl/ossl_engine.c b/ext/openssl/ossl_engine.c
index 6cc0183c0e..71586e3620 100644
--- a/ext/openssl/ossl_engine.c
+++ b/ext/openssl/ossl_engine.c
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_engine.c,v 1.4.2.6 2005/09/18 22:56:11 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
* All rights reserved.
diff --git a/ext/openssl/ossl_engine.h b/ext/openssl/ossl_engine.h
index ccc426481a..ea2f256912 100644
--- a/ext/openssl/ossl_engine.h
+++ b/ext/openssl/ossl_engine.h
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_engine.h,v 1.1 2003/10/02 08:47:11 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2003 Michal Rokos <m.rokos@sh.cvut.cz>
* Copyright (C) 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
diff --git a/ext/openssl/ossl_hmac.c b/ext/openssl/ossl_hmac.c
index cd66ab6e2c..312343e03d 100644
--- a/ext/openssl/ossl_hmac.c
+++ b/ext/openssl/ossl_hmac.c
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_hmac.c,v 1.4.2.2 2004/12/15 01:54:39 matz Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -191,6 +191,10 @@ ossl_hmac_s_hexdigest(VALUE klass, VALUE digest, VALUE key, VALUE data)
void
Init_ossl_hmac()
{
+#if 0 /* let rdoc know about mOSSL */
+ mOSSL = rb_define_module("OpenSSL");
+#endif
+
eHMACError = rb_define_class_under(mOSSL, "HMACError", eOSSLError);
cHMAC = rb_define_class_under(mOSSL, "HMAC", rb_cObject);
diff --git a/ext/openssl/ossl_hmac.h b/ext/openssl/ossl_hmac.h
index 2c8d69c177..1a2978b39a 100644
--- a/ext/openssl/ossl_hmac.h
+++ b/ext/openssl/ossl_hmac.h
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_hmac.h,v 1.1 2003/07/23 16:11:29 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
diff --git a/ext/openssl/ossl_ns_spki.c b/ext/openssl/ossl_ns_spki.c
index bd8c59faf9..66e28374cc 100644
--- a/ext/openssl/ossl_ns_spki.c
+++ b/ext/openssl/ossl_ns_spki.c
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_ns_spki.c,v 1.3.2.5 2006/03/17 10:10:53 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -70,6 +70,7 @@ ossl_spki_initialize(int argc, VALUE *argv, VALUE self)
}
NETSCAPE_SPKI_free(DATA_PTR(self));
DATA_PTR(self) = spki;
+ ERR_clear_error();
return self;
}
diff --git a/ext/openssl/ossl_ns_spki.h b/ext/openssl/ossl_ns_spki.h
index 2ca1fdcd62..9977035a9c 100644
--- a/ext/openssl/ossl_ns_spki.h
+++ b/ext/openssl/ossl_ns_spki.h
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_ns_spki.h,v 1.1 2003/07/23 16:11:29 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
diff --git a/ext/openssl/ossl_ocsp.c b/ext/openssl/ossl_ocsp.c
index f2097b967e..b5ea9dadf5 100644
--- a/ext/openssl/ossl_ocsp.c
+++ b/ext/openssl/ossl_ocsp.c
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_ocsp.c,v 1.4.2.2 2005/01/22 20:28:02 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2003 Michal Rokos <m.rokos@sh.cvut.cz>
* Copyright (C) 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
@@ -681,7 +681,7 @@ Init_ossl_ocsp()
{
mOCSP = rb_define_module_under(mOSSL, "OCSP");
- eOCSPError = rb_define_class_under(mOCSP, "OCSPError", rb_cObject);
+ eOCSPError = rb_define_class_under(mOCSP, "OCSPError", eOSSLError);
cOCSPReq = rb_define_class_under(mOCSP, "Request", rb_cObject);
rb_define_alloc_func(cOCSPReq, ossl_ocspreq_alloc);
diff --git a/ext/openssl/ossl_ocsp.h b/ext/openssl/ossl_ocsp.h
index 244fbb2a74..65b4f2e23f 100644
--- a/ext/openssl/ossl_ocsp.h
+++ b/ext/openssl/ossl_ocsp.h
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_ocsp.h,v 1.1 2003/07/23 16:11:29 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2003 Michal Rokos <m.rokos@sh.cvut.cz>
* Copyright (C) 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
diff --git a/ext/openssl/ossl_pkcs12.c b/ext/openssl/ossl_pkcs12.c
index e4b334c67e..e7d9954c5a 100644
--- a/ext/openssl/ossl_pkcs12.c
+++ b/ext/openssl/ossl_pkcs12.c
@@ -1,7 +1,7 @@
/*
* This program is licenced under the same licence as Ruby.
* (See the file 'LICENCE'.)
- * $Id: ossl_pkcs12.c,v 1.2 2003/12/15 00:30:12 usa Exp $
+ * $Id$
*/
#include "ossl.h"
diff --git a/ext/openssl/ossl_pkcs12.h b/ext/openssl/ossl_pkcs12.h
index 95b29de9b5..01dde2bc30 100644
--- a/ext/openssl/ossl_pkcs12.h
+++ b/ext/openssl/ossl_pkcs12.h
@@ -1,7 +1,7 @@
/*
* This program is licenced under the same licence as Ruby.
* (See the file 'LICENCE'.)
- * $Id: ossl_pkcs12.h,v 1.1.2.1 2005/06/19 16:29:17 gotoyuzo Exp $
+ * $Id$
*/
#if !defined(_OSSL_PKCS12_H_)
#define _OSSL_PKCS12_H_
diff --git a/ext/openssl/ossl_pkcs5.h b/ext/openssl/ossl_pkcs5.h
deleted file mode 100644
index a3b132bc50..0000000000
--- a/ext/openssl/ossl_pkcs5.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#if !defined(_OSSL_PKCS5_H_)
-#define _OSSL_PKCS5_H_
-
-void Init_ossl_pkcs5(void);
-
-#endif /* _OSSL_PKCS5_H_ */
diff --git a/ext/openssl/ossl_pkcs7.c b/ext/openssl/ossl_pkcs7.c
index 0fa85299aa..0fcabd7777 100644
--- a/ext/openssl/ossl_pkcs7.c
+++ b/ext/openssl/ossl_pkcs7.c
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_pkcs7.c,v 1.5.2.3 2005/09/10 01:11:15 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -667,8 +667,10 @@ ossl_pkcs7_verify(int argc, VALUE *argv, VALUE self)
}
ok = PKCS7_verify(p7, x509s, x509st, in, out, flg);
BIO_free(in);
+ if (ok < 0) ossl_raise(ePKCS7Error, NULL);
msg = ERR_reason_error_string(ERR_get_error());
ossl_pkcs7_set_err_string(self, msg ? rb_str_new2(msg) : Qnil);
+ ERR_clear_error();
data = ossl_membio2str(out);
ossl_pkcs7_set_data(self, data);
sk_X509_pop_free(x509s, X509_free);
diff --git a/ext/openssl/ossl_pkcs7.h b/ext/openssl/ossl_pkcs7.h
index fdf0d9fb34..f5942d65db 100644
--- a/ext/openssl/ossl_pkcs7.h
+++ b/ext/openssl/ossl_pkcs7.h
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_pkcs7.h,v 1.1.2.1 2005/09/10 01:17:00 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
diff --git a/ext/openssl/ossl_pkey.c b/ext/openssl/ossl_pkey.c
index 5a061597f6..d54f5b938e 100644
--- a/ext/openssl/ossl_pkey.c
+++ b/ext/openssl/ossl_pkey.c
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_pkey.c,v 1.4.2.2 2005/04/08 09:26:54 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -208,6 +208,10 @@ ossl_pkey_verify(VALUE self, VALUE digest, VALUE sig, VALUE data)
void
Init_ossl_pkey()
{
+#if 0 /* let rdoc know about mOSSL */
+ mOSSL = rb_define_module("OpenSSL");
+#endif
+
mPKey = rb_define_module_under(mOSSL, "PKey");
ePKeyError = rb_define_class_under(mPKey, "PKeyError", eOSSLError);
diff --git a/ext/openssl/ossl_pkey.h b/ext/openssl/ossl_pkey.h
index 224f0f4634..880a104675 100644
--- a/ext/openssl/ossl_pkey.h
+++ b/ext/openssl/ossl_pkey.h
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_pkey.h,v 1.2.2.2 2005/09/18 22:56:11 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
diff --git a/ext/openssl/ossl_pkey_dh.c b/ext/openssl/ossl_pkey_dh.c
index 79692f2f47..e16ede8bba 100644
--- a/ext/openssl/ossl_pkey_dh.c
+++ b/ext/openssl/ossl_pkey_dh.c
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_pkey_dh.c,v 1.4.2.3 2005/04/08 09:26:54 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -418,6 +418,11 @@ ossl_create_dh(unsigned char *p, size_t plen, unsigned char *g, size_t glen)
void
Init_ossl_dh()
{
+#if 0 /* let rdoc know about mOSSL and mPKey */
+ mOSSL = rb_define_module("OpenSSL");
+ mPKey = rb_define_module_under(mOSSL, "PKey");
+#endif
+
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);
diff --git a/ext/openssl/ossl_pkey_dsa.c b/ext/openssl/ossl_pkey_dsa.c
index 2a6060fe77..fdf23aa496 100644
--- a/ext/openssl/ossl_pkey_dsa.c
+++ b/ext/openssl/ossl_pkey_dsa.c
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_pkey_dsa.c,v 1.5.2.3 2005/09/18 22:56:11 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -378,6 +378,11 @@ OSSL_PKEY_BN(dsa, priv_key);
void
Init_ossl_dsa()
{
+#if 0 /* let rdoc know about mOSSL and mPKey */
+ mOSSL = rb_define_module("OpenSSL");
+ mPKey = rb_define_module_under(mOSSL, "PKey");
+#endif
+
eDSAError = rb_define_class_under(mPKey, "DSAError", ePKeyError);
cDSA = rb_define_class_under(mPKey, "DSA", cPKey);
diff --git a/ext/openssl/ossl_pkey_rsa.c b/ext/openssl/ossl_pkey_rsa.c
index 69d69c76f4..0afdcf8d01 100644
--- a/ext/openssl/ossl_pkey_rsa.c
+++ b/ext/openssl/ossl_pkey_rsa.c
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_pkey_rsa.c,v 1.5.2.4 2005/09/18 22:56:11 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -459,6 +459,11 @@ OSSL_PKEY_BN(rsa, iqmp);
void
Init_ossl_rsa()
{
+#if 0 /* let rdoc know about mOSSL and mPKey */
+ mOSSL = rb_define_module("OpenSSL");
+ mPKey = rb_define_module_under(mOSSL, "PKey");
+#endif
+
eRSAError = rb_define_class_under(mPKey, "RSAError", ePKeyError);
cRSA = rb_define_class_under(mPKey, "RSA", cPKey);
diff --git a/ext/openssl/ossl_rand.c b/ext/openssl/ossl_rand.c
index ffd68966ca..71bb3bedd5 100644
--- a/ext/openssl/ossl_rand.c
+++ b/ext/openssl/ossl_rand.c
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_rand.c,v 1.2 2003/09/17 09:05:02 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -115,6 +115,10 @@ ossl_rand_egd_bytes(VALUE self, VALUE filename, VALUE len)
void
Init_ossl_rand()
{
+#if 0 /* let rdoc know about mOSSL */
+ mOSSL = rb_define_module("OpenSSL");
+#endif
+
mRandom = rb_define_module_under(mOSSL, "Random");
eRandomError = rb_define_class_under(mRandom, "RandomError", eOSSLError);
diff --git a/ext/openssl/ossl_rand.h b/ext/openssl/ossl_rand.h
index 4895267fb6..ce2ae0d129 100644
--- a/ext/openssl/ossl_rand.h
+++ b/ext/openssl/ossl_rand.h
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_rand.h,v 1.1 2003/07/23 16:11:29 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c
index e4889d6d3f..8e632b526b 100644
--- a/ext/openssl/ossl_ssl.c
+++ b/ext/openssl/ossl_ssl.c
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_ssl.c,v 1.13.2.11 2006/03/17 10:10:53 gotoyuzo Exp $
+ * $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>
@@ -855,6 +855,10 @@ Init_ossl_ssl()
{
int i;
+#if 0 /* let rdoc know about mOSSL */
+ mOSSL = rb_define_module("OpenSSL");
+#endif
+
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);
ossl_ssl_ex_ptr_idx = SSL_get_ex_new_index(0,"ossl_ssl_ex_ptr_idx",0,0,0);
diff --git a/ext/openssl/ossl_ssl.h b/ext/openssl/ossl_ssl.h
index ba9ddb1985..5929eef856 100644
--- a/ext/openssl/ossl_ssl.h
+++ b/ext/openssl/ossl_ssl.h
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_ssl.h,v 1.1 2003/07/23 16:11:29 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
diff --git a/ext/openssl/ossl_version.h b/ext/openssl/ossl_version.h
index 6d43cdccbf..63878e0d8e 100644
--- a/ext/openssl/ossl_version.h
+++ b/ext/openssl/ossl_version.h
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_version.h,v 1.1 2003/07/23 16:11:29 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
diff --git a/ext/openssl/ossl_x509.c b/ext/openssl/ossl_x509.c
index fa90e92d11..fd1d9b6c7e 100644
--- a/ext/openssl/ossl_x509.c
+++ b/ext/openssl/ossl_x509.c
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_x509.c,v 1.2 2003/09/08 10:31:38 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
diff --git a/ext/openssl/ossl_x509.h b/ext/openssl/ossl_x509.h
index 8d1f77b302..1a43569073 100644
--- a/ext/openssl/ossl_x509.h
+++ b/ext/openssl/ossl_x509.h
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_x509.h,v 1.2 2003/11/01 09:24:55 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
diff --git a/ext/openssl/ossl_x509attr.c b/ext/openssl/ossl_x509attr.c
index 91a0795209..7b88e294a9 100644
--- a/ext/openssl/ossl_x509attr.c
+++ b/ext/openssl/ossl_x509attr.c
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_x509attr.c,v 1.4.2.2 2004/12/15 01:54:38 matz Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
diff --git a/ext/openssl/ossl_x509cert.c b/ext/openssl/ossl_x509cert.c
index 3ac9c894da..fc587a31f3 100644
--- a/ext/openssl/ossl_x509cert.c
+++ b/ext/openssl/ossl_x509cert.c
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_x509cert.c,v 1.3.2.1 2004/12/15 01:54:38 matz Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
diff --git a/ext/openssl/ossl_x509crl.c b/ext/openssl/ossl_x509crl.c
index 62d27fe7a4..0dc22416e7 100644
--- a/ext/openssl/ossl_x509crl.c
+++ b/ext/openssl/ossl_x509crl.c
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_x509crl.c,v 1.3.2.1 2004/12/15 01:54:38 matz Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
diff --git a/ext/openssl/ossl_x509ext.c b/ext/openssl/ossl_x509ext.c
index 219f30d7e3..31ffec48fa 100644
--- a/ext/openssl/ossl_x509ext.c
+++ b/ext/openssl/ossl_x509ext.c
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_x509ext.c,v 1.8.2.3 2005/11/22 22:28:51 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
diff --git a/ext/openssl/ossl_x509name.c b/ext/openssl/ossl_x509name.c
index 1a456f2c48..c5ed8b5457 100644
--- a/ext/openssl/ossl_x509name.c
+++ b/ext/openssl/ossl_x509name.c
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_x509name.c,v 1.4.2.8 2004/12/27 07:55:56 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -188,11 +188,11 @@ ossl_x509name_to_s(int argc, VALUE *argv, VALUE self)
return ossl_x509name_to_s_old(self);
else iflag = NUM2ULONG(flag);
if (!(out = BIO_new(BIO_s_mem())))
- ossl_raise(eX509NameError, NULL);
+ rb_raise(eX509NameError, NULL);
GetX509Name(self, name);
if (!X509_NAME_print_ex(out, name, 0, iflag)){
BIO_free(out);
- ossl_raise(eX509NameError, NULL);
+ rb_raise(eX509NameError, NULL);
}
str = ossl_membio2str(out);
diff --git a/ext/openssl/ossl_x509req.c b/ext/openssl/ossl_x509req.c
index c1b1a3e619..d644250433 100644
--- a/ext/openssl/ossl_x509req.c
+++ b/ext/openssl/ossl_x509req.c
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_x509req.c,v 1.5.2.2 2005/09/10 00:54:29 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
diff --git a/ext/openssl/ossl_x509revoked.c b/ext/openssl/ossl_x509revoked.c
index a0f2f00aa5..3ccac8d26a 100644
--- a/ext/openssl/ossl_x509revoked.c
+++ b/ext/openssl/ossl_x509revoked.c
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_x509revoked.c,v 1.2.2.1 2004/12/15 01:54:38 matz Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
diff --git a/ext/openssl/ossl_x509store.c b/ext/openssl/ossl_x509store.c
index 360769e612..cea845a1cc 100644
--- a/ext/openssl/ossl_x509store.c
+++ b/ext/openssl/ossl_x509store.c
@@ -1,5 +1,5 @@
/*
- * $Id: ossl_x509store.c,v 1.2.2.5 2005/09/10 00:54:29 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
diff --git a/ext/openssl/ruby_missing.h b/ext/openssl/ruby_missing.h
index f673bb157a..4bd08890f8 100644
--- a/ext/openssl/ruby_missing.h
+++ b/ext/openssl/ruby_missing.h
@@ -1,5 +1,5 @@
/*
- * $Id: ruby_missing.h,v 1.3 2003/09/06 08:56:57 gotoyuzo Exp $
+ * $Id$
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2003 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
diff --git a/ext/pty/lib/expect.rb b/ext/pty/lib/expect.rb
index 08191b05b9..aa9ab895d3 100644
--- a/ext/pty/lib/expect.rb
+++ b/ext/pty/lib/expect.rb
@@ -10,7 +10,7 @@ class IO
e_pat = pat
end
while true
- if !IO.select([self],nil,nil,timeout) or eof? then
+ if IO.select([self],nil,nil,timeout).nil? then
result = nil
break
end
diff --git a/ext/pty/pty.c b/ext/pty/pty.c
index 93fb5c0118..8e263790a4 100644
--- a/ext/pty/pty.c
+++ b/ext/pty/pty.c
@@ -62,7 +62,7 @@ char *MasterDevice = "/dev/ptym/pty%s",
0,
};
#elif defined(_IBMESA) /* AIX/ESA */
-static
+static
char *MasterDevice = "/dev/ptyp%s",
*SlaveDevice = "/dev/ttyp%s",
*deviceNo[] = {
@@ -84,7 +84,7 @@ char *MasterDevice = "/dev/ptyp%s",
"f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff",
};
#elif !defined(HAVE_PTSNAME)
-static
+static
char *MasterDevice = "/dev/pty%s",
*SlaveDevice = "/dev/tty%s",
*deviceNo[] = {
@@ -139,7 +139,7 @@ raise_from_wait(state, info)
char buf[1024];
VALUE exc;
- snprintf(buf, sizeof(buf), "pty - %s: %d", state, info->child_pid);
+ snprintf(buf, sizeof(buf), "pty - %s: %ld", state, (long)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);
@@ -183,10 +183,13 @@ struct exec_info {
VALUE *argv;
};
+static VALUE pty_exec _((VALUE v));
+
static VALUE
-pty_exec(arg)
- struct exec_info *arg;
+pty_exec(v)
+ VALUE v;
{
+ struct exec_info *arg = (struct exec_info *)v;
return rb_f_exec(arg->argc, arg->argv);
}
@@ -195,9 +198,9 @@ establishShell(argc, argv, info)
int argc;
VALUE *argv;
struct pty_info *info;
-{
- static int i,master,slave,currentPid;
- char *p, tmp, *getenv();
+{
+ int i,master,slave;
+ char *p,*getenv();
struct passwd *pwent;
VALUE v;
struct exec_info arg;
@@ -223,7 +226,6 @@ establishShell(argc, argv, info)
getDevice(&master,&slave);
info->thread = rb_thread_current();
- currentPid = getpid();
if((i = fork()) < 0) {
close(master);
close(slave);
@@ -231,8 +233,6 @@ establishShell(argc, argv, info)
}
if(i == 0) { /* child */
- currentPid = getpid();
-
/*
* Set free from process group and controlling terminal
*/
@@ -244,7 +244,7 @@ establishShell(argc, argv, info)
if (setpgrp() == -1)
perror("setpgrp()");
# else /* SETGRP_VOID */
- if (setpgrp(0, currentPid) == -1)
+ if (setpgrp(0, getpid()) == -1)
rb_sys_fail("setpgrp()");
if ((i = open("/dev/tty", O_RDONLY)) < 0)
rb_sys_fail("/dev/tty");
@@ -273,7 +273,6 @@ establishShell(argc, argv, info)
}
close(master);
#endif
- write(slave, "", 1);
dup2(slave,0);
dup2(slave,1);
dup2(slave,2);
@@ -289,7 +288,6 @@ establishShell(argc, argv, info)
_exit(1);
}
- read(master, &tmp, 1);
close(slave);
info->child_pid = i;
@@ -334,7 +332,6 @@ get_device_once(master, slave, fail)
strcpy(SlaveName, name);
return 0;
-}
#else /* HAVE__GETPTY */
int i,j;
@@ -356,7 +353,6 @@ get_device_once(master, slave, fail)
#if defined I_PUSH && !defined linux
if(ioctl(j, I_PUSH, "ptem") != -1) {
if(ioctl(j, I_PUSH, "ldterm") != -1) {
- ioctl(j, I_PUSH, "ttcompat");
#endif
*master = i;
*slave = j;
@@ -408,13 +404,6 @@ getDevice(master, slave)
}
}
-static void
-freeDevice()
-{
- chmod(SlaveName, 0666);
- chown(SlaveName, 0, 0);
-}
-
/* ruby function: getpty */
static VALUE
pty_getpty(argc, argv, self)
@@ -428,7 +417,7 @@ pty_getpty(argc, argv, self)
OpenFile *wfptr,*rfptr;
VALUE rport = rb_obj_alloc(rb_cFile);
VALUE wport = rb_obj_alloc(rb_cFile);
-
+
MakeOpenFile(rport, rfptr);
MakeOpenFile(wport, wfptr);
diff --git a/ext/purelib.rb b/ext/purelib.rb
new file mode 100644
index 0000000000..10ee06176c
--- /dev/null
+++ b/ext/purelib.rb
@@ -0,0 +1,3 @@
+if nul = $:.index("-")
+ $:[nul..-1] = ["."]
+end
diff --git a/ext/racc/cparse/cparse.c b/ext/racc/cparse/cparse.c
index 197a0eb40b..18a26f670f 100644
--- a/ext/racc/cparse/cparse.c
+++ b/ext/racc/cparse/cparse.c
@@ -393,10 +393,6 @@ cparse_params_mark(void *ptr)
rb_gc_mark(v->goto_check);
rb_gc_mark(v->goto_default);
rb_gc_mark(v->goto_pointer);
- rb_gc_mark(v->goto_pointer);
- rb_gc_mark(v->goto_pointer);
- rb_gc_mark(v->goto_pointer);
- rb_gc_mark(v->goto_pointer);
rb_gc_mark(v->reduce_table);
rb_gc_mark(v->token_table);
rb_gc_mark(v->state);
diff --git a/ext/racc/cparse/extconf.rb b/ext/racc/cparse/extconf.rb
index 8516c2998a..dd953a7e15 100644
--- a/ext/racc/cparse/extconf.rb
+++ b/ext/racc/cparse/extconf.rb
@@ -1,4 +1,4 @@
-# $Id: extconf.rb,v 1.1 2002/03/22 07:20:31 aamine Exp $
+# $Id$
require 'mkmf'
create_makefile 'racc/cparse'
diff --git a/ext/readline/extconf.rb b/ext/readline/extconf.rb
index b820c0b32f..b57a36f3a5 100644
--- a/ext/readline/extconf.rb
+++ b/ext/readline/extconf.rb
@@ -42,9 +42,9 @@ else
end
end
-have_func("rl_filename_completion_function")
-have_func("rl_username_completion_function")
-have_func("rl_completion_matches")
+have_readline_var("rl_filename_completion_function")
+have_readline_var("rl_username_completion_function")
+have_readline_var("rl_completion_matches")
have_readline_var("rl_deprep_term_function")
have_readline_var("rl_completion_append_character")
have_readline_var("rl_basic_word_break_characters")
@@ -59,6 +59,7 @@ have_func("rl_cleanup_after_signal")
have_func("rl_clear_signals")
have_func("rl_vi_editing_mode")
have_func("rl_emacs_editing_mode")
+have_func("rl_clear_signals")
have_func("replace_history_entry")
have_func("remove_history")
create_makefile("readline")
diff --git a/ext/readline/readline.c b/ext/readline/readline.c
index 3625fadef8..559e1c677b 100644
--- a/ext/readline/readline.c
+++ b/ext/readline/readline.c
@@ -34,36 +34,25 @@ static ID completion_proc, completion_case_fold;
#ifndef HAVE_RL_FILENAME_COMPLETION_FUNCTION
# define rl_filename_completion_function filename_completion_function
+#endif
+#ifndef HAVE_RL_USERNAME_COMPLETION_FUNCTION
# define rl_username_completion_function username_completion_function
+#endif
+#ifndef HAVE_RL_COMPLETION_MATCHES
# define rl_completion_matches completion_matches
#endif
+static int readline_event(void);
static char **readline_attempted_completion_function(const char *text,
int start, int end);
-#ifdef HAVE_RL_EVENT_HOOK
-#ifdef DOSISH
-#define BUSY_WAIT 1
-#else
-#define BUSY_WAIT 0
-#endif
-
-static int readline_event(void);
static int
readline_event()
{
-#if BUSY_WAIT
+ CHECK_INTS;
rb_thread_schedule();
-#else
- fd_set rset;
-
- FD_ZERO(&rset);
- FD_SET(fileno(rl_instream), &rset);
- rb_thread_select(fileno(rl_instream) + 1, &rset, NULL, NULL, NULL);
return 0;
-#endif
}
-#endif
static VALUE
readline_readline(argc, argv, self)
diff --git a/ext/sdbm/_sdbm.c b/ext/sdbm/_sdbm.c
index 7ffcf8579c..d4cf621ea5 100644
--- a/ext/sdbm/_sdbm.c
+++ b/ext/sdbm/_sdbm.c
@@ -8,7 +8,7 @@
*/
#ifndef lint
-/*char sdbm_rcsid[] = "$Id: _sdbm.c,v 1.5.2.1 2005/09/08 05:59:41 matz Exp $";*/
+/*char sdbm_rcsid[] = "$Id$";*/
#endif
#include "sdbm.h"
@@ -71,7 +71,7 @@ static int duppair proto((char *, datum));
#include <stdio.h>
#include <stdlib.h>
-#ifdef DOSISH
+#ifdef MSDOS
#include <io.h>
#endif
#include <sys/types.h>
@@ -626,7 +626,7 @@ register DBM *db;
*/
#ifndef lint
-/*char pair_rcsid[] = "$Id: _sdbm.c,v 1.5.2.1 2005/09/08 05:59:41 matz Exp $";*/
+/*char pair_rcsid[] = "$Id$";*/
#endif
#ifndef BSD42
diff --git a/ext/sdbm/init.c b/ext/sdbm/init.c
index ef4fb8ffbf..acadc9b26a 100644
--- a/ext/sdbm/init.c
+++ b/ext/sdbm/init.c
@@ -2,8 +2,8 @@
sdbminit.c -
- $Author: ocean $
- $Date: 2005/06/25 05:42:41 $
+ $Author$
+ $Date$
created at: Fri May 7 08:34:24 JST 1999
Copyright (C) 1995-2001 Yukihiro Matsumoto
diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb
index 41b715e0af..8a13ddba73 100644
--- a/ext/socket/extconf.rb
+++ b/ext/socket/extconf.rb
@@ -33,6 +33,9 @@ if /solaris/ =~ RUBY_PLATFORM and !try_compile("")
# bug of gcc 3.0 on Solaris 8 ?
headers << "sys/feature_tests.h"
end
+if have_header("arpa/inet.h")
+ headers << "arpa/inet.h"
+end
ipv6 = false
default_ipv6 = /cygwin/ !~ RUBY_PLATFORM
@@ -153,6 +156,10 @@ main()
if (ai->ai_addr == NULL)
goto bad;
#if defined(_AIX)
+ if (ai->ai_family == AF_INET6 && passive) {
+ inet6++;
+ continue;
+ }
ai->ai_addr->sa_len = ai->ai_addrlen;
ai->ai_addr->sa_family = ai->ai_family;
#endif
@@ -252,7 +259,6 @@ unless getaddr_info_ok and have_func("getnameinfo", "netdb.h") and have_func("ge
have_func("inet_ntop") or have_func("inet_ntoa")
have_func("inet_pton") or have_func("inet_aton")
have_func("getservbyport")
- have_header("arpa/inet.h")
have_header("arpa/nameser.h")
have_header("resolv.h")
end
diff --git a/ext/socket/getnameinfo.c b/ext/socket/getnameinfo.c
index 66f7e8818a..4c9c8f03c4 100644
--- a/ext/socket/getnameinfo.c
+++ b/ext/socket/getnameinfo.c
@@ -35,7 +35,6 @@
*/
#include "config.h"
-#include <stdio.h>
#include <sys/types.h>
#ifndef _WIN32
#if defined(__BEOS__)
@@ -52,11 +51,15 @@
#endif
#include <netdb.h>
#if defined(HAVE_RESOLV_H)
+#ifdef _SX
+#include <stdio.h>
+#endif
#include <resolv.h>
#endif
#endif
#ifdef _WIN32
#include <winsock2.h>
+#include <stdio.h>
#define snprintf _snprintf
#endif
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 8558e99ee5..4c23a1c178 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -2,8 +2,8 @@
socket.c -
- $Author: matz $
- $Date: 2006/08/07 07:50:28 $
+ $Author$
+ $Date$
created at: Thu Mar 31 12:21:29 JST 1994
Copyright (C) 1993-2001 Yukihiro Matsumoto
@@ -42,6 +42,9 @@
#ifdef HAVE_NETINET_UDP_H
# include <netinet/udp.h>
#endif
+#ifdef HAVE_ARPA_INET_H
+# include <arpa/inet.h>
+#endif
#include <netdb.h>
#endif
#include <errno.h>
@@ -195,6 +198,34 @@ ruby_getaddrinfo__aix(nodename, servname, hints, res)
}
#undef getaddrinfo
#define getaddrinfo(node,serv,hints,res) ruby_getaddrinfo__aix((node),(serv),(hints),(res))
+static int
+ruby_getnameinfo__aix(sa, salen, host, hostlen, serv, servlen, flags)
+ const struct sockaddr *sa;
+ size_t salen;
+ char *host;
+ size_t hostlen;
+ char *serv;
+ size_t servlen;
+ int flags;
+{
+ struct sockaddr_in6 *sa6;
+ u_int32_t *a6;
+
+ if (sa->sa_family == AF_INET6) {
+ sa6 = (struct sockaddr_in6 *)sa;
+ a6 = sa6->sin6_addr.u6_addr.u6_addr32;
+
+ if (a6[0] == 0 && a6[1] == 0 && a6[2] == 0 && a6[3] == 0) {
+ strncpy(host, "::", hostlen);
+ snprintf(serv, servlen, "%d", sa6->sin6_port);
+ return 0;
+ }
+ }
+ return getnameinfo(sa, salen, host, hostlen, serv, servlen, flags);
+}
+#undef getnameinfo
+#define getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) \
+ ruby_getnameinfo__aix((sa), (salen), (host), (hostlen), (serv), (servlen), (flags))
#ifndef CMSG_SPACE
# define CMSG_SPACE(len) (_CMSG_ALIGN(sizeof(struct cmsghdr)) + _CMSG_ALIGN(len))
#endif
@@ -1054,7 +1085,8 @@ ruby_connect(fd, sockaddr, len, socks)
int mode;
#if WAIT_IN_PROGRESS > 0
int wait_in_progress = -1;
- int sockerr, sockerrlen;
+ int sockerr;
+ socklen_t sockerrlen;
#endif
#if defined(HAVE_FCNTL)
@@ -1274,6 +1306,14 @@ init_inetsock(sock, remote_host, remote_serv, local_host, local_serv, type)
inetsock_cleanup, (VALUE)&arg);
}
+/*
+ * call-seq:
+ * TCPSocket.new(remote_host, remote_port, local_host=nil, local_port=nil)
+ *
+ * Opens a TCP connection to +remote_host+ on +remote_port+. If +local_host+
+ * and +local_port+ are specified, then those parameters are used on the local
+ * end to establish the connection.
+ */
static VALUE
tcp_init(argc, argv, sock)
int argc;
@@ -1424,24 +1464,6 @@ tcp_svr_init(argc, argv, sock)
return init_inetsock(sock, Qnil, arg1, Qnil, Qnil, INET_SERVER);
}
-static void
-make_fd_nonblock(int fd)
-{
- int flags;
-#ifdef F_GETFL
- flags = fcntl(fd, F_GETFL);
- if (flags == -1) {
- rb_sys_fail(0);
- }
-#else
- flags = 0;
-#endif
- flags |= O_NONBLOCK;
- if (fcntl(fd, F_SETFL, flags) == -1) {
- rb_sys_fail(0);
- }
-}
-
static VALUE
s_accept_nonblock(VALUE klass, OpenFile *fptr, struct sockaddr *sockaddr, socklen_t *len)
{
@@ -1453,7 +1475,6 @@ s_accept_nonblock(VALUE klass, OpenFile *fptr, struct sockaddr *sockaddr, sockle
if (fd2 < 0) {
rb_sys_fail("accept(2)");
}
- make_fd_nonblock(fd2);
return init_sock(rb_obj_alloc(klass), fd2);
}
@@ -2212,7 +2233,7 @@ unix_peeraddr(sock)
GetOpenFile(sock, fptr);
if (getpeername(fileno(fptr->f), (struct sockaddr*)&addr, &len) < 0)
- rb_sys_fail("getsockname(2)");
+ rb_sys_fail("getpeername(2)");
return unixaddr(&addr, len);
}
#endif
@@ -2930,7 +2951,7 @@ sock_recvfrom_nonblock(int argc, VALUE *argv, VALUE sock)
* socket.bind( sockaddr )
* socket.listen( 5 )
* client, client_sockaddr = socket.accept
- * puts "The client said, '#{socket.readline.chomp}'"
+ * puts "The client said, '#{client.readline.chomp}'"
* client.puts "Hello from script one!"
* socket.close
*
@@ -3035,7 +3056,7 @@ sock_accept(sock)
* IO.select([socket])
* retry
* end
- * puts "The client said, '#{socket.readline.chomp}'"
+ * puts "The client said, '#{client_socket.readline.chomp}'"
* client_socket.puts "Hello from script one!"
* socket.close
*
@@ -3090,8 +3111,8 @@ sock_accept_nonblock(sock)
* socket.bind( sockaddr )
* socket.listen( 5 )
* client_fd, client_sockaddr = socket.sysaccept
- * puts "The client said, '#{socket.readline.chomp}'"
* client_socket = Socket.for_fd( client_fd )
+ * puts "The client said, '#{client_socket.readline.chomp}'"
* client_socket.puts "Hello from script one!"
* socket.close
*
diff --git a/ext/socket/sockport.h b/ext/socket/sockport.h
index 8c7bebf558..e1cddf53f4 100644
--- a/ext/socket/sockport.h
+++ b/ext/socket/sockport.h
@@ -2,8 +2,8 @@
sockport.h -
- $Author: eban $
- $Date: 2000/08/24 06:29:30 $
+ $Author$
+ $Date$
created at: Fri Apr 30 23:19:34 JST 1999
************************************************/
diff --git a/ext/stringio/README b/ext/stringio/README
index 190052309c..c4031f7e97 100644
--- a/ext/stringio/README
+++ b/ext/stringio/README
@@ -1,6 +1,6 @@
-*- rd -*-
-$Author: nobu $
-$Date: 2002/02/19 13:16:24 $
+$Author$
+$Date$
=begin
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c
index fcc596d5f0..a64aaf837c 100644
--- a/ext/stringio/stringio.c
+++ b/ext/stringio/stringio.c
@@ -2,8 +2,8 @@
stringio.c -
- $Author: nobu $
- $Date: 2005/08/13 09:36:12 $
+ $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
@@ -136,7 +136,6 @@ check_modifiable(ptr)
static VALUE strio_s_allocate _((VALUE));
static VALUE strio_s_open _((int, VALUE *, VALUE));
-static void strio_init _((int, VALUE *, struct StringIO *));
static VALUE strio_initialize _((int, VALUE *, VALUE));
static VALUE strio_finalize _((VALUE));
static VALUE strio_self _((VALUE));
@@ -218,24 +217,13 @@ strio_initialize(argc, argv, self)
VALUE self;
{
struct StringIO *ptr = check_strio(self);
+ VALUE string, mode;
+ int trunc = Qfalse;
if (!ptr) {
DATA_PTR(self) = ptr = strio_alloc();
}
rb_call_super(0, 0);
- strio_init(argc, argv, ptr);
- return self;
-}
-
-static void
-strio_init(argc, argv, ptr)
- int argc;
- VALUE *argv;
- struct StringIO *ptr;
-{
- VALUE string, mode;
- int trunc = Qfalse;
-
switch (rb_scan_args(argc, argv, "02", &string, &mode)) {
case 2:
if (FIXNUM_P(mode)) {
@@ -267,6 +255,7 @@ strio_init(argc, argv, ptr)
break;
}
ptr->string = string;
+ return self;
}
static VALUE
@@ -581,8 +570,7 @@ strio_reopen(argc, argv, self)
if (argc == 1 && TYPE(*argv) != T_STRING) {
return strio_copy(self, *argv);
}
- strio_init(argc, argv, StringIO(self));
- return self;
+ return strio_initialize(argc, argv, self);
}
/*
diff --git a/ext/strscan/strscan.c b/ext/strscan/strscan.c
index 5e5ab5db1f..b5ee20282c 100644
--- a/ext/strscan/strscan.c
+++ b/ext/strscan/strscan.c
@@ -1,5 +1,5 @@
/*
- $Id: strscan.c,v 1.7.2.8 2006/07/26 09:37:00 aamine Exp $
+ $Id$
Copyright (c) 1999-2006 Minero Aoki
@@ -403,6 +403,7 @@ strscan_do_scan(VALUE self, VALUE regex, int succptr, int getstr, int headonly)
if (S_RESTLEN(p) < 0) {
return Qnil;
}
+ rb_kcode_set_option(regex);
if (headonly) {
ret = re_match(RREGEXP(regex)->ptr,
CURPTR(p), S_RESTLEN(p),
@@ -416,6 +417,7 @@ strscan_do_scan(VALUE self, VALUE regex, int succptr, int getstr, int headonly)
S_RESTLEN(p),
&(p->regs));
}
+ rb_kcode_reset_option();
if (ret == -2) rb_raise(ScanError, "regexp buffer overflow");
if (ret < 0) {
@@ -1256,7 +1258,7 @@ Init_strscan(void)
tmp = rb_str_new2(STRSCAN_VERSION);
rb_obj_freeze(tmp);
rb_const_set(StringScanner, rb_intern("Version"), tmp);
- tmp = rb_str_new2("$Id: strscan.c,v 1.7.2.8 2006/07/26 09:37:00 aamine Exp $");
+ tmp = rb_str_new2("$Id$");
rb_obj_freeze(tmp);
rb_const_set(StringScanner, rb_intern("Id"), tmp);
diff --git a/ext/syck/bytecode.c b/ext/syck/bytecode.c
index acda3b15a4..567aaf52a8 100644
--- a/ext/syck/bytecode.c
+++ b/ext/syck/bytecode.c
@@ -3,8 +3,8 @@
/*
* bytecode.re
*
- * $Author: why $
- * $Date: 2005/09/20 06:46:43 $
+ * $Author$
+ * $Date$
*
* Copyright (C) 2003 why the lucky stiff
*/
diff --git a/ext/syck/emitter.c b/ext/syck/emitter.c
index 8d32784cd5..9c8ab8d49b 100644
--- a/ext/syck/emitter.c
+++ b/ext/syck/emitter.c
@@ -1,8 +1,8 @@
/*
* emitter.c
*
- * $Author: matz $
- * $Date: 2006/05/03 17:29:34 $
+ * $Author$
+ * $Date$
*
* Copyright (C) 2003 why the lucky stiff
*
diff --git a/ext/syck/handler.c b/ext/syck/handler.c
index 26fb258318..56fe838fbd 100644
--- a/ext/syck/handler.c
+++ b/ext/syck/handler.c
@@ -1,8 +1,8 @@
/*
* handler.c
*
- * $Author: why $
- * $Date: 2005/09/20 06:46:43 $
+ * $Author$
+ * $Date$
*
* Copyright (C) 2003 why the lucky stiff
*/
diff --git a/ext/syck/implicit.c b/ext/syck/implicit.c
index 0f922f4d1b..d356faf7d9 100644
--- a/ext/syck/implicit.c
+++ b/ext/syck/implicit.c
@@ -3,8 +3,8 @@
/*
* implicit.re
*
- * $Author: ocean $
- * $Date: 2005/10/26 00:28:39 $
+ * $Author$
+ * $Date$
*
* Copyright (C) 2003 why the lucky stiff
*/
diff --git a/ext/syck/node.c b/ext/syck/node.c
index 724f747e99..28fc78c077 100644
--- a/ext/syck/node.c
+++ b/ext/syck/node.c
@@ -1,8 +1,8 @@
/*
* node.c
*
- * $Author: matz $
- * $Date: 2005/09/16 09:35:23 $
+ * $Author$
+ * $Date$
*
* Copyright (C) 2003 why the lucky stiff
*/
diff --git a/ext/syck/rubyext.c b/ext/syck/rubyext.c
index 8cd2da7c4e..078de4f78d 100644
--- a/ext/syck/rubyext.c
+++ b/ext/syck/rubyext.c
@@ -2,8 +2,8 @@
/*
* rubyext.c
*
- * $Author: ocean $
- * $Date: 2006/01/30 15:11:57 $
+ * $Author$
+ * $Date$
*
* Copyright (C) 2003-2005 why the lucky stiff
*/
@@ -2280,6 +2280,7 @@ Init_syck()
*/
cScalar = rb_define_class_under( rb_syck, "Scalar", cNode );
rb_define_alloc_func( cScalar, syck_scalar_alloc );
+ rb_define_attr( cNode, "value", 1, 0 );
rb_define_method( cScalar, "initialize", syck_scalar_initialize, 3 );
rb_define_method( cScalar, "value=", syck_scalar_value_set, 1 );
rb_define_method( cScalar, "style=", syck_scalar_style_set, 1 );
diff --git a/ext/syck/syck.c b/ext/syck/syck.c
index ac5427bc1b..a83c8813c1 100644
--- a/ext/syck/syck.c
+++ b/ext/syck/syck.c
@@ -1,8 +1,8 @@
/*
* syck.c
*
- * $Author: matz $
- * $Date: 2006/08/07 08:09:34 $
+ * $Author$
+ * $Date$
*
* Copyright (C) 2003 why the lucky stiff
*/
diff --git a/ext/syck/syck.h b/ext/syck/syck.h
index bc383ff2de..c49f740173 100644
--- a/ext/syck/syck.h
+++ b/ext/syck/syck.h
@@ -1,8 +1,8 @@
/*
* syck.h
*
- * $Author: ocean $
- * $Date: 2005/12/20 04:13:26 $
+ * $Author$
+ * $Date$
*
* Copyright (C) 2003 why the lucky stiff
*/
@@ -17,7 +17,6 @@
#define YAML_DOMAIN "yaml.org,2002"
#include <stdio.h>
-#include <stdlib.h>
#include <ctype.h>
#include "st.h"
@@ -400,7 +399,6 @@ int syck_scan_scalar( int, char *, long );
void syck_parser_handler( SyckParser *, SyckNodeHandler );
void syck_parser_error_handler( SyckParser *, SyckErrorHandler );
void syck_parser_bad_anchor_handler( SyckParser *, SyckBadAnchorHandler );
-void syck_parser_set_input_type( SyckParser *, enum syck_parser_input );
void syck_parser_file( SyckParser *, FILE *, SyckIoFileRead );
void syck_parser_str( SyckParser *, char *, long, SyckIoStrRead );
void syck_parser_str_auto( SyckParser *, char *, SyckIoStrRead );
diff --git a/ext/syck/token.c b/ext/syck/token.c
index e7b0414f74..3c6cd1a9cf 100644
--- a/ext/syck/token.c
+++ b/ext/syck/token.c
@@ -3,8 +3,8 @@
/*
* token.re
*
- * $Author: why $
- * $Date: 2005/09/20 23:56:24 $
+ * $Author$
+ * $Date$
*
* Copyright (C) 2003 why the lucky stiff
*/
diff --git a/ext/syck/yaml2byte.c b/ext/syck/yaml2byte.c
index 01a3aaf652..821a3cd5b5 100644
--- a/ext/syck/yaml2byte.c
+++ b/ext/syck/yaml2byte.c
@@ -1,8 +1,8 @@
/*
* yaml2byte.c
*
- * $Author: matz $
- * $Date: 2006/05/03 17:41:10 $
+ * $Author$
+ * $Date$
*
* Copyright (C) 2003 why the lucky stiff, clark evans
*
diff --git a/ext/syslog/extconf.rb b/ext/syslog/extconf.rb
index d47ed8fd61..0fa0bc339b 100644
--- a/ext/syslog/extconf.rb
+++ b/ext/syslog/extconf.rb
@@ -1,5 +1,5 @@
# $RoughId: extconf.rb,v 1.3 2001/11/24 17:49:26 knu Exp $
-# $Id: extconf.rb,v 1.1 2001/11/26 12:00:40 knu Exp $
+# $Id$
require 'mkmf'
diff --git a/ext/syslog/syslog.c b/ext/syslog/syslog.c
index 99e4215a95..477489ddfe 100644
--- a/ext/syslog/syslog.c
+++ b/ext/syslog/syslog.c
@@ -4,7 +4,7 @@
* <amos+ruby@utdallas.edu>
*
* $RoughId: syslog.c,v 1.21 2002/02/25 12:21:17 knu Exp $
- * $Id: syslog.c,v 1.8.2.1 2004/04/05 07:45:24 matz Exp $
+ * $Id$
*/
#include "ruby.h"
diff --git a/ext/syslog/syslog.txt b/ext/syslog/syslog.txt
index b134ed2a40..9aed35133d 100644
--- a/ext/syslog/syslog.txt
+++ b/ext/syslog/syslog.txt
@@ -1,6 +1,6 @@
.\" syslog.txt - -*- Indented-Text -*-
$RoughId: syslog.txt,v 1.18 2002/02/25 08:20:14 knu Exp $
-$Id: syslog.txt,v 1.2 2002/02/25 12:13:30 knu Exp $
+$Id$
UNIX Syslog extension for Ruby
Amos Gouaux, University of Texas at Dallas
diff --git a/ext/syslog/test.rb b/ext/syslog/test.rb
index 907602c21d..cfa33eff8f 100644
--- a/ext/syslog/test.rb
+++ b/ext/syslog/test.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
# $RoughId: test.rb,v 1.9 2002/02/25 08:20:14 knu Exp $
-# $Id: test.rb,v 1.4 2002/11/27 08:36:22 knu Exp $
+# $Id$
# Please only run this test on machines reasonable for testing.
# If in doubt, ask your admin.
diff --git a/ext/thread/extconf.rb b/ext/thread/extconf.rb
new file mode 100644
index 0000000000..2f984efc6d
--- /dev/null
+++ b/ext/thread/extconf.rb
@@ -0,0 +1,9 @@
+require 'mkmf'
+
+enable_config('fastthread', true) or exit
+
+if with_config('mem-pools', true)
+ $CPPFLAGS << ' -DUSE_MEM_POOLS'
+end
+
+create_makefile("thread")
diff --git a/ext/thread/lib/thread.rb b/ext/thread/lib/thread.rb
new file mode 100644
index 0000000000..6c533aba39
--- /dev/null
+++ b/ext/thread/lib/thread.rb
@@ -0,0 +1,5 @@
+unless defined? Thread
+ fail "Thread not available for this ruby interpreter"
+end
+
+require 'thread.so'
diff --git a/ext/thread/thread.c b/ext/thread/thread.c
new file mode 100644
index 0000000000..910b326696
--- /dev/null
+++ b/ext/thread/thread.c
@@ -0,0 +1,1214 @@
+/*
+ * Optimized Ruby Mutex implementation, loosely based on thread.rb by
+ * Yukihiro Matsumoto <matz@ruby-lang.org>
+ *
+ * Copyright 2006-2007 MenTaLguY <mental@rydia.net>
+ *
+ * RDoc taken from original.
+ *
+ * This file is made available under the same terms as Ruby.
+ */
+
+#include <ruby.h>
+#include <intern.h>
+#include <rubysig.h>
+#include <node.h>
+
+static VALUE rb_cMutex;
+static VALUE rb_cConditionVariable;
+static VALUE rb_cQueue;
+static VALUE rb_cSizedQueue;
+
+static VALUE set_critical(VALUE value);
+
+static VALUE
+thread_exclusive_do(void)
+{
+ rb_thread_critical = 1;
+
+ return rb_yield(Qundef);
+}
+
+/*
+ * call-seq:
+ * Thread.exclusive { block } => obj
+ *
+ * Wraps a block in Thread.critical, restoring the original value
+ * upon exit from the critical section, and returns the value of the
+ * block.
+ */
+
+static VALUE
+rb_thread_exclusive(void)
+{
+ return rb_ensure(thread_exclusive_do, Qundef, set_critical, rb_thread_critical);
+}
+
+typedef struct _Entry {
+ VALUE value;
+ struct _Entry *next;
+} Entry;
+
+typedef struct _List {
+ Entry *entries;
+ Entry *last_entry;
+ Entry *entry_pool;
+ unsigned long size;
+} List;
+
+static void
+init_list(List *list)
+{
+ list->entries = NULL;
+ list->last_entry = NULL;
+ list->entry_pool = NULL;
+ list->size = 0;
+}
+
+static void
+mark_list(List *list)
+{
+ Entry *entry;
+ for (entry = list->entries; entry; entry = entry->next) {
+ rb_gc_mark(entry->value);
+ }
+}
+
+static void
+free_entries(Entry *first)
+{
+ Entry *next;
+ while (first) {
+ next = first->next;
+ xfree(first);
+ first = next;
+ }
+}
+
+static void
+finalize_list(List *list)
+{
+ free_entries(list->entries);
+ free_entries(list->entry_pool);
+}
+
+static void
+push_list(List *list, VALUE value)
+{
+ Entry *entry;
+
+ if (list->entry_pool) {
+ entry = list->entry_pool;
+ list->entry_pool = entry->next;
+ } else {
+ entry = ALLOC(Entry);
+ }
+
+ entry->value = value;
+ entry->next = NULL;
+
+ if (list->last_entry) {
+ list->last_entry->next = entry;
+ } else {
+ list->entries = entry;
+ }
+ list->last_entry = entry;
+
+ ++list->size;
+}
+
+static void
+push_multiple_list(List *list, VALUE *values, unsigned count)
+{
+ unsigned i;
+ for (i = 0; i < count; i++) {
+ push_list(list, values[i]);
+ }
+}
+
+static void
+recycle_entries(List *list, Entry *first_entry, Entry *last_entry)
+{
+#ifdef USE_MEM_POOLS
+ last_entry->next = list->entry_pool;
+ list->entry_pool = first_entry;
+#else
+ last_entry->next = NULL;
+ free_entries(first_entry);
+#endif
+}
+
+static VALUE
+shift_list(List *list)
+{
+ Entry *entry;
+ VALUE value;
+
+ entry = list->entries;
+ if (!entry) return Qundef;
+
+ list->entries = entry->next;
+ if (entry == list->last_entry) {
+ list->last_entry = NULL;
+ }
+
+ --list->size;
+
+ value = entry->value;
+ recycle_entries(list, entry, entry);
+
+ return value;
+}
+
+static void
+remove_one(List *list, VALUE value)
+{
+ Entry **ref;
+ Entry *prev;
+ Entry *entry;
+
+ for (ref = &list->entries, prev = NULL, entry = list->entries;
+ entry != NULL;
+ ref = &entry->next, prev = entry, entry = entry->next) {
+ if (entry->value == value) {
+ *ref = entry->next;
+ list->size--;
+ if (!entry->next) {
+ list->last_entry = prev;
+ }
+ recycle_entries(list, entry, entry);
+ break;
+ }
+ }
+}
+
+static void
+clear_list(List *list)
+{
+ if (list->last_entry) {
+ recycle_entries(list, list->entries, list->last_entry);
+ list->entries = NULL;
+ list->last_entry = NULL;
+ list->size = 0;
+ }
+}
+
+static VALUE
+array_from_list(List const *list)
+{
+ VALUE ary;
+ Entry *entry;
+ ary = rb_ary_new();
+ for (entry = list->entries; entry; entry = entry->next) {
+ rb_ary_push(ary, entry->value);
+ }
+ return ary;
+}
+
+static VALUE
+wake_thread(VALUE thread)
+{
+ return rb_thread_wakeup_alive(thread);
+}
+
+static VALUE
+run_thread(VALUE thread)
+{
+ thread = wake_thread(thread);
+ if (RTEST(thread) && !rb_thread_critical)
+ rb_thread_schedule();
+ return thread;
+}
+
+static VALUE
+wake_one(List *list)
+{
+ VALUE waking;
+
+ waking = Qnil;
+ while (list->entries && !RTEST(waking)) {
+ waking = shift_list(list);
+ if (waking == Qundef) break;
+ waking = wake_thread(waking);
+ }
+
+ return waking;
+}
+
+static VALUE
+wake_all(List *list)
+{
+ while (list->entries) {
+ wake_one(list);
+ }
+ return Qnil;
+}
+
+static VALUE
+wait_list_inner(List *list)
+{
+ push_list(list, rb_thread_current());
+ rb_thread_stop();
+ return Qnil;
+}
+
+static VALUE
+wait_list_cleanup(List *list)
+{
+ /* cleanup in case of spurious wakeups */
+ remove_one(list, rb_thread_current());
+ return Qnil;
+}
+
+static void
+wait_list(List *list)
+{
+ rb_ensure(wait_list_inner, (VALUE)list, wait_list_cleanup, (VALUE)list);
+}
+
+static void
+assert_no_survivors(List *waiting, const char *label, void *addr)
+{
+ Entry *entry;
+ VALUE ths = 0;
+
+ for (entry = waiting->entries; entry; entry = entry->next) {
+ if (RTEST(wake_thread(entry->value))) {
+ if (!ths) ths = rb_ary_new();
+ rb_ary_push(ths, entry->value);
+ }
+ }
+ if (ths) {
+ rb_bug("%s %p freed with live thread(s) %s waiting",
+ label, addr, RSTRING_PTR(rb_inspect(ths)));
+ }
+}
+
+/*
+ * Document-class: Mutex
+ *
+ * Mutex implements a simple semaphore that can be used to coordinate access to
+ * shared data from multiple concurrent threads.
+ *
+ * Example:
+ *
+ * require 'thread'
+ * semaphore = Mutex.new
+ *
+ * a = Thread.new {
+ * semaphore.synchronize {
+ * # access shared resource
+ * }
+ * }
+ *
+ * b = Thread.new {
+ * semaphore.synchronize {
+ * # access shared resource
+ * }
+ * }
+ *
+ */
+
+typedef struct _Mutex {
+ VALUE owner;
+ List waiting;
+} Mutex;
+
+#define MUTEX_LOCKED_P(mutex) (RTEST((mutex)->owner) && rb_thread_alive_p((mutex)->owner))
+
+static void
+mark_mutex(Mutex *mutex)
+{
+ rb_gc_mark(mutex->owner);
+ mark_list(&mutex->waiting);
+}
+
+static void
+finalize_mutex(Mutex *mutex)
+{
+ finalize_list(&mutex->waiting);
+}
+
+static void
+free_mutex(Mutex *mutex)
+{
+ assert_no_survivors(&mutex->waiting, "mutex", mutex);
+ finalize_mutex(mutex);
+ xfree(mutex);
+}
+
+static void
+init_mutex(Mutex *mutex)
+{
+ mutex->owner = Qnil;
+ init_list(&mutex->waiting);
+}
+
+/*
+ * Document-method: new
+ * call-seq: Mutex.new
+ *
+ * Creates a new Mutex
+ *
+ */
+
+static VALUE
+rb_mutex_alloc(VALUE klass)
+{
+ Mutex *mutex;
+ mutex = ALLOC(Mutex);
+ init_mutex(mutex);
+ return Data_Wrap_Struct(klass, mark_mutex, free_mutex, mutex);
+}
+
+/*
+ * Document-method: locked?
+ * call-seq: locked?
+ *
+ * Returns +true+ if this lock is currently held by some thread.
+ *
+ */
+
+static VALUE
+rb_mutex_locked_p(VALUE self)
+{
+ Mutex *mutex;
+ Data_Get_Struct(self, Mutex, mutex);
+ return MUTEX_LOCKED_P(mutex) ? Qtrue : Qfalse;
+}
+
+/*
+ * Document-method: try_lock
+ * call-seq: try_lock
+ *
+ * Attempts to obtain the lock and returns immediately. Returns +true+ if the
+ * lock was granted.
+ *
+ */
+
+static VALUE
+rb_mutex_try_lock(VALUE self)
+{
+ Mutex *mutex;
+
+ Data_Get_Struct(self, Mutex, mutex);
+
+ if (MUTEX_LOCKED_P(mutex))
+ return Qfalse;
+
+ mutex->owner = rb_thread_current();
+ return Qtrue;
+}
+
+/*
+ * Document-method: lock
+ * call-seq: lock
+ *
+ * Attempts to grab the lock and waits if it isn't available.
+ *
+ */
+
+static VALUE
+lock_mutex(Mutex *mutex)
+{
+ VALUE current;
+ current = rb_thread_current();
+
+ rb_thread_critical = 1;
+
+ if (!MUTEX_LOCKED_P(mutex)) {
+ mutex->owner = current;
+ }
+ else {
+ push_list(&mutex->waiting, current);
+ do {
+ rb_thread_stop();
+ rb_thread_critical = 1;
+ if (!MUTEX_LOCKED_P(mutex)) {
+ mutex->owner = current;
+ break;
+ }
+ } while (mutex->owner != current);
+ }
+
+ rb_thread_critical = 0;
+ return Qnil;
+}
+
+static VALUE
+rb_mutex_lock(VALUE self)
+{
+ Mutex *mutex;
+ Data_Get_Struct(self, Mutex, mutex);
+ lock_mutex(mutex);
+ return self;
+}
+
+static VALUE
+relock_mutex(Mutex *mutex)
+{
+ VALUE current = rb_thread_current();
+
+ switch (rb_thread_status(current)) {
+ case THREAD_RUNNABLE:
+ case THREAD_STOPPED:
+ lock_mutex(mutex);
+ break;
+ default:
+ break;
+ }
+ return Qundef;
+}
+
+/*
+ * Document-method: unlock
+ *
+ * Releases the lock. Returns +nil+ if ref wasn't locked.
+ *
+ */
+
+static VALUE
+unlock_mutex_inner(Mutex *mutex)
+{
+ VALUE waking;
+
+ if (mutex->owner != rb_thread_current()) {
+ rb_raise(rb_eThreadError, "not owner");
+ }
+
+ waking = wake_one(&mutex->waiting);
+ mutex->owner = waking;
+
+ return waking;
+}
+
+static VALUE
+set_critical(VALUE value)
+{
+ rb_thread_critical = (int)value;
+ return Qundef;
+}
+
+static VALUE
+unlock_mutex(Mutex *mutex)
+{
+ VALUE waking;
+
+ rb_thread_critical = 1;
+ waking = rb_ensure(unlock_mutex_inner, (VALUE)mutex, set_critical, 0);
+ if (!RTEST(waking)) {
+ return Qfalse;
+ }
+
+ run_thread(waking);
+
+ return Qtrue;
+}
+
+static VALUE
+rb_mutex_unlock(VALUE self)
+{
+ Mutex *mutex;
+ Data_Get_Struct(self, Mutex, mutex);
+
+ if (RTEST(unlock_mutex(mutex))) {
+ return self;
+ } else {
+ return Qnil;
+ }
+}
+
+/*
+ * Document-method: exclusive_unlock
+ * call-seq: exclusive_unlock { ... }
+ *
+ * If the mutex is locked, unlocks the mutex, wakes one waiting thread, and
+ * yields in a critical section.
+ *
+ */
+
+static VALUE
+rb_mutex_exclusive_unlock_inner(Mutex *mutex)
+{
+ VALUE waking;
+ waking = unlock_mutex_inner(mutex);
+ rb_yield(Qundef);
+ return waking;
+}
+
+static VALUE
+rb_mutex_exclusive_unlock(VALUE self)
+{
+ Mutex *mutex;
+ VALUE waking;
+ Data_Get_Struct(self, Mutex, mutex);
+
+ rb_thread_critical = 1;
+ waking = rb_ensure(rb_mutex_exclusive_unlock_inner, (VALUE)mutex, set_critical, 0);
+
+ if (waking == Qundef || !RTEST(waking)) {
+ return Qnil;
+ }
+
+ run_thread(waking);
+
+ return self;
+}
+
+/*
+ * Document-method: synchronize
+ * call-seq: synchronize { ... }
+ *
+ * Obtains a lock, runs the block, and releases the lock when the block
+ * completes. See the example under Mutex.
+ *
+ */
+
+static VALUE
+rb_mutex_synchronize(VALUE self)
+{
+ rb_mutex_lock(self);
+ return rb_ensure(rb_yield, Qundef, rb_mutex_unlock, self);
+}
+
+/*
+ * Document-class: ConditionVariable
+ *
+ * ConditionVariable objects augment class Mutex. Using condition variables,
+ * it is possible to suspend while in the middle of a critical section until a
+ * resource becomes available.
+ *
+ * Example:
+ *
+ * require 'thread'
+ *
+ * mutex = Mutex.new
+ * resource = ConditionVariable.new
+ *
+ * a = Thread.new {
+ * mutex.synchronize {
+ * # Thread 'a' now needs the resource
+ * resource.wait(mutex)
+ * # 'a' can now have the resource
+ * }
+ * }
+ *
+ * b = Thread.new {
+ * mutex.synchronize {
+ * # Thread 'b' has finished using the resource
+ * resource.signal
+ * }
+ * }
+ *
+ */
+
+typedef struct _ConditionVariable {
+ List waiting;
+} ConditionVariable;
+
+static void
+mark_condvar(ConditionVariable *condvar)
+{
+ mark_list(&condvar->waiting);
+}
+
+static void
+finalize_condvar(ConditionVariable *condvar)
+{
+ finalize_list(&condvar->waiting);
+}
+
+static void
+free_condvar(ConditionVariable *condvar)
+{
+ assert_no_survivors(&condvar->waiting, "condition variable", condvar);
+ finalize_condvar(condvar);
+ xfree(condvar);
+}
+
+static void
+init_condvar(ConditionVariable *condvar)
+{
+ init_list(&condvar->waiting);
+}
+
+/*
+ * Document-method: new
+ * call-seq: ConditionVariable.new
+ *
+ * Creates a new ConditionVariable
+ *
+ */
+
+static VALUE
+rb_condvar_alloc(VALUE klass)
+{
+ ConditionVariable *condvar;
+
+ condvar = ALLOC(ConditionVariable);
+ init_condvar(condvar);
+
+ return Data_Wrap_Struct(klass, mark_condvar, free_condvar, condvar);
+}
+
+/*
+ * Document-method: wait
+ * call-seq: wait
+ *
+ * Releases the lock held in +mutex+ and waits; reacquires the lock on wakeup.
+ *
+ */
+
+static void
+wait_condvar(ConditionVariable *condvar, Mutex *mutex)
+{
+ VALUE waking;
+
+ rb_thread_critical = 1;
+ if (rb_thread_current() != mutex->owner) {
+ rb_thread_critical = 0;
+ rb_raise(rb_eThreadError, "not owner of the synchronization mutex");
+ }
+ waking = unlock_mutex_inner(mutex);
+ if (RTEST(waking)) {
+ wake_thread(waking);
+ }
+ rb_ensure(wait_list, (VALUE)&condvar->waiting, relock_mutex, (VALUE)mutex);
+}
+
+static VALUE
+legacy_exclusive_unlock(VALUE mutex)
+{
+ return rb_funcall(mutex, rb_intern("exclusive_unlock"), 0);
+}
+
+typedef struct {
+ ConditionVariable *condvar;
+ VALUE mutex;
+} legacy_wait_args;
+
+static VALUE
+legacy_wait(VALUE unused, legacy_wait_args *args)
+{
+ wait_list(&args->condvar->waiting);
+ rb_funcall(args->mutex, rb_intern("lock"), 0);
+ return Qnil;
+}
+
+static VALUE
+rb_condvar_wait(VALUE self, VALUE mutex_v)
+{
+ ConditionVariable *condvar;
+ Data_Get_Struct(self, ConditionVariable, condvar);
+
+ if (CLASS_OF(mutex_v) != rb_cMutex) {
+ /* interoperate with legacy mutex */
+ legacy_wait_args args;
+ args.condvar = condvar;
+ args.mutex = mutex_v;
+ rb_iterate(legacy_exclusive_unlock, mutex_v, legacy_wait, (VALUE)&args);
+ } else {
+ Mutex *mutex;
+ Data_Get_Struct(mutex_v, Mutex, mutex);
+ wait_condvar(condvar, mutex);
+ }
+
+ return self;
+}
+
+/*
+ * Document-method: broadcast
+ * call-seq: broadcast
+ *
+ * Wakes up all threads waiting for this condition.
+ *
+ */
+
+static VALUE
+rb_condvar_broadcast(VALUE self)
+{
+ ConditionVariable *condvar;
+
+ Data_Get_Struct(self, ConditionVariable, condvar);
+
+ rb_thread_critical = 1;
+ rb_ensure(wake_all, (VALUE)&condvar->waiting, set_critical, 0);
+ rb_thread_schedule();
+
+ return self;
+}
+
+/*
+ * Document-method: signal
+ * call-seq: signal
+ *
+ * Wakes up the first thread in line waiting for this condition.
+ *
+ */
+
+static void
+signal_condvar(ConditionVariable *condvar)
+{
+ VALUE waking;
+ rb_thread_critical = 1;
+ waking = rb_ensure(wake_one, (VALUE)&condvar->waiting, set_critical, 0);
+ if (RTEST(waking)) {
+ run_thread(waking);
+ }
+}
+
+static VALUE
+rb_condvar_signal(VALUE self)
+{
+ ConditionVariable *condvar;
+ Data_Get_Struct(self, ConditionVariable, condvar);
+ signal_condvar(condvar);
+ return self;
+}
+
+/*
+ * Document-class: Queue
+ *
+ * This class provides a way to synchronize communication between threads.
+ *
+ * Example:
+ *
+ * require 'thread'
+ *
+ * queue = Queue.new
+ *
+ * producer = Thread.new do
+ * 5.times do |i|
+ * sleep rand(i) # simulate expense
+ * queue << i
+ * puts "#{i} produced"
+ * end
+ * end
+ *
+ * consumer = Thread.new do
+ * 5.times do |i|
+ * value = queue.pop
+ * sleep rand(i/2) # simulate expense
+ * puts "consumed #{value}"
+ * end
+ * end
+ *
+ * consumer.join
+ *
+ */
+
+typedef struct _Queue {
+ Mutex mutex;
+ ConditionVariable value_available;
+ ConditionVariable space_available;
+ List values;
+ unsigned long capacity;
+} Queue;
+
+static void
+mark_queue(Queue *queue)
+{
+ mark_mutex(&queue->mutex);
+ mark_condvar(&queue->value_available);
+ mark_condvar(&queue->space_available);
+ mark_list(&queue->values);
+}
+
+static void
+finalize_queue(Queue *queue)
+{
+ finalize_mutex(&queue->mutex);
+ finalize_condvar(&queue->value_available);
+ finalize_condvar(&queue->space_available);
+ finalize_list(&queue->values);
+}
+
+static void
+free_queue(Queue *queue)
+{
+ assert_no_survivors(&queue->mutex.waiting, "queue", queue);
+ assert_no_survivors(&queue->space_available.waiting, "queue", queue);
+ assert_no_survivors(&queue->value_available.waiting, "queue", queue);
+ finalize_queue(queue);
+ xfree(queue);
+}
+
+static void
+init_queue(Queue *queue)
+{
+ init_mutex(&queue->mutex);
+ init_condvar(&queue->value_available);
+ init_condvar(&queue->space_available);
+ init_list(&queue->values);
+ queue->capacity = 0;
+}
+
+/*
+ * Document-method: new
+ * call-seq: new
+ *
+ * Creates a new queue.
+ *
+ */
+
+static VALUE
+rb_queue_alloc(VALUE klass)
+{
+ Queue *queue;
+ queue = ALLOC(Queue);
+ init_queue(queue);
+ return Data_Wrap_Struct(klass, mark_queue, free_queue, queue);
+}
+
+static VALUE
+rb_queue_marshal_load(VALUE self, VALUE data)
+{
+ Queue *queue;
+ VALUE array;
+ Data_Get_Struct(self, Queue, queue);
+
+ array = rb_marshal_load(data);
+ if (TYPE(array) != T_ARRAY) {
+ rb_raise(rb_eTypeError, "expected Array of queue data");
+ }
+ if (RARRAY(array)->len < 1) {
+ rb_raise(rb_eArgError, "missing capacity value");
+ }
+ queue->capacity = NUM2ULONG(rb_ary_shift(array));
+ push_multiple_list(&queue->values, RARRAY(array)->ptr, (unsigned)RARRAY(array)->len);
+
+ return self;
+}
+
+static VALUE
+rb_queue_marshal_dump(VALUE self)
+{
+ Queue *queue;
+ VALUE array;
+ Data_Get_Struct(self, Queue, queue);
+
+ array = array_from_list(&queue->values);
+ rb_ary_unshift(array, ULONG2NUM(queue->capacity));
+ return rb_marshal_dump(array, Qnil);
+}
+
+/*
+ * Document-method: clear
+ * call-seq: clear
+ *
+ * Removes all objects from the queue.
+ *
+ */
+
+static VALUE
+rb_queue_clear(VALUE self)
+{
+ Queue *queue;
+ Data_Get_Struct(self, Queue, queue);
+
+ lock_mutex(&queue->mutex);
+ clear_list(&queue->values);
+ signal_condvar(&queue->space_available);
+ unlock_mutex(&queue->mutex);
+
+ return self;
+}
+
+/*
+ * Document-method: empty?
+ * call-seq: empty?
+ *
+ * Returns +true+ if the queue is empty.
+ *
+ */
+
+static VALUE
+rb_queue_empty_p(VALUE self)
+{
+ Queue *queue;
+ VALUE result;
+ Data_Get_Struct(self, Queue, queue);
+
+ lock_mutex(&queue->mutex);
+ result = queue->values.size == 0 ? Qtrue : Qfalse;
+ unlock_mutex(&queue->mutex);
+
+ return result;
+}
+
+/*
+ * Document-method: length
+ * call-seq: length
+ *
+ * Returns the length of the queue.
+ *
+ */
+
+static VALUE
+rb_queue_length(VALUE self)
+{
+ Queue *queue;
+ VALUE result;
+ Data_Get_Struct(self, Queue, queue);
+
+ lock_mutex(&queue->mutex);
+ result = ULONG2NUM(queue->values.size);
+ unlock_mutex(&queue->mutex);
+
+ return result;
+}
+
+/*
+ * Document-method: num_waiting
+ * call-seq: num_waiting
+ *
+ * Returns the number of threads waiting on the queue.
+ *
+ */
+
+static VALUE
+rb_queue_num_waiting(VALUE self)
+{
+ Queue *queue;
+ VALUE result;
+ Data_Get_Struct(self, Queue, queue);
+
+ lock_mutex(&queue->mutex);
+ result = ULONG2NUM(queue->value_available.waiting.size +
+ queue->space_available.waiting.size);
+ unlock_mutex(&queue->mutex);
+
+ return result;
+}
+
+/*
+ * Document-method: pop
+ * call_seq: pop(non_block=false)
+ *
+ * Retrieves data from the queue. If the queue is empty, the calling thread is
+ * suspended until data is pushed onto the queue. If +non_block+ is true, the
+ * thread isn't suspended, and an exception is raised.
+ *
+ */
+
+static VALUE
+rb_queue_pop(int argc, VALUE *argv, VALUE self)
+{
+ Queue *queue;
+ int should_block;
+ VALUE result;
+ Data_Get_Struct(self, Queue, queue);
+
+ if (argc == 0) {
+ should_block = 1;
+ } else if (argc == 1) {
+ should_block = !RTEST(argv[0]);
+ } else {
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)", argc);
+ }
+
+ lock_mutex(&queue->mutex);
+ if (!queue->values.entries && !should_block) {
+ unlock_mutex(&queue->mutex);
+ rb_raise(rb_eThreadError, "queue empty");
+ }
+
+ while (!queue->values.entries) {
+ wait_condvar(&queue->value_available, &queue->mutex);
+ }
+
+ result = shift_list(&queue->values);
+ if (queue->capacity && queue->values.size < queue->capacity) {
+ signal_condvar(&queue->space_available);
+ }
+ unlock_mutex(&queue->mutex);
+
+ return result;
+}
+
+/*
+ * Document-method: push
+ * call-seq: push(obj)
+ *
+ * Pushes +obj+ to the queue.
+ *
+ */
+
+static VALUE
+rb_queue_push(VALUE self, VALUE value)
+{
+ Queue *queue;
+ Data_Get_Struct(self, Queue, queue);
+
+ lock_mutex(&queue->mutex);
+ while (queue->capacity && queue->values.size >= queue->capacity) {
+ wait_condvar(&queue->space_available, &queue->mutex);
+ }
+ push_list(&queue->values, value);
+ signal_condvar(&queue->value_available);
+ unlock_mutex(&queue->mutex);
+
+ return self;
+}
+
+/*
+ * Document-class: SizedQueue
+ *
+ * This class represents queues of specified size capacity. The push operation
+ * may be blocked if the capacity is full.
+ *
+ * See Queue for an example of how a SizedQueue works.
+ *
+ */
+
+/*
+ * Document-method: new
+ * call-seq: new
+ *
+ * Creates a fixed-length queue with a maximum size of +max+.
+ *
+ */
+
+/*
+ * Document-method: max
+ * call-seq: max
+ *
+ * Returns the maximum size of the queue.
+ *
+ */
+
+static VALUE
+rb_sized_queue_max(VALUE self)
+{
+ Queue *queue;
+ VALUE result;
+ Data_Get_Struct(self, Queue, queue);
+
+ lock_mutex(&queue->mutex);
+ result = ULONG2NUM(queue->capacity);
+ unlock_mutex(&queue->mutex);
+
+ return result;
+}
+
+/*
+ * Document-method: max=
+ * call-seq: max=(size)
+ *
+ * Sets the maximum size of the queue.
+ *
+ */
+
+static VALUE
+rb_sized_queue_max_set(VALUE self, VALUE value)
+{
+ Queue *queue;
+ unsigned long new_capacity;
+ unsigned long difference;
+ Data_Get_Struct(self, Queue, queue);
+
+ new_capacity = NUM2ULONG(value);
+
+ if (new_capacity < 1) {
+ rb_raise(rb_eArgError, "value must be positive");
+ }
+
+ lock_mutex(&queue->mutex);
+ if (queue->capacity && new_capacity > queue->capacity) {
+ difference = new_capacity - queue->capacity;
+ } else {
+ difference = 0;
+ }
+ queue->capacity = new_capacity;
+ for (; difference > 0; --difference) {
+ signal_condvar(&queue->space_available);
+ }
+ unlock_mutex(&queue->mutex);
+
+ return self;
+}
+
+/*
+ * Document-method: push
+ * call-seq: push(obj)
+ *
+ * Pushes +obj+ to the queue. If there is no space left in the queue, waits
+ * until space becomes available.
+ *
+ */
+
+/*
+ * Document-method: pop
+ * call-seq: pop(non_block=false)
+ *
+ * Retrieves data from the queue and runs a waiting thread, if any.
+ *
+ */
+
+/* for marshalling mutexes and condvars */
+
+static VALUE
+dummy_load(VALUE self, VALUE string)
+{
+ return Qnil;
+}
+
+static VALUE
+dummy_dump(VALUE self)
+{
+ return rb_str_new2("");
+}
+
+void
+Init_thread(void)
+{
+ rb_define_singleton_method(rb_cThread, "exclusive", rb_thread_exclusive, 0);
+
+ rb_cMutex = rb_define_class("Mutex", rb_cObject);
+ rb_define_alloc_func(rb_cMutex, rb_mutex_alloc);
+ rb_define_method(rb_cMutex, "marshal_load", dummy_load, 1);
+ rb_define_method(rb_cMutex, "marshal_dump", dummy_dump, 0);
+ rb_define_method(rb_cMutex, "locked?", rb_mutex_locked_p, 0);
+ rb_define_method(rb_cMutex, "try_lock", rb_mutex_try_lock, 0);
+ rb_define_method(rb_cMutex, "lock", rb_mutex_lock, 0);
+ rb_define_method(rb_cMutex, "unlock", rb_mutex_unlock, 0);
+ rb_define_method(rb_cMutex, "exclusive_unlock", rb_mutex_exclusive_unlock, 0);
+ rb_define_method(rb_cMutex, "synchronize", rb_mutex_synchronize, 0);
+
+ rb_cConditionVariable = rb_define_class("ConditionVariable", rb_cObject);
+ rb_define_alloc_func(rb_cConditionVariable, rb_condvar_alloc);
+ rb_define_method(rb_cConditionVariable, "marshal_load", dummy_load, 1);
+ rb_define_method(rb_cConditionVariable, "marshal_dump", dummy_dump, 0);
+ rb_define_method(rb_cConditionVariable, "wait", rb_condvar_wait, 1);
+ rb_define_method(rb_cConditionVariable, "broadcast", rb_condvar_broadcast, 0);
+ rb_define_method(rb_cConditionVariable, "signal", rb_condvar_signal, 0);
+
+ rb_cQueue = rb_define_class("Queue", rb_cObject);
+ rb_define_alloc_func(rb_cQueue, rb_queue_alloc);
+ rb_define_method(rb_cQueue, "marshal_load", rb_queue_marshal_load, 1);
+ rb_define_method(rb_cQueue, "marshal_dump", rb_queue_marshal_dump, 0);
+ rb_define_method(rb_cQueue, "clear", rb_queue_clear, 0);
+ rb_define_method(rb_cQueue, "empty?", rb_queue_empty_p, 0);
+ rb_define_method(rb_cQueue, "length", rb_queue_length, 0);
+ rb_define_method(rb_cQueue, "num_waiting", rb_queue_num_waiting, 0);
+ rb_define_method(rb_cQueue, "pop", rb_queue_pop, -1);
+ rb_define_method(rb_cQueue, "push", rb_queue_push, 1);
+ rb_alias(rb_cQueue, rb_intern("enq"), rb_intern("push"));
+ rb_alias(rb_cQueue, rb_intern("<<"), rb_intern("push"));
+ rb_alias(rb_cQueue, rb_intern("deq"), rb_intern("pop"));
+ rb_alias(rb_cQueue, rb_intern("shift"), rb_intern("pop"));
+ rb_alias(rb_cQueue, rb_intern("size"), rb_intern("length"));
+
+ rb_cSizedQueue = rb_define_class("SizedQueue", rb_cQueue);
+ rb_define_method(rb_cSizedQueue, "initialize", rb_sized_queue_max_set, 1);
+ rb_define_method(rb_cSizedQueue, "num_waiting", rb_queue_num_waiting, 0);
+ rb_define_method(rb_cSizedQueue, "pop", rb_queue_pop, -1);
+ rb_define_method(rb_cSizedQueue, "push", rb_queue_push, 1);
+ rb_define_method(rb_cSizedQueue, "max", rb_sized_queue_max, 0);
+ rb_define_method(rb_cSizedQueue, "max=", rb_sized_queue_max_set, 1);
+ rb_alias(rb_cSizedQueue, rb_intern("enq"), rb_intern("push"));
+ rb_alias(rb_cSizedQueue, rb_intern("<<"), rb_intern("push"));
+ rb_alias(rb_cSizedQueue, rb_intern("deq"), rb_intern("pop"));
+ rb_alias(rb_cSizedQueue, rb_intern("shift"), rb_intern("pop"));
+}
+
diff --git a/ext/tk/ChangeLog.tkextlib b/ext/tk/ChangeLog.tkextlib
index fa5524da01..359b466a32 100644
--- a/ext/tk/ChangeLog.tkextlib
+++ b/ext/tk/ChangeLog.tkextlib
@@ -1,3 +1,63 @@
+2007-05-26 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib/tkextlib/tcllib/tablelist.rb: fix typo.
+
+ * ext/tk/lib/tkextlib/tile/dialog.rb: forget to give an argument.
+
+ * ext/tk/lib/tkextlib/version.rb: update RELEASE_DATE.
+
+2007-01-26 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib/tkextlib/iwidgets/checkbox.rb: wrong number of arguments
+ [ruby-Bugs-7776].
+
+ * ext/tk/lib/tkextlib/iwidgets/radiobox.rb: ditto.
+
+ * ext/tk/lib/tkextlib/blt/tile/checkbutton.rb: change primary name
+ of class [ruby-dev:30080].
+
+ * ext/tk/lib/tkextlib/blt/tile/radiobutton.rb: ditto.
+
+2006-11-07 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/tile/treeview.rb : minor bug fix.
+
+ * lib/tkextlib/blt/table.rb: fix bugs which forbade use of
+ '::blt::table' command. Now, probably, it'll works properly.
+
+2006-11-06 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/version.rb: keep release date of tkextlib on
+ "Tk::Tkextlib_RELEASE_DATE".
+
+ * lib/tkextlib/tile/treeview.rb : support Tile 0.7.8.
+ Now, you can handle tree items as objects.
+
+2006-10-04 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/tile.rb, lib/tkextlib/tile/* : support Tile 0.7.6.
+
+2006-10-03 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/SUPPORT_STATUS: [ruby-talk:211939] check links
+ of extensions.
+
+ * lib/tkextlib/blt/container.rb: define instance methods properly.
+
+ * lib/tkextlib/tile/tcombobox.rb: bug fix [ruby-talk:213003].
+
+ * lib/tkextlib/tile/tnotebook.rb: ditto.
+
+ * lib/tkextlib/tile/treeview.rb: ditto.
+
+ * lib/tkextlib/tile/sizegrip.rb: [new] add 'ttk::sizegrip' widget.
+
+2006-08-31 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/blt.rb: double dashes (--) option doesn't work
+ properly on some versions of BLT (wrong description on the
+ manual of `blt::bgexec'?).
+
2005-12-11 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* lib/tkextlib/SUPPORT_STATUS: update to support libraries in
diff --git a/ext/tk/README.tcltklib b/ext/tk/README.tcltklib
index 5d1da48a45..e939ba1f51 100644
--- a/ext/tk/README.tcltklib
+++ b/ext/tk/README.tcltklib
@@ -41,6 +41,15 @@ some or all of the following options.
(e.g. "/Library/Frameworks/Tk.framework/Headers")
+ --with-X11 / --without-X11 use / not use the X Window System
+
+ --with-X11-dir=<path>
+ equal to "--with-X11-include=<path>/include --with-X11-lib=<path>/lib"
+
+ --with-X11-include=<dir> the directry contains X11 header files
+ --with-X11-lib=<dir> the directry contains X11 libraries
+
+
If you forgot to give the options when do 'configure' on toplevel
directry of Ruby sources, please try something like as the followings.
diff --git a/ext/tk/extconf.rb b/ext/tk/extconf.rb
index 8c8d833481..5ed86a8b76 100644
--- a/ext/tk/extconf.rb
+++ b/ext/tk/extconf.rb
@@ -47,6 +47,8 @@ tklib = with_config("tklib")
tcllib = with_config("tcllib")
stubs = enable_config("tcltk_stubs") || with_config("tcltk_stubs")
+use_X = with_config("X11", (! is_win32))
+
def find_tcl(tcllib, stubs)
paths = ["/usr/local/lib", "/usr/pkg/lib", "/usr/lib"]
if stubs
@@ -273,8 +275,9 @@ end
if tcltk_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")) &&
+ ( !use_X || find_library("X11", "XOpenDisplay",
+ "/usr/X11/lib", "/usr/lib/X11",
+ "/usr/X11R6/lib", "/usr/openwin/lib")) &&
find_tcl(tcllib, stubs) &&
find_tk(tklib, stubs))
$CPPFLAGS += ' -DUSE_TCL_STUBS -DUSE_TK_STUBS' if stubs
diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb
index eba2f72f29..32b5e20bc5 100644
--- a/ext/tk/lib/tk.rb
+++ b/ext/tk/lib/tk.rb
@@ -1,6 +1,6 @@
#
# tk.rb - Tk interface module using tcltklib
-# $Date: 2006/07/14 04:10:49 $
+# $Date$
# by Yukihiro Matsumoto <matz@netlab.jp>
# use Shigehiro's tcltklib
@@ -2829,7 +2829,7 @@ module TkConfigMethod
def __confinfo_cmd
__config_cmd
end
- private :__config_cmd
+ private :__confinfo_cmd
def __configinfo_struct
{:key=>0, :alias=>1, :db_name=>1, :db_class=>2,
@@ -2926,6 +2926,7 @@ module TkConfigMethod
}
keys2
end
+ private :__conv_keyonly_opts
def config_hash_kv(keys, enc_mode = nil, conf = nil)
hash_kv(__conv_keyonly_opts(keys), enc_mode, conf)
@@ -4597,7 +4598,7 @@ end
#Tk.freeze
module Tk
- RELEASE_DATE = '2006-07-14'.freeze
+ RELEASE_DATE = '2007-01-26'.freeze
autoload :AUTO_PATH, 'tk/variable'
autoload :TCL_PACKAGE_PATH, 'tk/variable'
@@ -4609,6 +4610,7 @@ end
# call setup script for Tk extension libraries (base configuration)
begin
+ require 'tkextlib/version.rb'
require 'tkextlib/setup.rb'
rescue LoadError
# ignore
diff --git a/ext/tk/lib/tk/after.rb b/ext/tk/lib/tk/after.rb
index 24a048ee32..8c58210331 100644
--- a/ext/tk/lib/tk/after.rb
+++ b/ext/tk/lib/tk/after.rb
@@ -1,6 +1,6 @@
#
# tk/after.rb : methods for Tcl/Tk after command
#
-# $Id: after.rb,v 1.1.2.1 2004/05/01 16:09:49 nagai Exp $
+# $Id$
#
require 'tk/timer'
diff --git a/ext/tk/lib/tk/canvas.rb b/ext/tk/lib/tk/canvas.rb
index 0f55bff4ed..c30fd79bb9 100644
--- a/ext/tk/lib/tk/canvas.rb
+++ b/ext/tk/lib/tk/canvas.rb
@@ -1,6 +1,6 @@
#
# tk/canvas.rb - Tk canvas classes
-# $Date: 2005/10/24 00:07:00 $
+# $Date$
# by Yukihiro Matsumoto <matz@caelum.co.jp>
#
require 'tk'
@@ -42,7 +42,7 @@ end
class TkCanvas<TkWindow
include TkCanvasItemConfig
- include Scrollable
+ include Tk::Scrollable
TkCommandNames = ['canvas'.freeze].freeze
WidgetClassName = 'Canvas'.freeze
@@ -543,8 +543,8 @@ class TkCanvas<TkWindow
tk_send_without_enc('scan', 'mark', x, y)
self
end
- def scan_dragto(x, y)
- tk_send_without_enc('scan', 'dragto', x, y)
+ def scan_dragto(x, y, gain=None)
+ tk_send_without_enc('scan', 'dragto', x, y, gain)
self
end
diff --git a/ext/tk/lib/tk/entry.rb b/ext/tk/lib/tk/entry.rb
index e4d69eb7bf..4ac3f28229 100644
--- a/ext/tk/lib/tk/entry.rb
+++ b/ext/tk/lib/tk/entry.rb
@@ -1,6 +1,6 @@
#
# tk/entry.rb - Tk entry classes
-# $Date: 2005/10/22 22:16:24 $
+# $Date$
# by Yukihiro Matsumoto <matz@caelum.co.jp>
require 'tk'
diff --git a/ext/tk/lib/tk/font.rb b/ext/tk/lib/tk/font.rb
index de02d4957c..ab58ac5762 100644
--- a/ext/tk/lib/tk/font.rb
+++ b/ext/tk/lib/tk/font.rb
@@ -1449,7 +1449,7 @@ module TkFont::CoreMethods
end
else
l = tk_split_simplelist(tk_call('font', 'configure', font))
- r = {}
+ h = {}
while key=l.shift
if key == '-compound'
l.shift
@@ -1458,15 +1458,15 @@ module TkFont::CoreMethods
val = l.shift
case TkFont::OptionType[key]
when ?n
- r.push [key, num_or_str(val)]
+ h[key] = num_or_str(val)
when ?b
- r.push [key, bool(val)]
+ h[key] = bool(val)
else
- r.push [key, val]
+ h[key] = val
end
end
end
- r
+ h
end
end
diff --git a/ext/tk/lib/tk/itemconfig.rb b/ext/tk/lib/tk/itemconfig.rb
index 0b84be38b8..a7885e74f3 100644
--- a/ext/tk/lib/tk/itemconfig.rb
+++ b/ext/tk/lib/tk/itemconfig.rb
@@ -289,7 +289,7 @@ module TkItemConfigMethod
self
end
- def itemconfiginfo(tagOrId, slot = nil)
+ def __itemconfiginfo_core(tagOrId, slot = nil)
if TkComm::GET_CONFIGINFO_AS_ARRAY
if (slot && slot.to_s =~ /^(|latin|ascii|kanji)(#{__item_font_optkeys(tagid(tagOrId)).join('|')})$/)
fontkey = $2
@@ -594,7 +594,7 @@ module TkItemConfigMethod
if v.empty?
conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
else
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = TkVarAccess.new
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = TkVarAccess.new(v)
end
end
@@ -1020,13 +1020,18 @@ module TkItemConfigMethod
end
end
end
+ private :__itemconfiginfo_core
+
+ def itemconfiginfo(tagOrId, slot = nil)
+ __itemconfiginfo_core(tagOrId, slot)
+ end
def current_itemconfiginfo(tagOrId, slot = nil)
if TkComm::GET_CONFIGINFO_AS_ARRAY
if slot
org_slot = slot
begin
- conf = itemconfiginfo(tagOrId, slot)
+ conf = __itemconfiginfo_core(tagOrId, slot)
if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \
|| conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
return {conf[0] => conf[-1]}
@@ -1037,7 +1042,7 @@ module TkItemConfigMethod
"there is a configure alias loop about '#{org_slot}'"
else
ret = {}
- itemconfiginfo(tagOrId).each{|conf|
+ __itemconfiginfo_core(tagOrId).each{|conf|
if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \
|| conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
ret[conf[0]] = conf[-1]
@@ -1047,7 +1052,7 @@ module TkItemConfigMethod
end
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
ret = {}
- itemconfiginfo(slot).each{|key, conf|
+ __itemconfiginfo_core(tagOrId, slot).each{|key, conf|
ret[key] = conf[-1] if conf.kind_of?(Array)
}
ret
diff --git a/ext/tk/lib/tk/scrollable.rb b/ext/tk/lib/tk/scrollable.rb
index ec27b76467..96959b7a4b 100644
--- a/ext/tk/lib/tk/scrollable.rb
+++ b/ext/tk/lib/tk/scrollable.rb
@@ -4,7 +4,7 @@
require 'tk'
module Tk
- module X_Scrollable
+ module XScrollable
def xscrollcommand(cmd=Proc.new)
configure_cmd 'xscrollcommand', cmd
# Tk.update # avoid scrollbar trouble
@@ -38,7 +38,7 @@ module Tk
end
end
- module Y_Scrollable
+ module YScrollable
def yscrollcommand(cmd=Proc.new)
configure_cmd 'yscrollcommand', cmd
# Tk.update # avoid scrollbar trouble
@@ -72,8 +72,11 @@ module Tk
end
end
+ X_Scrollable = XScrollable
+ Y_Scrollable = YScrollable
+
module Scrollable
- include X_Scrollable
- include Y_Scrollable
+ include XScrollable
+ include YScrollable
end
end
diff --git a/ext/tk/lib/tk/scrollbox.rb b/ext/tk/lib/tk/scrollbox.rb
index 833505be17..fd04057fb6 100644
--- a/ext/tk/lib/tk/scrollbox.rb
+++ b/ext/tk/lib/tk/scrollbox.rb
@@ -1,7 +1,7 @@
#
# tk/scrollbox.rb - Tk Listbox with Scrollbar
# as an example of Composite Widget
-# $Date: 2004/10/11 04:51:07 $
+# $Date$
# by Yukihiro Matsumoto <matz@netlab.co.jp>
#
require 'tk'
diff --git a/ext/tk/lib/tk/spinbox.rb b/ext/tk/lib/tk/spinbox.rb
index 1eed4d1dc4..9a10977d12 100644
--- a/ext/tk/lib/tk/spinbox.rb
+++ b/ext/tk/lib/tk/spinbox.rb
@@ -1,6 +1,6 @@
#
# tk/spinbox.rb - Tk spinbox classes
-# $Date: 2005/10/22 22:16:24 $
+# $Date$
# by Yukihiro Matsumoto <matz@caelum.co.jp>
#
require 'tk'
diff --git a/ext/tk/lib/tk/text.rb b/ext/tk/lib/tk/text.rb
index 0db10a653f..49d4b5625b 100644
--- a/ext/tk/lib/tk/text.rb
+++ b/ext/tk/lib/tk/text.rb
@@ -1,6 +1,6 @@
#
# tk/text.rb - Tk text classes
-# $Date: 2005/11/23 12:01:05 $
+# $Date$
# by Yukihiro Matsumoto <matz@caelum.co.jp>
require 'tk'
require 'tk/itemfont'
diff --git a/ext/tk/lib/tk/timer.rb b/ext/tk/lib/tk/timer.rb
index 49b7f1b06a..47f2b79350 100644
--- a/ext/tk/lib/tk/timer.rb
+++ b/ext/tk/lib/tk/timer.rb
@@ -1,7 +1,7 @@
#
# tk/timer.rb : methods for Tcl/Tk after command
#
-# $Id: timer.rb,v 1.1.2.15 2005/05/08 14:20:53 nagai Exp $
+# $Id$
#
require 'tk'
diff --git a/ext/tk/lib/tk/txtwin_abst.rb b/ext/tk/lib/tk/txtwin_abst.rb
index 5520360eab..540f806d17 100644
--- a/ext/tk/lib/tk/txtwin_abst.rb
+++ b/ext/tk/lib/tk/txtwin_abst.rb
@@ -4,7 +4,7 @@
require 'tk'
class TkTextWin<TkWindow
- TkCommnadNames = [].freeze
+ TkCommandNames = [].freeze
#def create_self
# fail RuntimeError, "TkTextWin is an abstract class"
#end
diff --git a/ext/tk/lib/tkclass.rb b/ext/tk/lib/tkclass.rb
index 355b1a1b1d..87f5acc453 100644
--- a/ext/tk/lib/tkclass.rb
+++ b/ext/tk/lib/tkclass.rb
@@ -3,7 +3,7 @@
# Date: 2000/11/27 09:23:36
# by Yukihiro Matsumoto <matz@caelum.co.jp>
#
-# $Id: tkclass.rb,v 1.6.2.1 2004/10/11 04:51:06 nagai Exp $
+# $Id$
require "tk"
diff --git a/ext/tk/lib/tkextlib/SUPPORT_STATUS b/ext/tk/lib/tkextlib/SUPPORT_STATUS
index 8d7b6fc44a..15925cba72 100644
--- a/ext/tk/lib/tkextlib/SUPPORT_STATUS
+++ b/ext/tk/lib/tkextlib/SUPPORT_STATUS
@@ -1,7 +1,7 @@
[ current support status of Tcl/Tk extensions ]
- *******<<< RELEASE_DATE of the libraries : 2005/12/11 >>>*******
+ *** RELEASE_DATE of the libraries => see 'tkextlib/version.rb' ***
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
@@ -56,23 +56,23 @@ script may give you some hints about that.
===< support with some examples (may be beta quality) >=======================
Tcllib 1.8
-Tklib 0.4.1 http://sf.net/projects/tcllib ==> tcllib
+Tklib 0.4.1 http://sourceforge.net/projects/tcllib ==> tcllib
-IWidgets 4.0.2 http://sf.net/projects/incrTcl ==> iwidgets
+IWidgets 4.0.2 http://sourceforge.net/projects/incrtcl ==> iwidgets
-BWidgets 1.7 http://sf.net/projects/tcllib ==> bwidget
+BWidgets 1.7 http://sourceforge.net/projects/tcllib ==> bwidget
-TkTable 2.9 http://sf.net/projects/tktable ==> tktable
+TkTable 2.9 http://sourceforge.net/projects/tktable ==> tktable
* see also <http://www.korus.hu/~fery/ruby/tktable.rb>
written by Ferenc Engard (ferenc@engard.hu)
-vu 2.3.0 http://tktable.sourceforge.net ==> vu
+vu 2.3.0 http://sourceforge.net/projects/tktable ==> vu
-TkHTML 2.0 http://www.hwaci.com/sw/tkhtml/index.html ==> tkHTML
+TkHTML 2.0 http://www.hwaci.com/sw/tkhtml/ ==> tkHTML
ICONS 1.0 http://www.satisoft.com/tcltk/icons/ ==> ICONS
-TkImg 1.3 http://sf.net/projects/tkimg ==> tkimg
+TkImg 1.3 http://sourceforge.net/projects/tkimg ==> tkimg
BLT 2.4z http://sourceforge.net/projects/blt
@@ -81,20 +81,20 @@ BLT 2.4z http://sourceforge.net/projects/blt
==> blt
TkTreeCtrl CVS/Hd(2005-12-02)
- http://tktreectrl.sourceforge.net/ ==> treectrl
+ http://sourceforge.net/projects/tktreectrl ==> treectrl
-Tile CVS/Hd(2005-12-07)
- http://tktable.sourceforge.net/tile/ ==> tile
+Tile 0.7.8
+ http://sourceforge.net/projects/tktable ==> tile
===< support (may be alpha or beta quality) >=================================
IncrTcl CVS/Hd(2005-02-14)
- http://sf.net/projects/incrTcl ==> itcl, itk
+ http://sourceforge.net/projects/incrtcl ==> itcl, itk
TclX CVS/Hd(2005-02-07)
- http://sf.net/projects/tclx
+ http://sourceforge.net/projects/tclx
==> tclx (partial support; infox command and
XPG/3 message catalogs only)
@@ -105,7 +105,7 @@ Trofs 0.4.3 http://math.nist.gov/~DPorter/tcltk/trofs/
===< possibly available (not tested; alpha quality) >=========================
winico 0.6
- http://tktable.sourceforge.net
+ http://sourceforge.net/projects/tktable
==> winico (win32 only)
TkTrans latest(2004-10-11)
@@ -160,17 +160,17 @@ QuickTimeTcl *** http://hem.fyristorg.com/matben/qt/
===< may not support (already exist, out of Ruby/Tk scope, and so on) >=======
-TkCon *** http://sf.net/projects/tkcon
+TkCon *** http://sourceforge.net/projects/tkcon
-Expect *** http://sf.net/projects/expect
+Expect *** http://sourceforge.net/projects/expect
-TclXML *** http://sf.net/projects/tclxml
+TclXML *** http://sourceforge.net/projects/tclxml
-TclXSLT *** http://sf.net/projects/tclxml
+TclXSLT *** http://sourceforge.net/projects/tclxml
-TclDOM *** http://sf.net/projects/tclxml
+TclDOM *** http://sourceforge.net/projects/tclxml
-TclSOAP *** http://sf.net/projects/tclsoap
+TclSOAP *** http://sourceforge.net/projects/tclsoap
Snack *** http://www.speech.kth.se/~kare/snack2.2.tar.gz
* use Snack for Ruby
@@ -182,7 +182,7 @@ tDOM *** http://www.tdom.org
Mk4tcl *** http://www.equi4.com/metakit/tcl.html
-Memchan *** http://memchan.sourceforge.net/
+Memchan *** http://sourceforge.net/projects/memchan
XOTcl *** http://www.xotcl.org/
diff --git a/ext/tk/lib/tkextlib/blt.rb b/ext/tk/lib/tkextlib/blt.rb
index 8ac8605513..115eb927ba 100644
--- a/ext/tk/lib/tkextlib/blt.rb
+++ b/ext/tk/lib/tkextlib/blt.rb
@@ -68,7 +68,7 @@ module Tk
params.concat(hash_kv(args.shift, true)) if args[0].kind_of?(Hash)
- params << '--'
+ params << '--' if args[0] =~ /^\s*-[^-]/
params.concat(args)
tk_call('::blt::bgexec', *params)
@@ -85,7 +85,7 @@ module Tk
params.concat(hash_kv(args.shift, true)) if args[0].kind_of?(Hash)
- params << '--'
+ params << '--' if args[0] =~ /^\s*-[^-]/
params.concat(args)
params << '&'
diff --git a/ext/tk/lib/tkextlib/blt/container.rb b/ext/tk/lib/tkextlib/blt/container.rb
index 60ba1dec1e..cdbec21f25 100644
--- a/ext/tk/lib/tkextlib/blt/container.rb
+++ b/ext/tk/lib/tkextlib/blt/container.rb
@@ -11,18 +11,18 @@ module Tk::BLT
TkCommandNames = ['::blt::container'.freeze].freeze
WidgetClassName = 'Container'.freeze
WidgetClassNames[WidgetClassName] = self
- end
- def __strval_optkeys
- super() << 'name'
- end
- private :__strval_optkeys
+ def __strval_optkeys
+ super() << 'name'
+ end
+ private :__strval_optkeys
- def find_command(pat)
- list(tk_send_without_enc(tk_call(self.path, 'find', '-command', pat)))
- end
+ def find_command(pat)
+ Hash[*simplelist(tk_send_without_enc('find', '-command', pat))]
+ end
- def find_name(pat)
- list(tk_send_without_enc(tk_call(self.path, 'find', '-name', pat)))
+ def find_name(pat)
+ Hash[*simplelist(tk_send_without_enc('find', '-name', pat))]
+ end
end
end
diff --git a/ext/tk/lib/tkextlib/blt/table.rb b/ext/tk/lib/tkextlib/blt/table.rb
index fc1bf54e65..0be9d8d42a 100644
--- a/ext/tk/lib/tkextlib/blt/table.rb
+++ b/ext/tk/lib/tkextlib/blt/table.rb
@@ -17,97 +17,97 @@ module Tk::BLT
module TableContainer
def blt_table_add(*args)
- Tk::BLT::Table.add(@path, *args)
+ Tk::BLT::Table.add(self, *args)
self
end
def blt_table_arrange()
- Tk::BLT::Table.arrange(@path)
+ Tk::BLT::Table.arrange(self)
self
end
def blt_table_cget(*args)
- Tk::BLT::Table.cget(@path, *args)
+ Tk::BLT::Table.cget(self, *args)
end
def blt_table_configure(*args)
- Tk::BLT::Table.configure(@path, *args)
+ Tk::BLT::Table.configure(self, *args)
self
end
def blt_table_configinfo(*args)
- Tk::BLT::Table.configinfo(@path, *args)
+ Tk::BLT::Table.configinfo(self, *args)
end
def blt_table_current_configinfo(*args)
- Tk::BLT::Table.current_configinfo(@path, *args)
+ Tk::BLT::Table.current_configinfo(self, *args)
end
def blt_table_locate(x, y)
- Tk::BLT::Table.locate(@path, x, y)
+ Tk::BLT::Table.locate(self, x, y)
end
def blt_table_delete(*args)
- Tk::BLT::Table.delete(@path, *args)
+ Tk::BLT::Table.delete(self, *args)
self
end
def blt_table_extents(item)
- Tk::BLT::Table.extents(@path, item)
+ Tk::BLT::Table.extents(self, item)
end
def blt_table_insert(*args)
- Tk::BLT::Table.insert(@path, *args)
+ Tk::BLT::Table.insert(self, *args)
self
end
def blt_table_insert_before(*args)
- Tk::BLT::Table.insert_before(@path, *args)
+ Tk::BLT::Table.insert_before(self, *args)
self
end
def blt_table_insert_after(*args)
- Tk::BLT::Table.insert_after(@path, *args)
+ Tk::BLT::Table.insert_after(self, *args)
self
end
def blt_table_join(first, last)
- Tk::BLT::Table.join(@path, first, last)
+ Tk::BLT::Table.join(self, first, last)
self
end
def blt_table_save()
- Tk::BLT::Table.save(@path)
+ Tk::BLT::Table.save(self)
end
def blt_table_search(*args)
- Tk::BLT::Table.search(@path, *args)
+ Tk::BLT::Table.search(self, *args)
end
def blt_table_split(*args)
- Tk::BLT::Table.split(@path, *args)
+ Tk::BLT::Table.split(self, *args)
self
end
def blt_table_itemcget(*args)
- Tk::BLT::Table.itemcget(@path, *args)
+ Tk::BLT::Table.itemcget(self, *args)
end
def blt_table_itemconfigure(*args)
- Tk::BLT::Table.itemconfigure(@path, *args)
+ Tk::BLT::Table.itemconfigure(self, *args)
self
end
def blt_table_itemconfiginfo(*args)
- Tk::BLT::Table.itemconfiginfo(@path, *args)
+ Tk::BLT::Table.itemconfiginfo(self, *args)
end
def blt_table_current_itemconfiginfo(*args)
- Tk::BLT::Table.current_itemconfiginfo(@path, *args)
+ Tk::BLT::Table.current_itemconfiginfo(self, *args)
end
def blt_table_iteminfo(item)
- Tk::BLT::Table.iteminfo(@path, item)
+ Tk::BLT::Table.iteminfo(self, item)
end
end
end
@@ -117,18 +117,21 @@ end
############################################
class << Tk::BLT::Table
def __item_cget_cmd(id) # id := [ container, item ]
- ['::blt::table', 'cget', id[0].path, id[1]]
+ win = (id[0].kind_of?(TkWindow))? id[0].path: id[0].to_s
+ ['::blt::table', 'cget', win, id[1]]
end
private :__item_cget_cmd
def __item_config_cmd(id) # id := [ container, item, ... ]
container, *items = id
- ['::blt::table', 'configure', container.path, *items]
+ win = (container.kind_of?(TkWindow))? container.path: container.to_s
+ ['::blt::table', 'configure', win, *items]
end
private :__item_config_cmd
def __item_pathname(id)
- id[0].path + ';'
+ win = (id[0].kind_of?(TkWindow))? id[0].path: id[0].to_s
+ win + ';'
end
private :__item_pathname
@@ -194,6 +197,7 @@ class << Tk::BLT::Table
if args[-1].kind_of?(Hash)
# container, item, item, ... , hash_optkeys
keys = args.pop
+ fail ArgumentError, 'no item is given' if args.empty?
id = [container]
args.each{|item| id << tagid(item)}
__itemconfigure(id, keys)
@@ -201,10 +205,12 @@ class << Tk::BLT::Table
# container, item, item, ... , option, value
val = args.pop
opt = args.pop
+ fail ArgumentError, 'no item is given' if args.empty?
id = [container]
args.each{|item| id << tagid(item)}
__itemconfigure(id, opt, val)
end
+ container
end
def itemconfiginfo(container, *args)
@@ -222,11 +228,35 @@ class << Tk::BLT::Table
slot = nil
end
+ fail ArgumentError, 'no item is given' if args.empty?
+
id = [container]
args.each{|item| id << tagid(item)}
__itemconfiginfo(id, slot)
end
+ def current_itemconfiginfo(container, *args)
+ slot = args[-1]
+ if slot.kind_of?(String) || slot.kind_of?(Symbol)
+ slot = slot.to_s
+ if slot[0] == ?. || slot =~ /^\d+,\d+$/ || slot =~ /^(c|C|r|R)(\*|\d+)/
+ # widget || row,col || Ci or Ri
+ slot = nil
+ else
+ # option
+ slot = args.pop
+ end
+ else
+ slot = nil
+ end
+
+ fail ArgumentError, 'no item is given' if args.empty?
+
+ id = [container]
+ args.each{|item| id << tagid(item)}
+ __current_itemconfiginfo(id, slot)
+ end
+
def info(container)
ret = {}
inf = list(tk_call('::blt::table', 'info', container))
@@ -238,12 +268,22 @@ class << Tk::BLT::Table
end
def iteminfo(container, item)
- ret = {}
- inf = list(tk_call('::blt::table', 'info', container, tagid(item)))
- until inf.empty?
- opt = inf.slice!(0..1)
- ret[opt[1..-1]] = opt[1]
+ inf = list(tk_call('::blt::table', 'info', container, tagid(item)).chomp)
+
+ ret = []
+ until inf.empty? || (inf[0].kind_of?(String) && inf[0] =~ /^-/)
+ ret << inf.shift
+ end
+
+ if inf.length > 1
+ keys = {}
+ while inf.length > 1
+ opt = inf.slice!(0..1)
+ keys[opt[0][1..-1]] = opt[1]
+ end
+ ret << keys
end
+
ret
end
@@ -253,7 +293,7 @@ class << Tk::BLT::Table
tk_call('::blt::table', container)
begin
class << container
- include Tk::BLT::TABLE::TableContainer
+ include Tk::BLT::Table::TableContainer
end
rescue
warn('fail to include TableContainer methods (frozen object?)')
@@ -276,10 +316,12 @@ class << Tk::BLT::Table
}
tk_call('::blt::table', container, *args)
end
+ container
end
def arrange(container)
tk_call('::blt::table', 'arrange', container)
+ container
end
def delete(container, *args)
diff --git a/ext/tk/lib/tkextlib/blt/tile/checkbutton.rb b/ext/tk/lib/tkextlib/blt/tile/checkbutton.rb
index ebe79179a5..ad58999d86 100644
--- a/ext/tk/lib/tkextlib/blt/tile/checkbutton.rb
+++ b/ext/tk/lib/tkextlib/blt/tile/checkbutton.rb
@@ -9,9 +9,9 @@ require 'tkextlib/blt/tile.rb'
module Tk::BLT
module Tile
- class Checkbutton < TkCheckbutton
+ class CheckButton < TkCheckButton
TkCommandNames = ['::blt::tile::checkbutton'.freeze].freeze
end
- CheckButton = Checkbutton
+ Checkbutton = CheckButton
end
end
diff --git a/ext/tk/lib/tkextlib/blt/tile/radiobutton.rb b/ext/tk/lib/tkextlib/blt/tile/radiobutton.rb
index 7573aa08d6..2316923b19 100644
--- a/ext/tk/lib/tkextlib/blt/tile/radiobutton.rb
+++ b/ext/tk/lib/tkextlib/blt/tile/radiobutton.rb
@@ -9,9 +9,9 @@ require 'tkextlib/blt/tile.rb'
module Tk::BLT
module Tile
- class Radiobutton < TkRadiobutton
+ class RadioButton < TkRadioButton
TkCommandNames = ['::blt::tile::radiobutton'.freeze].freeze
end
- RadioButton = Radiobutton
+ Radiobutton = RadioButton
end
end
diff --git a/ext/tk/lib/tkextlib/iwidgets/checkbox.rb b/ext/tk/lib/tkextlib/iwidgets/checkbox.rb
index abd23299a8..46ca389db2 100644
--- a/ext/tk/lib/tkextlib/iwidgets/checkbox.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/checkbox.rb
@@ -87,7 +87,7 @@ class Tk::Iwidgets::Checkbox
def get(idx)
simplelist(tk_call(@path, 'get', index(idx))).collect{|id|
- Tk::Itk::Component.id2obj(id)
+ Tk::Itk::Component.id2obj(self, id)
}
end
diff --git a/ext/tk/lib/tkextlib/iwidgets/radiobox.rb b/ext/tk/lib/tkextlib/iwidgets/radiobox.rb
index d4316754f2..1a2821bd6a 100644
--- a/ext/tk/lib/tkextlib/iwidgets/radiobox.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/radiobox.rb
@@ -87,7 +87,7 @@ class Tk::Iwidgets::Radiobox
def get(idx)
simplelist(tk_call(@path, 'get', index(idx))).collect{|id|
- Tk::Itk::Component.id2obj(id)
+ Tk::Itk::Component.id2obj(self, id)
}
end
diff --git a/ext/tk/lib/tkextlib/tcllib/tablelist.rb b/ext/tk/lib/tkextlib/tcllib/tablelist.rb
index 42435a1971..efeb8fbbac 100644
--- a/ext/tk/lib/tkextlib/tcllib/tablelist.rb
+++ b/ext/tk/lib/tkextlib/tcllib/tablelist.rb
@@ -23,5 +23,5 @@ else
# TkPackage.require('Tablelist', '4.2')
TkPackage.require('Tablelist')
- requrie 'tkextlib/tcllib/tablelist_core'
+ require 'tkextlib/tcllib/tablelist_core'
end
diff --git a/ext/tk/lib/tkextlib/tile.rb b/ext/tk/lib/tkextlib/tile.rb
index 690f93f029..acc7bebe4e 100644
--- a/ext/tk/lib/tkextlib/tile.rb
+++ b/ext/tk/lib/tkextlib/tile.rb
@@ -158,6 +158,11 @@ module Tk
list(tk_send('state'))
end
end
+
+ def identify(x, y)
+ ret = tk_send_without_enc('identify', x, y)
+ (ret.empty?)? nil: ret
+ end
end
######################################
diff --git a/ext/tk/lib/tkextlib/tile/dialog.rb b/ext/tk/lib/tkextlib/tile/dialog.rb
index f8ddf62598..b10378d7de 100644
--- a/ext/tk/lib/tkextlib/tile/dialog.rb
+++ b/ext/tk/lib/tkextlib/tile/dialog.rb
@@ -51,7 +51,7 @@ class Tk::Tile::Dialog
alias display show
def client_frame
- window(tk_call_without_enc('::ttk::dialog::clientframe'))
+ window(tk_call_without_enc('::ttk::dialog::clientframe', @path))
end
def cget(slot)
diff --git a/ext/tk/lib/tkextlib/tile/sizegrip.rb b/ext/tk/lib/tkextlib/tile/sizegrip.rb
new file mode 100644
index 0000000000..ea796583b0
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tile/sizegrip.rb
@@ -0,0 +1,25 @@
+#
+# ttk::sizegrip widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class SizeGrip < TkWindow
+ end
+ end
+end
+
+class Tk::Tile::SizeGrip < TkWindow
+ include Tk::Tile::TileWidget
+
+ TkCommandNames = ['::ttk::sizegrip'.freeze].freeze
+ WidgetClassName = 'TSizegrip'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+end
diff --git a/ext/tk/lib/tkextlib/tile/style.rb b/ext/tk/lib/tkextlib/tile/style.rb
index 485a36d7d6..59bc4b0d78 100644
--- a/ext/tk/lib/tkextlib/tile/style.rb
+++ b/ext/tk/lib/tkextlib/tile/style.rb
@@ -52,6 +52,10 @@ class << Tk::Tile::Style
end
end
+ def lookup(style, opt, state=None, fallback_value=None)
+ tk_call('style', 'lookup', style, '-' << opt.to_s, state, fallback_value)
+ end
+
include Tk::Tile::ParseStyleLayout
def layout(style=nil, spec=nil)
diff --git a/ext/tk/lib/tkextlib/tile/tcombobox.rb b/ext/tk/lib/tkextlib/tile/tcombobox.rb
index c63ab94dbe..e8e042fbd9 100644
--- a/ext/tk/lib/tkextlib/tile/tcombobox.rb
+++ b/ext/tk/lib/tkextlib/tile/tcombobox.rb
@@ -39,16 +39,12 @@ class Tk::Tile::TCombobox < Tk::Tile::TEntry
end
def current
- number(tk_send_without_enc('current', idx))
+ number(tk_send_without_enc('current'))
end
def current=(idx)
tk_send_without_enc('current', idx)
end
- def identify(x, y)
- tk_send_without_enc('identify', x, y)
- end
-
def set(val)
tk_send('set', val)
end
diff --git a/ext/tk/lib/tkextlib/tile/tnotebook.rb b/ext/tk/lib/tkextlib/tile/tnotebook.rb
index abaed8ee9c..a928e64b61 100644
--- a/ext/tk/lib/tkextlib/tile/tnotebook.rb
+++ b/ext/tk/lib/tkextlib/tile/tnotebook.rb
@@ -27,15 +27,15 @@ class Tk::Tile::TNotebook < TkWindow
end
private :__item_config_cmd
- def __item_listval_optkeys
+ def __item_listval_optkeys(id)
[]
end
private :__item_listval_optkeys
- def __item_methodcall_optkeys # { key=>method, ... }
+ def __item_methodcall_optkeys(id) # { key=>method, ... }
{}
end
- private :__item_listval_optkeys
+ private :__item_methodcall_optkeys
#alias tabcget itemcget
alias tabconfigure itemconfigure
@@ -104,6 +104,10 @@ class Tk::Tile::TNotebook < TkWindow
self
end
+ def selected
+ window(tk_send_without_enc('select'))
+ end
+
def tabs
list(tk_send('tabs'))
end
diff --git a/ext/tk/lib/tkextlib/tile/treeview.rb b/ext/tk/lib/tkextlib/tile/treeview.rb
index d3ffbbfa6b..68e478896c 100644
--- a/ext/tk/lib/tkextlib/tile/treeview.rb
+++ b/ext/tk/lib/tkextlib/tile/treeview.rb
@@ -9,129 +9,898 @@ module Tk
module Tile
class Treeview < TkWindow
end
+ end
+end
- module TreeviewConfig
- include TkItemConfigMethod
+module Tk::Tile::TreeviewConfig
+ include TkItemConfigMethod
- def __item_cget_cmd(id)
- [self.path, id[0], id[1]]
- end
- private :__item_cget_cmd
+ def __item_configinfo_struct(id)
+ # maybe need to override
+ {:key=>0, :alias=>nil, :db_name=>nil, :db_class=>nil,
+ :default_value=>nil, :current_value=>1}
+ end
+ private :__item_configinfo_struct
- def __item_config_cmd(id)
- [self.path, id[0], id[1]]
- end
- private :__item_config_cmd
-
- def __item_numstrval_optkeys(id)
- case id[0]
- when :item, 'item'
- ['width']
- when :column, 'column'
- super(id[1])
- when :heading, 'heading'
- super(id[1])
- end
- end
- private :__item_numstrval_optkeys
-
- def __item_strval_optkeys(id)
- case id[0]
- when :item, 'item'
- super(id) + ['id']
- when :column, 'column'
- super(id[1])
- when :heading, 'heading'
- super(id[1])
- end
- end
- private :__item_strval_optkeys
-
- def __item_boolval_optkeys(id)
- case id[0]
- when :item, 'item'
- ['open']
- when :column, 'column'
- super(id[1])
- when :heading, 'heading'
- super(id[1])
+ def __itemconfiginfo_core(tagOrId, slot = nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if (slot && slot.to_s =~ /^(|latin|ascii|kanji)(#{__item_font_optkeys(tagid(tagOrId)).join('|')})$/)
+ fontkey = $2
+ return [slot.to_s, tagfontobj(tagid(tagOrId), fontkey)]
+ else
+ if slot
+ slot = slot.to_s
+ case slot
+ when /^(#{__tile_specific_item_optkeys(tagid(tagOrId)).join('|')})$/
+ begin
+ # On tile-0.7.{2-8}, 'state' options has no '-' at its head.
+ val = tk_call(*(__item_confinfo_cmd(tagid(tagOrId)) << slot))
+ rescue
+ # Maybe, 'state' option has '-' in future.
+ val = tk_call(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ end
+ return [slot, val]
+
+ when /^(#{__item_val2ruby_optkeys(tagid(tagOrId)).keys.join('|')})$/
+ method = _symbolkey2str(__item_val2ruby_optkeys(tagid(tagOrId)))[slot]
+ optval = tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ begin
+ val = method.call(tagOrId, optval)
+ rescue => e
+ warn("Warning:: #{e.message} (when #{method}lcall(#{tagOrId.inspect}, #{optval.inspect})") if $DEBUG
+ val = optval
+ end
+ return [slot, val]
+
+ 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('|')})$/
+ begin
+ val = number(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")))
+ rescue
+ val = nil
+ end
+ return [slot, val]
+
+ when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/
+ val = num_or_str(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")))
+ return [slot, val]
+
+ when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/
+ begin
+ val = bool(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")))
+ rescue
+ val = nil
+ end
+ return [slot, val]
+
+ when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/
+ val = simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")))
+ return [slot, val]
+
+ when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/
+ val = tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ if val =~ /^[0-9]/
+ return [slot, list(val)]
+ else
+ return [slot, val]
+ end
+
+ when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/
+ val = tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ return [slot, val]
+
+ when /^(#{__item_tkvariable_optkeys(tagid(tagOrId)).join('|')})$/
+ val = tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ if val.empty?
+ return [slot, nil]
+ else
+ return [slot, TkVarAccess.new(val)]
+ end
+
+ else
+ val = tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ if val.index('{')
+ return [slot, tk_split_list(val)]
+ else
+ return [slot, tk_tcl2ruby(val)]
+ end
+ end
+
+ else # ! slot
+ ret = Hash[*(tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)))), false, false))].to_a.collect{|conf|
+ conf[0] = conf[0][1..-1] if conf[0][0] == ?-
+ case conf[0]
+ when /^(#{__item_val2ruby_optkeys(tagid(tagOrId)).keys.join('|')})$/
+ method = _symbolkey2str(__item_val2ruby_optkeys(tagid(tagOrId)))[conf[0]]
+ optval = conf[1]
+ begin
+ val = method.call(tagOrId, optval)
+ rescue => e
+ warn("Warning:: #{e.message} (when #{method}.call(#{tagOrId.inspect}, #{optval.inspect})") if $DEBUG
+ val = optval
+ end
+ conf[1] = val
+
+ when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/
+ # do nothing
+
+ when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/
+ begin
+ conf[1] = number(conf[1])
+ rescue
+ conf[1] = nil
+ end
+
+ when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf[1] = num_or_str(conf[1])
+
+ when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/
+ begin
+ conf[1] = bool(conf[1])
+ rescue
+ conf[1] = nil
+ end
+
+ when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf[1] = simplelist(conf[1])
+
+ when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/
+ if conf[1] =~ /^[0-9]/
+ conf[1] = list(conf[1])
+ end
+
+ when /^(#{__item_tkvariable_optkeys(tagid(tagOrId)).join('|')})$/
+ if conf[1].empty?
+ conf[1] = nil
+ else
+ conf[1] = TkVarAccess.new(conf[1])
+ end
+
+ else
+ if conf[1].index('{')
+ conf[1] = tk_split_list(conf[1])
+ else
+ conf[1] = tk_tcl2ruby(conf[1])
+ end
+ end
+
+ conf
+ }
+
+ __item_font_optkeys(tagid(tagOrId)).each{|optkey|
+ optkey = optkey.to_s
+ fontconf = ret.assoc(optkey)
+ if fontconf
+ ret.delete_if{|inf| inf[0] =~ /^(|latin|ascii|kanji)#{optkey}$/}
+ fontconf[1] = 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
- private :__item_boolval_optkeys
-
- def __item_listval_optkeys(id)
- case id[0]
- when :item, 'item'
- ['values']
- when :column, 'column'
- []
- when :heading, 'heading'
- []
+
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ if (slot && slot.to_s =~ /^(|latin|ascii|kanji)(#{__item_font_optkeys(tagid(tagOrId)).join('|')})$/)
+ fontkey = $2
+ return {slot.to_s => tagfontobj(tagid(tagOrId), fontkey)}
+ else
+ if slot
+ slot = slot.to_s
+ case slot
+ when /^(#{__tile_specific_item_optkeys(tagid(tagOrId)).join('|')})$/
+ begin
+ # On tile-0.7.{2-8}, 'state' option has no '-' at its head.
+ val = tk_call(*(__item_confinfo_cmd(tagid(tagOrId)) << slot))
+ rescue
+ # Maybe, 'state' option has '-' in future.
+ val = tk_call(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ end
+ return {slot => val}
+
+ when /^(#{__item_val2ruby_optkeys(tagid(tagOrId)).keys.join('|')})$/
+ method = _symbolkey2str(__item_val2ruby_optkeys(tagid(tagOrId)))[slot]
+ optval = tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ begin
+ val = method.call(tagOrId, optval)
+ rescue => e
+ warn("Warning:: #{e.message} (when #{method}lcall(#{tagOrId.inspect}, #{optval.inspect})") if $DEBUG
+ val = optval
+ end
+ return {slot => val}
+
+ 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('|')})$/
+ begin
+ val = number(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")))
+ rescue
+ val = nil
+ end
+ return {slot => val}
+
+ when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/
+ val = num_or_str(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")))
+ return {slot => val}
+
+ when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/
+ begin
+ val = bool(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")))
+ rescue
+ val = nil
+ end
+ return {slot => val}
+
+ when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/
+ val = simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")))
+ return {slot => val}
+
+ when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/
+ val = tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ if val =~ /^[0-9]/
+ return {slot => list(val)}
+ else
+ return {slot => val}
+ end
+
+ when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/
+ val = tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ return {slot => val}
+
+ when /^(#{__item_tkvariable_optkeys(tagid(tagOrId)).join('|')})$/
+ val = tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ if val.empty?
+ return {slot => nil}
+ else
+ return {slot => TkVarAccess.new(val)}
+ end
+
+ else
+ val = tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ if val.index('{')
+ return {slot => tk_split_list(val)}
+ else
+ return {slot => tk_tcl2ruby(val)}
+ end
+ end
+
+ else # ! slot
+ ret = {}
+ ret = Hash[*(tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)))), false, false))].to_a.collect{|conf|
+ conf[0] = conf[0][1..-1] if conf[0][0] == ?-
+
+ optkey = conf[0]
+ case optkey
+ when /^(#{__item_val2ruby_optkeys(tagid(tagOrId)).keys.join('|')})$/
+ method = _symbolkey2str(__item_val2ruby_optkeys(tagid(tagOrId)))[optkey]
+ optval = conf[1]
+ begin
+ val = method.call(tagOrId, optval)
+ rescue => e
+ warn("Warning:: #{e.message} (when #{method}.call(#{tagOrId.inspect}, #{optval.inspect})") if $DEBUG
+ val = optval
+ end
+ conf[1] = val
+
+ when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/
+ # do nothing
+
+ when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/
+ begin
+ conf[1] = number(conf[1])
+ rescue
+ conf[1] = nil
+ end
+
+ when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf[1] = num_or_str(conf[1])
+
+ when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/
+ begin
+ conf[1] = bool(conf[1])
+ rescue
+ conf[1] = nil
+ end
+
+ when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf[1] = simplelist(conf[1])
+
+ when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/
+ if conf[1] =~ /^[0-9]/
+ conf[1] = list(conf[1])
+ end
+
+ when /^(#{__item_tkvariable_optkeys(tagid(tagOrId)).join('|')})$/
+ if conf[1].empty?
+ conf[1] = nil
+ else
+ conf[1] = TkVarAccess.new(conf[1])
+ end
+
+ else
+ if conf[1].index('{')
+ return [slot, tk_split_list(conf[1])]
+ else
+ return [slot, tk_tcl2ruby(conf[1])]
+ end
+ end
+
+ ret[conf[0]] = conf[1]
+ }
+
+ __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[1] = 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
- private :__item_listval_optkeys
+ end
+ end
- alias __itemcget itemcget
- alias __itemconfigure itemconfigure
- alias __itemconfiginfo itemconfiginfo
- alias __current_itemconfiginfo current_itemconfiginfo
+ ###################
- private :__itemcget, :__itemconfigure
- private :__itemconfiginfo, :__current_itemconfiginfo
+ def __item_cget_cmd(id)
+ [self.path, id[0], id[1]]
+ end
+ private :__item_cget_cmd
- # Treeview Item
- def itemcget(tagOrId, option)
- __itemcget([:item, tagOrId], option)
- end
- def itemconfigure(tagOrId, slot, value=None)
- __itemconfigure([:item, tagOrId], slot, value)
- end
- def itemconfiginfo(tagOrId, slot=nil)
- __itemconfiginfo([:item, tagOrId], slot)
- end
- def current_itemconfiginfo(tagOrId, slot=nil)
- __current_itemconfiginfo([:item, tagOrId], slot)
- end
+ def __item_config_cmd(id)
+ [self.path, id[0], id[1]]
+ end
+ private :__item_config_cmd
- # Treeview Column
- def columncget(tagOrId, option)
- __itemcget([:column, tagOrId], option)
- end
- def columnconfigure(tagOrId, slot, value=None)
- __itemconfigure([:column, tagOrId], slot, value)
- end
- def columnconfiginfo(tagOrId, slot=nil)
- __itemconfiginfo([:column, tagOrId], slot)
- end
- def current_columnconfiginfo(tagOrId, slot=nil)
- __current_itemconfiginfo([:column, tagOrId], slot)
- end
- alias column_cget columncget
- alias column_configure columnconfigure
- alias column_configinfo columnconfiginfo
- alias current_column_configinfo current_columnconfiginfo
-
- # Treeview Heading
- def headingcget(tagOrId, option)
- __itemcget([:heading, tagOrId], option)
- end
- def headingconfigure(tagOrId, slot, value=None)
- __itemconfigure([:heading, tagOrId], slot, value)
+ def __item_numstrval_optkeys(id)
+ case id[0]
+ when :item, 'item'
+ ['width']
+ when :column, 'column'
+ super(id[1])
+ when :tag, 'tag'
+ super(id[1])
+ when :heading, 'heading'
+ super(id[1])
+ else
+ super(id[1])
+ end
+ end
+ private :__item_numstrval_optkeys
+
+ def __item_strval_optkeys(id)
+ case id[0]
+ when :item, 'item'
+ super(id) + ['id']
+ when :column, 'column'
+ super(id[1])
+ when :tag, 'tag'
+ super(id[1])
+ when :heading, 'heading'
+ super(id[1])
+ else
+ super(id[1])
+ end
+ end
+ private :__item_strval_optkeys
+
+ def __item_boolval_optkeys(id)
+ case id[0]
+ when :item, 'item'
+ ['open']
+ when :column, 'column'
+ super(id[1])
+ when :tag, 'tag'
+ super(id[1])
+ when :heading, 'heading'
+ super(id[1])
+ end
+ end
+ private :__item_boolval_optkeys
+
+ def __item_listval_optkeys(id)
+ case id[0]
+ when :item, 'item'
+ ['values']
+ when :column, 'column'
+ []
+ when :heading, 'heading'
+ []
+ else
+ []
+ end
+ end
+ private :__item_listval_optkeys
+
+ def __item_val2ruby_optkeys(id)
+ case id[0]
+ when :item, 'item'
+ {
+ 'tags'=>proc{|arg_id, val|
+ simplelist(val).collect{|tag|
+ Tk::Tile::Treeview::Tag.id2obj(self, tag)
+ }
+ }
+ }
+ when :column, 'column'
+ {}
+ when :heading, 'heading'
+ {}
+ else
+ {}
+ end
+ end
+ private :__item_val2ruby_optkeys
+
+ def __tile_specific_item_optkeys(id)
+ case id[0]
+ when :item, 'item'
+ []
+ when :column, 'column'
+ []
+ when :heading, 'heading'
+ ['state'] # On tile-0.7.{2-8}, 'state' options has no '-' at its head.
+ else
+ []
+ end
+ end
+ private :__item_val2ruby_optkeys
+
+ def itemconfiginfo(tagOrId, slot = nil)
+ __itemconfiginfo_core(tagOrId, slot)
+ end
+
+ def current_itemconfiginfo(tagOrId, slot = nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ org_slot = slot
+ begin
+ conf = __itemconfiginfo_core(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_core(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
- def headingconfiginfo(tagOrId, slot=nil)
- __itemconfiginfo([:heading, tagOrId], slot)
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ ret = {}
+ __itemconfiginfo_core(tagOrId, slot).each{|key, conf|
+ ret[key] = conf[-1] if conf.kind_of?(Array)
+ }
+ ret
+ end
+ end
+
+ alias __itemcget itemcget
+ alias __itemconfigure itemconfigure
+ alias __itemconfiginfo itemconfiginfo
+ alias __current_itemconfiginfo current_itemconfiginfo
+
+ private :__itemcget, :__itemconfigure
+ private :__itemconfiginfo, :__current_itemconfiginfo
+
+ # Treeview Item
+ def itemcget(tagOrId, option)
+ __itemcget([:item, tagOrId], option)
+ end
+ def itemconfigure(tagOrId, slot, value=None)
+ __itemconfigure([:item, tagOrId], slot, value)
+ end
+ def itemconfiginfo(tagOrId, slot=nil)
+ __itemconfiginfo([:item, tagOrId], slot)
+ end
+ def current_itemconfiginfo(tagOrId, slot=nil)
+ __current_itemconfiginfo([:item, tagOrId], slot)
+ end
+
+ # Treeview Column
+ def columncget(tagOrId, option)
+ __itemcget([:column, tagOrId], option)
+ end
+ def columnconfigure(tagOrId, slot, value=None)
+ __itemconfigure([:column, tagOrId], slot, value)
+ end
+ def columnconfiginfo(tagOrId, slot=nil)
+ __itemconfiginfo([:column, tagOrId], slot)
+ end
+ def current_columnconfiginfo(tagOrId, slot=nil)
+ __current_itemconfiginfo([:column, tagOrId], slot)
+ end
+ alias column_cget columncget
+ alias column_configure columnconfigure
+ alias column_configinfo columnconfiginfo
+ alias current_column_configinfo current_columnconfiginfo
+
+ # Treeview Heading
+ def headingcget(tagOrId, option)
+ if __tile_specific_item_optkeys([:heading, tagOrId]).index(option.to_s)
+ begin
+ # On tile-0.7.{2-8}, 'state' options has no '-' at its head.
+ tk_call(*(__item_cget_cmd([:heading, tagOrId]) << option.to_s))
+ rescue
+ # Maybe, 'state' option has '-' in future.
+ tk_call(*(__item_cget_cmd([:heading, tagOrId]) << "-#{option}"))
end
- def current_headingconfiginfo(tagOrId, slot=nil)
- __current_itemconfiginfo([:heading, tagOrId], slot)
+ else
+ __itemcget([:heading, tagOrId], option)
+ end
+ end
+ def headingconfigure(tagOrId, slot, value=None)
+ if slot.kind_of?(Hash)
+ slot = _symbolkey2str(slot)
+ sp_kv = []
+ __tile_specific_item_optkeys([:heading, tagOrId]).each{|k|
+ sp_kv << k << _get_eval_string(slot.delete(k)) if slot.has_key?(k)
+ }
+ tk_call(*(__item_config_cmd([:heading, tagOrId]).concat(sp_kv)))
+ tk_call(*(__item_config_cmd([:heading, tagOrId]).concat(hash_kv(slot))))
+ elsif __tile_specific_item_optkeys([:heading, tagOrId]).index(slot.to_s)
+ begin
+ # On tile-0.7.{2-8}, 'state' options has no '-' at its head.
+ tk_call(*(__item_cget_cmd([:heading, tagOrId]) << slot.to_s << value))
+ rescue
+ # Maybe, 'state' option has '-' in future.
+ tk_call(*(__item_cget_cmd([:heading, tagOrId]) << "-#{slot}" << value))
end
- alias heading_cget headingcget
- alias heading_configure headingconfigure
- alias heading_configinfo headingconfiginfo
- alias current_heading_configinfo current_headingconfiginfo
+ else
+ __itemconfigure([:heading, tagOrId], slot, value)
+ end
+ self
+ end
+ def headingconfiginfo(tagOrId, slot=nil)
+ __itemconfiginfo([:heading, tagOrId], slot)
+ end
+ def current_headingconfiginfo(tagOrId, slot=nil)
+ __current_itemconfiginfo([:heading, tagOrId], slot)
+ end
+ alias heading_cget headingcget
+ alias heading_configure headingconfigure
+ alias heading_configinfo headingconfiginfo
+ alias current_heading_configinfo current_headingconfiginfo
+
+ # Treeview Tag
+ def tagcget(tagOrId, option)
+ __itemcget([:tag, tagOrId], option)
+ end
+ def tagconfigure(tagOrId, slot, value=None)
+ __itemconfigure([:tag, tagOrId], slot, value)
+ end
+ def tagconfiginfo(tagOrId, slot=nil)
+ __itemconfiginfo([:tag, tagOrId], slot)
+ end
+ def current_tagconfiginfo(tagOrId, slot=nil)
+ __current_itemconfiginfo([:tag, tagOrId], slot)
+ end
+ alias tag_cget tagcget
+ alias tag_configure tagconfigure
+ alias tag_configinfo tagconfiginfo
+ alias current_tag_configinfo current_tagconfiginfo
+end
+
+########################
+
+class Tk::Tile::Treeview::Item < TkObject
+ ItemID_TBL = TkCore::INTERP.create_table
+ TkCore::INTERP.init_ip_env{ Tk::Tile::Treeview::Item::ItemID_TBL.clear }
+
+ def self.id2obj(tree, id)
+ tpath = tree.path
+ return id unless Tk::Tile::Treeview::Item::ItemID_TBL[tpath]
+ (Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id])? \
+ Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id]: id
+ end
+
+ def self.assign(tree, id)
+ tpath = tree.path
+ if Tk::Tile::Treeview::Item::ItemID_TBL[tpath] &&
+ Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id]
+ return Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id]
+ end
+
+ obj = self.allocate
+ obj.instance_eval{
+ @parent = @t = tree
+ @tpath = tpath
+ @path = @id = id
+ }
+ ItemID_TBL[tpath] = {} unless ItemID_TBL[tpath]
+ Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id] = obj
+ obj
+ end
+
+ def _insert_item(tree, parent_item, idx, keys={})
+ keys = _symbolkey2str(keys)
+ id = keys.delete('id')
+ if id
+ num_or_str(tk_call(tree, 'insert',
+ parent_item, idx, '-id', id, *hash_kv(keys)))
+ else
+ num_or_str(tk_call(tree, 'insert', parent_item, idx, *hash_kv(keys)))
+ end
+ end
+ private :_insert_item
+
+ def initialize(tree, parent_item = '', idx = 'end', keys = {})
+ if parent_item.kind_of?(Hash)
+ keys = parent_item
+ idx = 'end'
+ parent_item = ''
+ elsif idx.kind_of?(Hash)
+ keys = idx
+ idx = 'end'
+ end
+
+ @parent = @t = tree
+ @tpath = tree.path
+ @path = @id = _insert_item(@t, parent_item, idx, keys)
+ ItemID_TBL[@tpath] = {} unless ItemID_TBL[@tpath]
+ ItemID_TBL[@tpath][@id] = self
+ end
+ def id
+ @id
+ end
+
+ def cget(option)
+ @t.itemcget(@id, option)
+ end
+
+ def configure(key, value=None)
+ @t.itemconfigure(@id, key, value)
+ self
+ end
+
+ def configinfo(key=nil)
+ @t.itemconfiginfo(@id, key)
+ end
+
+ def current_configinfo(key=nil)
+ @t.current_itemconfiginfo(@id, key)
+ end
+
+ def open?
+ cget('open')
+ end
+ def open
+ configure('open', true)
+ self
+ end
+ def close
+ configure('open', false)
+ self
+ end
+
+ def bbox(column=None)
+ @t.bbox(@id, column)
+ end
+
+ def children
+ @t.children(@id)
+ end
+ def set_children(*items)
+ @t.set_children(@id, *items)
+ self
+ end
+
+ def delete
+ @t.delete(@id)
+ self
+ end
+
+ def detach
+ @t.detach(@id)
+ self
+ end
+
+ def exist?
+ @t.exist?(@id)
+ end
+
+ def focus
+ @t.focus_item(@id)
+ end
+
+ def index
+ @t.index(@id)
+ end
+
+ def insert(idx='end', keys={})
+ @t.insert(@id, idx, keys)
+ end
+
+ def move(parent, idx)
+ @t.move(@id, parent, idx)
+ self
+ end
+
+ def next_item
+ @t.next_item(@id)
+ end
+
+ def parent_item
+ @t.parent_item(@id)
+ end
+
+ def prev_item
+ @t.prev_item(@id)
+ end
+
+ def see
+ @t.see(@id)
+ self
+ end
+
+ def selection_add
+ @t.selection_add(@id)
+ self
+ end
+
+ def selection_remove
+ @t.selection_remove(@id)
+ self
+ end
+
+ def selection_set
+ @t.selection_set(@id)
+ self
+ end
+
+ def selection_toggle
+ @t.selection_toggle(@id)
+ self
+ end
+
+ def get_directory
+ @t.get_directory(@id)
+ end
+ alias get_dictionary get_directory
+
+ def get(col)
+ @t.get(@id, col)
+ end
+
+ def set(col, value)
+ @t.set(@id, col, value)
+ end
+end
+
+########################
+
+class Tk::Tile::Treeview::Root < Tk::Tile::Treeview::Item
+ def self.new(tree, keys = {})
+ tpath = tree.path
+ if Tk::Tile::Treeview::Item::ItemID_TBL[tpath] &&
+ Tk::Tile::Treeview::Item::ItemID_TBL[tpath]['']
+ Tk::Tile::Treeview::Item::ItemID_TBL[tpath]['']
+ else
+ super(tree, keys)
+ end
+ end
+
+ def initialize(tree, keys = {})
+ @parent = @t = tree
+ @tpath = tree.path
+ @path = @id = ''
+ unless Tk::Tile::Treeview::Item::ItemID_TBL[@tpath]
+ Tk::Tile::Treeview::Item::ItemID_TBL[@tpath] = {}
+ end
+ Tk::Tile::Treeview::Item::ItemID_TBL[@tpath][@id] = self
+ end
+end
+
+########################
+
+class Tk::Tile::Treeview::Tag < TkObject
+ include TkTreatTagFont
+
+ TagID_TBL = TkCore::INTERP.create_table
+ Tag_ID = ['tile_treeview_tag'.freeze, '00000'.taint].freeze
+
+ TkCore::INTERP.init_ip_env{ Tk::Tile::Treeview::Tag::TagID_TBL.clear }
+
+ def self.id2obj(tree, id)
+ tpath = tree.path
+ return id unless Tk::Tile::Treeview::Tag::TagID_TBL[tpath]
+ (Tk::Tile::Treeview::Tag::TagID_TBL[tpath][id])? \
+ Tk::Tile::Treeview::Tag::TagID_TBL[tpath][id]: id
+ end
+
+ def initialize(tree, keys=nil)
+ @parent = @t = tree
+ @tpath = tree.path
+ @path = @id = Tag_ID.join(TkCore::INTERP._ip_id_)
+ TagID_TBL[@tpath] = {} unless TagID_TBL[@tpath]
+ TagID_TBL[@tpath][@id] = self
+ Tag_ID[1].succ!
+ if keys && keys != None
+ tk_call_without_enc(@tpath, 'tag', 'configure', *hash_kv(keys, true))
end
end
+ def id
+ @id
+ end
+
+ def bind(seq, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ @t.tag_bind(@id, seq, cmd, *args)
+ self
+ end
+
+ def bind_append(seq, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ @t.tag_bind_append(@id, seq, cmd, *args)
+ self
+ end
+
+ def bind_remove(seq)
+ @t.tag_bind_remove(@id, seq)
+ self
+ end
+
+ def bindinfo(seq=nil)
+ @t.tag_bindinfo(@id, seq)
+ end
+
+ def cget(option)
+ @t.tagcget(@id, option)
+ end
+
+ def configure(key, value=None)
+ @t.tagconfigure(@id, key, value)
+ self
+ end
+
+ def configinfo(key=nil)
+ @t.tagconfiginfo(@id, key)
+ end
+
+ def current_configinfo(key=nil)
+ @t.current_tagconfiginfo(@id, key)
+ end
end
+########################
+
class Tk::Tile::Treeview < TkWindow
include Tk::Tile::TileWidget
include Scrollable
@@ -146,20 +915,38 @@ class Tk::Tile::Treeview < TkWindow
WidgetClassName = 'Treeview'.freeze
WidgetClassNames[WidgetClassName] = self
+ def __destroy_hook__
+ Tk::Tile::Treeview::Item::ItemID_TBL.delete(@path)
+ Tk::Tile::Treeview::Tag::ItemID_TBL.delete(@path)
+ end
+
def self.style(*args)
[self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
end
def tagid(id)
- if id.kind_of?(Array)
+ if id.kind_of?(Tk::Tile::Treeview::Item) ||
+ id.kind_of?(Tk::Tile::Treeview::Tag)
+ id.id
+ elsif id.kind_of?(Array)
[id[0], _get_eval_string(id[1])]
else
_get_eval_string(id)
end
end
+ def root
+ Tk::Tile::Treeview::Root.new(self)
+ end
+
+ def bbox(item, column=None)
+ list(tk_send('item', 'bbox', item, column))
+ end
+
def children(item)
- simplelist(tk_send_without_enc('children', item))
+ simplelist(tk_send_without_enc('children', item)).collect{|id|
+ Tk::Tile::Treeview::Item.id2obj(self, id)
+ }
end
def set_children(item, *items)
tk_send_without_enc('children', item,
@@ -181,55 +968,84 @@ class Tk::Tile::Treeview < TkWindow
bool(tk_send_without_enc('exists', _get_eval_enc_str(item)))
end
- def focus_item(item = None)
- tk_send('focus', item)
+ def focus_item(item = nil)
+ if item
+ tk_send('focus', item)
+ item
+ else
+ id = tk_send('focus')
+ (id.empty?)? nil: Tk::Tile::Treeview::Item.id2obj(self, id)
+ end
end
def identify(x, y)
+ # tile-0.7.2 or previous
ret = simplelist(tk_send('identify', x, y))
case ret[0]
- when 'heading', 'separator', 'cell'
+ when 'heading', 'separator'
ret[-1] = num_or_str(ret[-1])
+ when 'cell'
+ ret[1] = Tk::Tile::Treeview::Item.id2obj(self, ret[1])
+ ret[-1] = num_or_str(ret[-1])
+ when 'item', 'row'
+ ret[1] = Tk::Tile::Treeview::Item.id2obj(self, ret[1])
end
end
- def index(item)
- number(tk_send('index', item))
+ def row_identify(x, y)
+ id = tk_send('identify', 'row', x, y)
+ (id.empty?)? nil: Tk::Tile::Treeview::Item.id2obj(self, id)
end
- def insert(parent, idx, keys={})
- keys = _symbolkey2str(keys)
- id = keys.delete('id')
- if id
- tk_send('insert', parent, idx, '-id', id, *hash_kv(keys))
- else
- tk_send('insert', parent, idx, *hash_kv(keys))
- end
- self
+ def column_identify(x, y)
+ tk_send('identify', 'column', x, y)
end
- def instate(spec, cmd=Proc.new)
- tk_send('instate', spec, cmd)
+ def index(item)
+ number(tk_send('index', item))
end
- def state(spec=None)
- tk_send('state', spec)
+
+ # def insert(parent, idx='end', keys={})
+ # keys = _symbolkey2str(keys)
+ # id = keys.delete('id')
+ # if id
+ # num_or_str(tk_send('insert', parent, idx, '-id', id, *hash_kv(keys)))
+ # else
+ # num_or_str(tk_send('insert', parent, idx, *hash_kv(keys)))
+ # end
+ # end
+ def insert(parent, idx='end', keys={})
+ Tk::Tile::Treeview::Item.new(self, parent, idx, keys)
end
+ # def instate(spec, cmd=Proc.new)
+ # tk_send('instate', spec, cmd)
+ # end
+ # def state(spec=None)
+ # tk_send('state', spec)
+ # end
+
def move(item, parent, idx)
tk_send('move', item, parent, idx)
self
end
- def next(item)
- tk_send('next', item)
+ def next_item(item)
+ id = tk_send('next', item)
+ (id.empty?)? nil: Tk::Tile::Treeview::Item.id2obj(self, id)
end
- def parent(item)
- tk_send('parent', item)
+ def parent_item(item)
+ if (id = tk_send('parent', item)).empty?
+ Tk::Tile::Treeview::Root.new(self)
+ else
+ Tk::Tile::Treeview::Item.id2obj(self, id)
+ end
end
- def prev(item)
- tk_send('prev', item)
+ def prev_item(item)
+ id = tk_send('prev', item)
+ (id.empty?)? nil: Tk::Tile::Treeview::Item.id2obj(self, id)
end
def see(item)
@@ -238,7 +1054,9 @@ class Tk::Tile::Treeview < TkWindow
end
def selection
- simplelist(tk_send('selection'))
+ simplelist(tk_send('selection')).collect{|id|
+ Tk::Tile::Treeview::Item.id2obj(self, id)
+ }
end
alias selection_get selection
@@ -270,6 +1088,8 @@ class Tk::Tile::Treeview < TkWindow
end
ret
end
+ alias get_dictionary get_directory
+
def get(item, col)
tk_send('set', item, col)
end
@@ -277,4 +1097,37 @@ class Tk::Tile::Treeview < TkWindow
tk_send('set', item, col, value)
self
end
+
+ def tag_bind(tag, seq, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind([@path, 'tag', 'bind', tag], seq, cmd, *args)
+ self
+ end
+ alias tagbind tag_bind
+
+ def tag_bind_append(tag, seq, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append([@path, 'tag', 'bind', tag], seq, cmd, *args)
+ self
+ end
+ alias tagbind_append tag_bind_append
+
+ def tag_bind_remove(tag, seq)
+ _bind_remove([@path, 'tag', 'bind', tag], seq)
+ self
+ end
+ alias tagbind_remove tag_bind_remove
+
+ def tag_bindinfo(tag, context=nil)
+ _bindinfo([@path, 'tag', 'bind', tag], context)
+ end
+ alias tagbindinfo tag_bindinfo
end
diff --git a/ext/tk/lib/tkextlib/version.rb b/ext/tk/lib/tkextlib/version.rb
new file mode 100644
index 0000000000..c7816fd4a5
--- /dev/null
+++ b/ext/tk/lib/tkextlib/version.rb
@@ -0,0 +1,6 @@
+#
+# release date of tkextlib
+#
+module Tk
+ Tkextlib_RELEASE_DATE = '2007-05-26'.freeze
+end
diff --git a/ext/tk/sample/editable_listbox.rb b/ext/tk/sample/editable_listbox.rb
new file mode 100644
index 0000000000..99345da380
--- /dev/null
+++ b/ext/tk/sample/editable_listbox.rb
@@ -0,0 +1,69 @@
+#
+# Editable_TkListbox class
+#
+# When "DoubleClick-1" on a listbox item, the entry box is opend on the
+# item. And when hit "Return" key on the entry box after modifying the
+# text, the entry box is closed and the item is changed. Or when hit
+# "Escape" key, the entry box is closed without modification.
+#
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+class Editable_TkListbox < TkListbox
+ def _ebox_placer(coord_y)
+ idx = self.nearest(coord_y)
+ x, y, w, h = self.bbox(idx)
+ @ebox.place(:x => 0, :relwidth => 1.0,
+ :y => y - self.selectborderwidth,
+ :height => h + 2 * self.selectborderwidth)
+ @ebox.pos = idx
+ @ebox.value = self.listvariable.list[idx]
+ @ebox.focus
+ end
+ private :_ebox_placer
+
+
+ def create_self(keys)
+ super(keys)
+
+ unless self.listvariable
+ self.listvariable = TkVariable.new(self.get(0, :end))
+ end
+
+ @ebox = TkEntry.new(self){
+ @pos = -1
+ def self.pos; @pos; end
+ def self.pos=(idx); @pos = idx; end
+ }
+
+ @ebox.bind('Return'){
+ list = self.listvariable.list
+ list[@ebox.pos] = @ebox.value
+ self.listvariable.value = list
+ @ebox.place_forget
+ @ebox.pos = -1
+ }
+
+ @ebox.bind('Escape'){
+ @ebox.place_forget
+ @ebox.pos = -1
+ }
+
+ self.bind('Double-1', '%y'){|y| _ebox_placer(y) }
+ end
+end
+
+if $0 == __FILE__
+ scr = TkScrollbar.new.pack(:side=>:right, :fill=>:y)
+
+ lbox1 = Editable_TkListbox.new.pack(:side=>:left)
+ lbox2 = Editable_TkListbox.new.pack(:side=>:left)
+
+ scr.assign(lbox1, lbox2)
+
+ lbox1.insert(:end, *%w(a b c d e f g h i j k l m n))
+ lbox2.insert(:end, 0,1,2,3,4,5,6,7,8,9,0,1,2,3)
+
+ Tk.mainloop
+end
diff --git a/ext/tk/sample/images/teapot.ppm b/ext/tk/sample/images/teapot.ppm
index 78afefbf82..b8ab85f3a5 100644
--- a/ext/tk/sample/images/teapot.ppm
+++ b/ext/tk/sample/images/teapot.ppm
@@ -1,8 +1,7 @@
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
+\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À[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
@@ -13,44 +12,20 @@ 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
+^/ V+Q(L&I$r9  TlRMnSM46G47G47G46G46G46G46G46G36G36G25G25G15G04G/4F.3F
+
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%
-
-
+›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
+ 
+$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
!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[ 
+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 |>
+
+ &3#.$-% .% .& /&!,#,#@70A71XNHXNHWNHWNHZRLYQLYQLXQLWQLWPLUOLSNLQMKOLJMJJ0//.-.,,-&(+"(!'
+ %' %$#" ! !$ 
diff --git a/ext/tk/sample/irbtkw.rbw b/ext/tk/sample/irbtkw.rbw
new file mode 100644
index 0000000000..f6a35be6ed
--- /dev/null
+++ b/ext/tk/sample/irbtkw.rbw
@@ -0,0 +1,124 @@
+#!/usr/bin/env ruby
+#
+# irbtkw.rb : IRB console with Ruby/Tk
+#
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+release = '2006/11/06'
+
+require 'tk'
+begin
+ require 'tktextio'
+rescue LoadError
+ require File.join(File.dirname(File.expand_path(__FILE__)), 'tktextio.rb')
+end
+
+require 'irb'
+
+# console setup
+top = TkToplevel.new(:title=>'IRB console')
+top.protocol(:WM_DELETE_WINDOW){ Tk.exit }
+
+console = TkTextIO.new(top, :mode=>:console,
+ :width=>80).pack(:side=>:left,
+ :expand=>true, :fill=>:both)
+console.yscrollbar(TkScrollbar.new(top, :width=>10).pack(:before=>console,
+ :side=>:right,
+ :expand=>false,
+ :fill=>:y))
+irb_thread = nil
+ev_loop = Thread.new{
+ Tk.mainloop
+ irb_thread.kill if irb_thread
+}
+
+# window position control
+root = Tk.root
+
+r_x = root.winfo_rootx
+r_y = root.winfo_rooty
+r_w = root.winfo_width
+
+t_x = top.winfo_rootx
+t_y = top.winfo_rooty
+t_w = top.winfo_width
+
+delta = 10
+
+ratio = 0.8
+s_w = (ratio * root.winfo_screenwidth).to_i
+
+if r_x < t_x
+ r_x, t_x = t_x, r_x
+end
+if t_x + t_w + r_w + delta < s_w
+ r_x = t_x + t_w + delta
+elsif t_w + r_w + delta < s_w
+ r_x = s_w - r_w
+ t_x = r_x - t_w
+else
+ r_x = s_w - r_w
+ t_x = 0
+end
+
+root.geometry("+#{r_x}+#{r_y}")
+top.geometry("+#{t_x}+#{t_y}")
+
+root.raise
+console.focus
+
+# I/O setup
+$stdin = console
+$stdout = console
+$stderr = console
+
+# dummy for rubyw.exe on Windows
+def STDIN.tty?
+ true
+end
+
+# IRB setup
+IRB.init_config(nil)
+IRB.conf[:USE_READLINE] = false
+IRB.init_error
+irb = IRB::Irb.new
+IRB.conf[:MAIN_CONTEXT] = irb.context
+
+class IRB::StdioInputMethod
+ def gets
+ prompt = "\n" << @prompt
+ $stdin.instance_eval{
+ flush
+ @prompt = prompt
+ _set_console_line
+ @prompt = nil
+ _see_pos
+ }
+
+ @line[@line_no += 1] = $stdin.gets
+ end
+end
+
+# IRB start
+$stdout.print("*** IRB console on Ruby/Tk (#{release}) ")
+irb_thread = Thread.new{
+ catch(:IRB_EXIT){
+ loop {
+ begin
+ irb.eval_input
+ rescue Exception
+ end
+ }
+ }
+}
+
+console.bind('Control-c'){
+ console.insert('end', "^C\n")
+ irb_thread.raise RubyLex::TerminateLineInput
+}
+
+irb_thread.join
+
+# exit
+ev_thread.kill
+Tk.exit
diff --git a/ext/tk/sample/tkextlib/tile/repeater.tcl b/ext/tk/sample/tkextlib/tile/repeater.tcl
index 1f403de537..652ba8ab17 100644
--- a/ext/tk/sample/tkextlib/tile/repeater.tcl
+++ b/ext/tk/sample/tkextlib/tile/repeater.tcl
@@ -1,5 +1,5 @@
#
-# $Id: repeater.tcl,v 1.1.2.1 2005/08/02 06:51:26 ocean Exp $
+# $Id$
#
# Demonstration of custom classes.
#
diff --git a/ext/tk/sample/tkextlib/tile/themes/keramik/keramik.tcl b/ext/tk/sample/tkextlib/tile/themes/keramik/keramik.tcl
index c47a67b5a9..79fcd7c04e 100644
--- a/ext/tk/sample/tkextlib/tile/themes/keramik/keramik.tcl
+++ b/ext/tk/sample/tkextlib/tile/themes/keramik/keramik.tcl
@@ -5,7 +5,7 @@
# Copyright (c) 2004 Googie
# Copyright (c) 2004 Pat Thoyts <patthoyts@users.sourceforge.net>
#
-# $Id: keramik.tcl,v 1.1.2.1 2005/11/25 07:04:59 nagai Exp $
+# $Id$
package require Tk 8.4; # minimum version for Tile
package require tile 0.5; # depends upon tile 0.5
diff --git a/ext/tk/sample/tkextlib/tile/themes/keramik/pkgIndex.tcl b/ext/tk/sample/tkextlib/tile/themes/keramik/pkgIndex.tcl
index b66fa7fb31..4bb89aa8a5 100644
--- a/ext/tk/sample/tkextlib/tile/themes/keramik/pkgIndex.tcl
+++ b/ext/tk/sample/tkextlib/tile/themes/keramik/pkgIndex.tcl
@@ -6,7 +6,7 @@
# To use this automatically within tile, the tile-using application should
# use tile::availableThemes and tile::setTheme
#
-# $Id: pkgIndex.tcl,v 1.1.2.1 2005/11/25 07:04:59 nagai Exp $
+# $Id$
if {![file isdirectory [file join $dir keramik]]} { return }
if {![package vsatisfies [package provide Tcl] 8.4]} { return }
diff --git a/ext/tk/sample/tkextlib/tile/themes/kroc/pkgIndex.tcl b/ext/tk/sample/tkextlib/tile/themes/kroc/pkgIndex.tcl
index 4f188b77e0..179077917c 100644
--- a/ext/tk/sample/tkextlib/tile/themes/kroc/pkgIndex.tcl
+++ b/ext/tk/sample/tkextlib/tile/themes/kroc/pkgIndex.tcl
@@ -6,7 +6,7 @@
# To use this automatically within tile, the tile-using application should
# use tile::availableThemes and tile::setTheme
#
-# $Id: pkgIndex.tcl,v 1.1.2.1 2005/11/25 07:05:01 nagai Exp $
+# $Id$
if {![file isdirectory [file join $dir kroc]]} { return }
if {![package vsatisfies [package provide Tcl] 8.4]} { return }
diff --git a/ext/tk/sample/tkextlib/tile/themes/plastik/pkgIndex.tcl b/ext/tk/sample/tkextlib/tile/themes/plastik/pkgIndex.tcl
index f7fd2a899d..e39aff6f44 100644
--- a/ext/tk/sample/tkextlib/tile/themes/plastik/pkgIndex.tcl
+++ b/ext/tk/sample/tkextlib/tile/themes/plastik/pkgIndex.tcl
@@ -6,7 +6,7 @@
# To use this automatically within tile, the tile-using application should
# use tile::availableThemes and tile::setTheme
#
-# $Id: pkgIndex.tcl,v 1.1.2.1 2005/11/25 07:05:02 nagai Exp $
+# $Id$
if {![file isdirectory [file join $dir plastik]]} { return }
if {![package vsatisfies [package provide Tcl] 8.4]} { return }
diff --git a/ext/tk/sample/tkextlib/tile/themes/plastik/plastik.tcl b/ext/tk/sample/tkextlib/tile/themes/plastik/plastik.tcl
index 51fb7244f6..ea6ed74162 100644
--- a/ext/tk/sample/tkextlib/tile/themes/plastik/plastik.tcl
+++ b/ext/tk/sample/tkextlib/tile/themes/plastik/plastik.tcl
@@ -5,7 +5,7 @@
# Copyright (c) 2004 Googie
# Copyright (c) 2005 Pat Thoyts <patthoyts@users.sourceforge.net>
#
-# $Id: plastik.tcl,v 1.1.2.1 2005/11/25 07:05:02 nagai Exp $
+# $Id$
package require Tk 8.4
package require tile 0.5
diff --git a/ext/tk/sample/tkextlib/tile/toolbutton.tcl b/ext/tk/sample/tkextlib/tile/toolbutton.tcl
index 63b805d98b..4e08034e31 100644
--- a/ext/tk/sample/tkextlib/tile/toolbutton.tcl
+++ b/ext/tk/sample/tkextlib/tile/toolbutton.tcl
@@ -1,5 +1,5 @@
#
-# $Id: toolbutton.tcl,v 1.1.2.1 2005/04/09 09:27:28 nagai Exp $
+# $Id$
#
# Demonstration of custom widget styles.
#
diff --git a/ext/tk/sample/tkextlib/tkHTML/page3/index.html b/ext/tk/sample/tkextlib/tkHTML/page3/index.html
index d854bd5b8b..ce92e8a22e 100644
--- a/ext/tk/sample/tkextlib/tkHTML/page3/index.html
+++ b/ext/tk/sample/tkextlib/tkHTML/page3/index.html
@@ -29,7 +29,7 @@
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: index.html,v 1.1.2.1 2004/07/01 09:38:51 nagai Exp $</small></p></td></tr>
+ <p align="center"><small>$Id$</small></p></td></tr>
</table>
</center>
</p>
diff --git a/ext/tk/sample/tktextio.rb b/ext/tk/sample/tktextio.rb
index cb59c2d9d6..4573bcebdf 100644
--- a/ext/tk/sample/tktextio.rb
+++ b/ext/tk/sample/tktextio.rb
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
#
-# sample class of handling I/O stream on a TkText widget
-# by Hidetoshi NAGAI
+# TkTextIO class :: handling I/O stream on a TkText widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
# NOTE: TkTextIO supports 'character' (not 'byte') access only.
# So, for example, TkTextIO#getc returns a character, TkTextIO#pos
@@ -14,69 +14,376 @@
# TkTextIO.
#
require 'tk'
+require 'tk/text'
+require 'tk/textmark'
+require 'thread'
class TkTextIO < TkText
+ # keep safe level
+ @@create_queues = proc{ [Queue.new, Mutex.new, Queue.new, Mutex.new] }
+
+ OPT_DEFAULTS = {
+ 'mode' => nil,
+ 'overwrite' => false,
+ 'text' => nil,
+ 'show' => :pos,
+ 'wrap' => 'char',
+ 'sync' => true,
+ 'prompt' => nil,
+ 'prompt_cmd' => nil,
+ 'hist_size' => 1000,
+ }
+
def create_self(keys)
- mode = nil
- ovwt = false
- text = nil
- wrap = 'char'
- show = :pos
-
- if keys.kind_of?(Hash)
- mode = keys.delete('mode')
- ovwt = keys.delete('overwrite')
- text = keys.delete('text')
- show = keys.delete('show') if keys.has_key?('show')
- wrap = keys.delete('wrap') || 'char'
- end
+ opts = _get_io_params((keys.kind_of?(Hash))? keys: {})
super(keys)
- self['wrap'] = wrap
- insert('1.0', text)
+ @count_var = TkVariable.new
- @txtpos = TkTextMark.new(self, '1.0')
- @txtpos.gravity = :left
+ @write_buffer = ''
+ @read_buffer = ''
+ @buf_size = 0
+ @buf_max = 1024
- self.show_mode = show
+ @write_buf_queue, @write_buf_mutex,
+ @read_buf_queue, @read_buf_mutex = @@create_queues.call
- @sync = true
- @overwrite = (ovwt)? true: false
+ @idle_flush = TkTimer.new(:idle, 1, proc{ @flusher.run rescue nil })
+ @timer_flush = TkTimer.new(250, -1, proc{ @flusher.run rescue nil })
+
+ @flusher = Thread.new{ loop { Thread.stop; flush() } }
+
+ @receiver = Thread.new{
+ begin
+ loop {
+ str = @write_buf_queue.deq
+ @write_buf_mutex.synchronize { @write_buffer << str }
+ @idle_flush.start
+ }
+ ensure
+ @flusher.kill
+ end
+ }
+
+ @timer_flush.start
+
+ _setup_io(opts)
+ end
+ private :create_self
+
+ def destroy
+ @flusher.kill rescue nil
+
+ @idle_flush.stop rescue nil
+ @timer_flush.stop rescue nil
+
+ @receiver.kill rescue nil
+
+ super()
+ end
+
+ ####################################
+
+ def _get_io_params(keys)
+ opts = {}
+ self.class.const_get(:OPT_DEFAULTS).each{|k, v|
+ if keys.has_key?(k)
+ opts[k] = keys.delete(k)
+ else
+ opts[k] = v
+ end
+ }
+ opts
+ end
+
+ def _setup_io(opts)
+ unless defined? @txtpos
+ @txtpos = TkTextMark.new(self, '1.0')
+ else
+ @txtpos.set('1.0')
+ end
+ @txtpos.gravity = :left
@lineno = 0
@line_offset = 0
- @count_var = TkVariable.new
+
+ @hist_max = opts['hist_size'].to_i
+ @hist_index = 0
+ @history = Array.new(@hist_max)
+ @history[0] = ''
+
+ self['wrap'] = wrap
+
+ self.show_mode = opts['show']
+
+ self.value = opts['text'] if opts['text']
+
+ @overwrite = (opts['overwrite'])? true: false
+
+ @sync = opts['sync']
+
+ @prompt = opts['prompt']
+ @prompt_cmd = opts['prompt_cmd']
@open = {:r => true, :w => true} # default is 'r+'
- case mode
- when 'r'
+ @console_mode = false
+ @end_of_stream = false
+ @console_buffer = nil
+
+ case opts['mode']
+ when nil
+ # do nothing
+
+ when :console, 'console'
+ @console_mode = true
+ # @console_buffer = TkTextIO.new(:mode=>'r')
+ @console_buffer = self.class.new(:mode=>'r')
+ self.show_mode = :insert
+
+ when 'r', 'rb'
@open[:r] = true; @open[:w] = nil
- when 'r+'
+ when 'r+', 'rb+', 'r+b'
@open[:r] = true; @open[:w] = true
- when 'w'
+ when 'w', 'wb'
@open[:r] = nil; @open[:w] = true
self.value=''
- when 'w+'
+ when 'w+', 'wb+', 'w+b'
@open[:r] = true; @open[:w] = true
self.value=''
- when 'a'
+ when 'a', 'ab'
@open[:r] = nil; @open[:w] = true
- @txtpos = TkTextMark.new(self, 'end - 1 char')
+ @txtpos.set('end - 1 char')
@txtpos.gravity = :right
- when 'a+'
+ when 'a+', 'ab+', 'a+b'
@open[:r] = true; @open[:w] = true
- @txtpos = TkTextMark.new(self, 'end - 1 char')
+ @txtpos.set('end - 1 char')
@txtpos.gravity = :right
+
+ else
+ fail ArgumentError, "unknown mode `#{opts['mode']}'"
+ end
+
+ unless defined? @ins_head
+ @ins_head = TkTextMark.new(self, 'insert')
+ @ins_head.gravity = :left
+ end
+
+ unless defined? @ins_tail
+ @ins_tail = TkTextMark.new(self, 'insert')
+ @ins_tail.gravity = :right
+ end
+
+ unless defined? @tmp_mark
+ @tmp_mark = TkTextMark.new(self, 'insert')
+ @tmp_mark.gravity = :left
+ end
+
+ if @console_mode
+ _set_console_line
+ _setup_console_bindings
+ end
+ end
+ private :_get_io_params, :_setup_io
+
+ def _set_console_line
+ @tmp_mark.set(@ins_tail)
+
+ mark_set('insert', 'end')
+
+ prompt = ''
+ prompt << @prompt_cmd.call if @prompt_cmd
+ prompt << @prompt if @prompt
+ insert(@tmp_mark, prompt)
+
+ @ins_head.set(@ins_tail)
+ @ins_tail.set('insert')
+
+ @txtpos.set(@tmp_mark)
+
+ _see_pos
+ end
+
+ def _replace_console_line(str)
+ self.delete(@ins_head, @ins_tail)
+ self.insert(@ins_head, str)
+ end
+
+ def _get_console_line
+ @tmp_mark.set(@ins_tail)
+ s = self.get(@ins_head, @tmp_mark)
+ _set_console_line
+ s
+ end
+ private :_set_console_line, :_replace_console_line, :_get_console_line
+
+ def _cb_up
+ @history[@hist_index].replace(self.get(@ins_head, @ins_tail))
+ @hist_index += 1
+ @hist_index -= 1 if @hist_index >= @hist_max || !@history[@hist_index]
+ _replace_console_line(@history[@hist_index]) if @history[@hist_index]
+ Tk.callback_break
+ end
+ def _cb_down
+ @history[@hist_index].replace(self.get(@ins_head, @ins_tail))
+ @hist_index -= 1
+ @hist_index = 0 if @hist_index < 0
+ _replace_console_line(@history[@hist_index]) if @history[@hist_index]
+ Tk.callback_break
+ end
+ def _cb_left
+ if @console_mode && compare('insert', '<=', @ins_head)
+ mark_set('insert', @ins_head)
+ Tk.callback_break
+ end
+ end
+ def _cb_backspace
+ if @console_mode && compare('insert', '<=', @ins_head)
+ Tk.callback_break
+ end
+ end
+ def _cb_ctrl_a
+ if @console_mode
+ mark_set('insert', @ins_head)
+ Tk.callback_break
+ end
+ end
+ private :_cb_up, :_cb_down, :_cb_left, :_cb_backspace, :_cb_ctrl_a
+
+ def _setup_console_bindings
+ @bindtag = TkBindTag.new
+
+ tags = self.bindtags
+ tags[tags.index(self)+1, 0] = @bindtag
+ self.bindtags = tags
+
+ @bindtag.bind('Return'){
+ insert('end - 1 char', "\n")
+ if (str = _get_console_line)
+ @read_buf_queue.push(str)
+
+ @history[0].replace(str.chomp)
+ @history.pop
+ @history.unshift('')
+ @hist_index = 0
+ end
+
+ Tk.update
+ Tk.callback_break
+ }
+ @bindtag.bind('Alt-Return'){
+ Tk.callback_continue
+ }
+
+ @bindtag.bind('FocusIn'){
+ if @console_mode
+ mark_set('insert', @ins_tail)
+ Tk.callback_break
+ end
+ }
+
+ ins_mark = TkTextMark.new(self, 'insert')
+
+ @bindtag.bind('ButtonPress'){
+ if @console_mode
+ ins_mark.set('insert')
+ end
+ }
+
+ @bindtag.bind('ButtonRelease-1'){
+ if @console_mode && compare('insert', '<=', @ins_head)
+ mark_set('insert', ins_mark)
+ Tk.callback_break
+ end
+ }
+
+ @bindtag.bind('ButtonRelease-2', '%x %y'){|x, y|
+ if @console_mode
+ # paste a text at 'insert' only
+ x1, y1, x2, y2 = bbox(ins_mark)
+ unless x == x1 && y == y1
+ Tk.event_generate(self, 'ButtonRelease-2', :x=>x1, :y=>y1)
+ Tk.callback_break
+ end
+ end
+ }
+
+ @bindtag.bind('Up'){ _cb_up }
+ @bindtag.bind('Control-p'){ _cb_up }
+
+ @bindtag.bind('Down'){ _cb_down }
+ @bindtag.bind('Control-n'){ _cb_down }
+
+ @bindtag.bind('Left'){ _cb_left }
+ @bindtag.bind('Control-b'){ _cb_left }
+
+ @bindtag.bind('BackSpace'){ _cb_backspace }
+ @bindtag.bind('Control-h'){ _cb_backspace }
+
+ @bindtag.bind('Home'){ _cb_ctrl_a }
+ @bindtag.bind('Control-a'){ _cb_ctrl_a }
+ end
+ private :_setup_console_bindings
+
+ def _block_read(size = nil, ret = '', block_mode = true)
+ return '' if size == 0
+ return nil if ! @read_buf_queue && @read_buffer.empty?
+ ret = '' unless ret.kind_of?(String)
+ ret.replace('') unless ret.empty?
+
+ if block_mode == nil # partial
+ if @read_buffer.empty?
+ ret << @read_buffer.slice!(0..-1)
+ return ret
+ end
+ end
+
+ if size.kind_of?(Numeric)
+ loop{
+ @read_buf_mutex.synchronize {
+ buf_len = @read_buffer.length
+ if buf_len >= size
+ ret << @read_buffer.slice!(0, size)
+ return ret
+ else
+ ret << @read_buffer.slice!(0..-1)
+ size -= buf_len
+ return ret unless @read_buf_queue
+ end
+ }
+ @read_buffer << @read_buf_queue.pop
+ }
+ else # readline
+ rs = (size)? size: $/
+ rs = rs.to_s if rs.kind_of?(Regexp)
+ loop{
+ @read_buf_mutex.synchronize {
+ if (str = @read_buffer.slice!(/\A(.*)(#{rs})/m))
+ ret << str
+ return ret
+ else
+ ret << @read_buffer.slice!(0..-1)
+ return ret unless @read_buf_queue
+ end
+ }
+ @read_buffer << @read_buf_queue.pop
+ }
end
end
+ def _block_write
+ ###### currently, not support
+ end
+ private :_block_read, :_block_write
+
+ ####################################
+
def <<(obj)
_write(obj)
self
@@ -107,14 +414,15 @@ class TkTextIO < TkText
nil
end
- def closed?
- close_read? && close_write?
- end
- def closed_read?
- !@open[:r]
- end
- def closed_write?
- !@open[:w]
+ def closed?(dir=nil)
+ case dir
+ when :r, 'r'
+ !@open[:r]
+ when :w, 'w'
+ !@open[:w]
+ else
+ !@open[:r] && !@open[:w]
+ end
end
def _check_readable
@@ -129,7 +437,7 @@ class TkTextIO < TkText
def each_line(rs = $/)
_check_readable
- while(s = gets)
+ while(s = self.gets(rs))
yield(s)
end
self
@@ -138,7 +446,7 @@ class TkTextIO < TkText
def each_char
_check_readable
- while(c = getc)
+ while(c = self.getc)
yield(c)
end
self
@@ -151,7 +459,7 @@ class TkTextIO < TkText
alias eof eof?
def fcntl(*args)
- fail NotImplementedError, 'fcntl is not implemented on TkTextIO'
+ fail NotImplementedError, "fcntl is not implemented on #{self.class}"
end
def fsync
@@ -163,11 +471,19 @@ class TkTextIO < TkText
end
def flush
- Tk.update if @open[:w] && @sync
+ Thread.pass
+ if @open[:w] || ! @write_buffer.empty?
+ @write_buf_mutex.synchronize {
+ _sync_write_buf(@write_buffer)
+ @write_buffer[0..-1] = ''
+ }
+ end
self
end
def getc
+ return _block_read(1) if @console_mode
+
_check_readable
return nil if eof?
c = get(@txtpos)
@@ -177,8 +493,10 @@ class TkTextIO < TkText
end
def gets(rs = $/)
+ return _block_read(rs) if @console_mode
+
_check_readable
- return nil if eof?
+ return nil if eof?
_readline(rs)
end
@@ -233,7 +551,6 @@ class TkTextIO < TkText
alias tell pos
def pos=(idx)
- # @txtpos.set((idx.kind_of?(Numeric))? "1.0 + #{idx} char": idx)
seek(idx, IO::SEEK_SET)
idx
end
@@ -306,6 +623,8 @@ class TkTextIO < TkText
private :_read
def read(len=nil, buf=nil)
+ return _block_read(len, buf) if @console_mode
+
_check_readable
if len
return "" if len == 0
@@ -321,6 +640,8 @@ class TkTextIO < TkText
end
def readchar
+ return _block_read(1) if @console_mode
+
_check_readable
fail EOFError if eof?
c = get(@txtpos)
@@ -334,6 +655,7 @@ class TkTextIO < TkText
s = get(@txtpos, 'end - 1 char')
@txtpos.set('end - 1 char')
elsif rs == ''
+ @count_var.value # make it global
idx = tksearch_with_count([:regexp], @count_var,
"\n(\n)+", @txtpos, 'end - 1 char')
if idx
@@ -345,6 +667,7 @@ class TkTextIO < TkText
@txtpos.set('end - 1 char')
end
else
+ @count_var.value # make it global
idx = tksearch_with_count(@count_var, rs, @txtpos, 'end - 1 char')
if idx
s = get(@txtpos, "#{idx} + #{@count_var.value} char")
@@ -363,12 +686,22 @@ class TkTextIO < TkText
private :_readline
def readline(rs = $/)
+ return _block_readline(rs) if @console_mode
+
_check_readable
fail EOFError if eof?
_readline(rs)
end
def readlines(rs = $/)
+ if @console_mode
+ lines = []
+ while (line = _block_readline(rs))
+ lines << line
+ end
+ return lines
+ end
+
_check_readable
lines = []
until(eof?)
@@ -379,7 +712,11 @@ class TkTextIO < TkText
end
def readpartial(maxlen, buf=nil)
+ #return @console_buffer.readpartial(maxlen, buf) if @console_mode
+ return _block_read(maxlen, buf, nil) if @console_mode
+
_check_readable
+ fail EOFError if eof?
s = _read(maxlen)
buf.replace(s) if buf.kind_of?(String)
s
@@ -471,6 +808,8 @@ class TkTextIO < TkText
end
def sysread(len, buf=nil)
+ return _block_read(len, buf) if @console_mode
+
_check_readable
fail EOFError if eof?
s = _read(len)
@@ -492,6 +831,13 @@ class TkTextIO < TkText
end
def ungetc(c)
+ if @console_mode
+ @read_buf_mutex.synchronize {
+ @read_buffer[0,0] = c.chr
+ }
+ return nil
+ end
+
_check_readable
c = c.chr if c.kind_of?(Fixnum)
if compare(@txtpos, '>', '1.0')
@@ -506,8 +852,10 @@ class TkTextIO < TkText
nil
end
+=begin
def _write(obj)
- s = _get_eval_string(obj)
+ #s = _get_eval_string(obj)
+ s = (obj.kind_of?(String))? obj: obj.to_s
n = number(tk_call('string', 'length', s))
delete(@txtpos, @txtpos + "#{n} char") if @overwrite
self.insert(@txtpos, s)
@@ -518,6 +866,37 @@ class TkTextIO < TkText
n
end
private :_write
+=end
+#=begin
+ def _sync_write_buf(s)
+ if (n = number(tk_call('string', 'length', s))) > 0
+ delete(@txtpos, @txtpos + "#{n} char") if @overwrite
+ self.insert(@txtpos, s)
+ #Tk.update
+
+ @txtpos.set(@txtpos + "#{n} char")
+ @txtpos.set('end - 1 char') if compare(@txtpos, '>=', :end)
+
+ @ins_head.set(@txtpos) if compare(@txtpos, '>', @ins_head)
+
+ _see_pos
+ end
+ self
+ end
+ private :_sync_write_buf
+
+ def _write(obj)
+ s = (obj.kind_of?(String))? obj: obj.to_s
+ n = number(tk_call('string', 'length', s))
+ @write_buf_queue.enq(s)
+ if @sync
+ Thread.pass
+ Tk.update
+ end
+ n
+ end
+ private :_write
+#=end
def write(obj)
_check_writable
@@ -529,13 +908,19 @@ end
# TEST
####################
if __FILE__ == $0
+ ev_loop = Thread.new{Tk.mainloop}
+
f = TkFrame.new.pack
- tio = TkTextIO.new(f, :show=>:pos,
+ #tio = TkTextIO.new(f, :show=>:nil,
+ #tio = TkTextIO.new(f, :show=>:pos,
+ tio = TkTextIO.new(f, :show=>:insert,
:text=>">>> This is an initial text line. <<<\n\n"){
- yscrollbar(TkScrollbar.new(f).pack(:side=>:right, :fill=>:y))
+# yscrollbar(TkScrollbar.new(f).pack(:side=>:right, :fill=>:y))
pack(:side=>:left, :fill=>:both, :expand=>true)
}
+ Tk.update
+
$stdin = tio
$stdout = tio
$stderr = tio
@@ -599,5 +984,67 @@ if __FILE__ == $0
tio.seek(0, IO::SEEK_END)
- Tk.mainloop
+ STDOUT.print("tio.sync == #{tio.sync}\n")
+# tio.sync = false
+# STDOUT.print("tio.sync == #{tio.sync}\n")
+
+ (0..10).each{|i|
+ STDOUT.print("#{i}\n")
+ s = ''
+ (0..1000).each{ s << '*' }
+ print(s)
+ }
+ print("\n")
+ print("\n=========================================================\n\n")
+
+ s = ''
+ timer = TkTimer.new(:idle, -1, proc{
+ #STDOUT.print("idle call\n")
+ unless s.empty?
+ print(s)
+ s = ''
+ end
+ }).start
+ (0..10).each{|i|
+ STDOUT.print("#{i}\n")
+ (0..1000).each{ s << '*' }
+ }
+# timer.stop
+ until s.empty?
+ sleep 0.1
+ end
+ timer.stop
+
+=begin
+ tio.sync = false
+ print("\n")
+ #(0..10000).each{ putc('*') }
+ (0..10).each{|i|
+ STDOUT.print("#{i}\n")
+ (0..1000).each{ putc('*') }
+ }
+
+ (0..10).each{|i|
+ STDOUT.print("#{i}\n")
+ s = ''
+ (0..1000).each{ s << '*' }
+ print(s)
+ }
+=end
+
+ num = 0
+# io = TkTextIO.new(:mode=>:console, :prompt=>'').pack
+#=begin
+ io = TkTextIO.new(:mode=>:console,
+ :prompt_cmd=>proc{
+ s = "[#{num}]"
+ num += 1
+ s
+ },
+ :prompt=>'-> ').pack
+#=end
+ Thread.new{loop{sleep 2; io.puts 'hoge'}}
+ Thread.new{loop{p io.gets}}
+
+ ev_loop.join
end
diff --git a/ext/tk/tcltklib.c b/ext/tk/tcltklib.c
index ff1f7640bd..10b79f2970 100644
--- a/ext/tk/tcltklib.c
+++ b/ext/tk/tcltklib.c
@@ -4364,11 +4364,12 @@ delete_slaves(ip)
/* finalize operation */
-static void
+static VALUE
lib_mark_at_exit(self)
VALUE self;
{
at_exit = 1;
+ return Qnil;
}
static int
@@ -4413,13 +4414,13 @@ ip_finalize(ip)
}
if (Tcl_InterpDeleted(ip)) {
- DUMP2("ip(%p) is already deleted", ip);
+ DUMP2("ip(%lx) is already deleted", ip);
return;
}
#if TCL_NAMESPACE_DEBUG
if (ip_null_namespace(ip)) {
- DUMP2("ip(%p) has null namespace", ip);
+ DUMP2("ip(%lx) has null namespace", ip);
return;
}
#endif
@@ -7994,6 +7995,8 @@ Init_tcltklib()
/* --------------------------------------------------------------- */
+ rb_define_module_function(lib, "_mark_at_exit", lib_mark_at_exit, 0);
+
rb_define_module_function(lib, "mainloop", lib_mainloop, -1);
rb_define_module_function(lib, "mainloop_thread?",
lib_evloop_thread_p, 0);
@@ -8130,7 +8133,7 @@ Init_tcltklib()
/* --------------------------------------------------------------- */
- rb_set_end_proc(lib_mark_at_exit, 0);
+ rb_eval_string("at_exit{ TclTkLib._mark_at_exit }");
/* --------------------------------------------------------------- */
diff --git a/ext/tk/tkutil/extconf.rb b/ext/tk/tkutil/extconf.rb
index e3aa00a4b2..dd00d5d535 100644
--- a/ext/tk/tkutil/extconf.rb
+++ b/ext/tk/tkutil/extconf.rb
@@ -1,4 +1,11 @@
-if compiled?('tk')
+begin
+ has_tk = compiled?('tk')
+rescue NoMethodError
+ # Probably, called manually (NOT from 'extmk.rb'). Force to make Makefile.
+ has_tk = true
+end
+
+if has_tk
require 'mkmf'
create_makefile('tkutil')
end
diff --git a/ext/tk/tkutil/tkutil.c b/ext/tk/tkutil/tkutil.c
index be1b635a0f..f4271a724c 100644
--- a/ext/tk/tkutil/tkutil.c
+++ b/ext/tk/tkutil/tkutil.c
@@ -2,8 +2,8 @@
tkutil.c -
- $Author: nagai $
- $Date: 2006/04/05 16:08:45 $
+ $Author$
+ $Date$
created at: Fri Nov 3 00:47:54 JST 1995
************************************************/
diff --git a/ext/win32ole/extconf.rb b/ext/win32ole/extconf.rb
index 8cd9581fb0..cee922554a 100644
--- a/ext/win32ole/extconf.rb
+++ b/ext/win32ole/extconf.rb
@@ -1,7 +1,7 @@
#----------------------------------
# extconf.rb
-# $Revision: 1.5.2.2 $
-# $Date: 2005/10/09 02:15:03 $
+# $Revision$
+# $Date$
#----------------------------------
require 'mkmf'
diff --git a/ext/win32ole/sample/olegen.rb b/ext/win32ole/sample/olegen.rb
index ff450f235f..48d86893fe 100644
--- a/ext/win32ole/sample/olegen.rb
+++ b/ext/win32ole/sample/olegen.rb
@@ -1,7 +1,7 @@
#-----------------------------
# olegen.rb
-# $Date: 2002/06/01 12:34:29 $
-# $Revision: 1.1 $
+# $Date$
+# $Revision$
#-----------------------------
require 'win32ole'
diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c
index 4bb318cefd..950ff21fd9 100644
--- a/ext/win32ole/win32ole.c
+++ b/ext/win32ole/win32ole.c
@@ -12,7 +12,7 @@
*/
/*
- $Date: 2007/01/13 22:34:25 $
+ $Date$
modified for win32ole (ruby) by Masaki.Suketa <masaki.suketa@nifty.ne.jp>
*/
@@ -30,6 +30,7 @@
#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__)
@@ -78,7 +79,7 @@
#define WC2VSTR(x) ole_wc2vstr((x), TRUE)
-#define WIN32OLE_VERSION "0.7.4"
+#define WIN32OLE_VERSION "0.7.1"
typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX)
(REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*);
@@ -476,9 +477,8 @@ ole_wc2mb(pw)
LPSTR pm;
size = WideCharToMultiByte(cWIN32OLE_cp, 0, pw, -1, NULL, 0, NULL, NULL);
if (size) {
- pm = ALLOC_N(char, size + 1);
+ pm = ALLOC_N(char, size);
WideCharToMultiByte(cWIN32OLE_cp, 0, pw, -1, pm, size, NULL, NULL);
- pm[size] = '\0';
}
else {
pm = ALLOC_N(char, 1);
@@ -497,7 +497,7 @@ ole_hresult2msg(hr)
DWORD dwCount;
char strhr[100];
- sprintf(strhr, " HRESULT error code:0x%08lx\n ", hr);
+ sprintf(strhr, " HRESULT error code:0x%08x\n ", hr);
msg = rb_str_new2(strhr);
dwCount = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
@@ -926,8 +926,8 @@ ole_variant2val(pvar)
if (!psa) {
return obj;
}
-
dim = SafeArrayGetDim(psa);
+
VariantInit(&variant);
V_VT(&variant) = (V_VT(pvar) & ~VT_ARRAY) | VT_BYREF;
@@ -1138,13 +1138,12 @@ reg_enum_key(hkey, i)
HKEY hkey;
DWORD i;
{
- char buf[BUFSIZ + 1];
- DWORD size_buf = sizeof(buf) - 1;
+ 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) {
- buf[BUFSIZ] = '\0';
return rb_str_new2(buf);
}
return Qnil;
@@ -1155,11 +1154,10 @@ reg_get_val(hkey, subkey)
HKEY hkey;
const char *subkey;
{
- char buf[BUFSIZ + 1];
- LONG size_buf = sizeof(buf) - 1;
+ char buf[BUFSIZ];
+ LONG size_buf = sizeof(buf);
LONG err = RegQueryValue(hkey, subkey, buf, &size_buf);
if (err == ERROR_SUCCESS) {
- buf[BUFSIZ] = '\0';
return rb_str_new2(buf);
}
return Qnil;
@@ -2102,7 +2100,7 @@ ole_invoke(argc, argv, self, wFlags)
&result, &excepinfo, &argErr);
if (FAILED(hr)) {
/* retry to call args by value */
- if(op.dp.cArgs >= cNamedArgs) {
+ 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);
@@ -3620,10 +3618,8 @@ ole_type_progid(pTypeInfo)
if (FAILED(hr))
return progid;
hr = ProgIDFromCLSID(&pTypeAttr->guid, &pbuf);
- if (SUCCEEDED(hr)) {
- progid = ole_wc2vstr(pbuf, FALSE);
- CoTaskMemFree(pbuf);
- }
+ if (SUCCEEDED(hr))
+ progid = WC2VSTR(pbuf);
OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
return progid;
}
@@ -4037,8 +4033,7 @@ folevariable_name(self)
return rb_ivar_get(self, rb_intern("name"));
}
-static VALUE
-ole_variable_ole_type(pTypeInfo, var_index)
+static ole_variable_ole_type(pTypeInfo, var_index)
ITypeInfo *pTypeInfo;
UINT var_index;
{
@@ -4082,8 +4077,7 @@ folevariable_ole_type(self)
return ole_variable_ole_type(pvar->pTypeInfo, pvar->index);
}
-static VALUE
-ole_variable_ole_type_detail(pTypeInfo, var_index)
+static ole_variable_ole_type_detail(pTypeInfo, var_index)
ITypeInfo *pTypeInfo;
UINT var_index;
{
@@ -4119,8 +4113,7 @@ folevariable_ole_type_detail(self)
return ole_variable_ole_type_detail(pvar->pTypeInfo, pvar->index);
}
-static VALUE
-ole_variable_value(pTypeInfo, var_index)
+static ole_variable_value(pTypeInfo, var_index)
ITypeInfo *pTypeInfo;
UINT var_index;
{
@@ -4166,8 +4159,7 @@ folevariable_value(self)
return ole_variable_value(pvar->pTypeInfo, pvar->index);
}
-static VALUE
-ole_variable_visible(pTypeInfo, var_index)
+static ole_variable_visible(pTypeInfo, var_index)
ITypeInfo *pTypeInfo;
UINT var_index;
{
@@ -4639,8 +4631,7 @@ folemethod_visible(self)
return ole_method_visible(pmethod->pTypeInfo, pmethod->index);
}
-static VALUE
-ole_method_event(pTypeInfo, method_index, method_name)
+static ole_method_event(pTypeInfo, method_index, method_name)
ITypeInfo *pTypeInfo;
WORD method_index;
VALUE method_name;
diff --git a/ext/zlib/doc/zlib.rd b/ext/zlib/doc/zlib.rd
index f914d883fe..6a36dc7fed 100644
--- a/ext/zlib/doc/zlib.rd
+++ b/ext/zlib/doc/zlib.rd
@@ -4,7 +4,7 @@
#
# Copyright (C) UENO Katsuhiro 2000-2003
#
-# $Id: zlib.rd,v 1.1.2.1 2004/03/28 14:10:39 akr Exp $
+# $Id$
#
= Ruby/zlib version 0.6.0
diff --git a/ext/zlib/extconf.rb b/ext/zlib/extconf.rb
index 14c8376417..b4e76af3c6 100644
--- a/ext/zlib/extconf.rb
+++ b/ext/zlib/extconf.rb
@@ -1,7 +1,7 @@
#
# extconf.rb
#
-# $Id: extconf.rb,v 1.2.2.2 2006/05/25 23:44:07 nobu Exp $
+# $Id$
#
require 'mkmf'
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index 4684865c65..8caadaeddc 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -3,7 +3,7 @@
*
* Copyright (C) UENO Katsuhiro 2000-2003
*
- * $Id: zlib.c,v 1.7.2.20 2006/02/14 11:21:54 ocean Exp $
+ * $Id$
*/
#include <ruby.h>
diff --git a/file.c b/file.c
index e92dd7962b..226046a6ef 100644
--- a/file.c
+++ b/file.c
@@ -2,8 +2,8 @@
file.c -
- $Author: nobu $
- $Date: 2006/08/19 02:29:18 $
+ $Author$
+ $Date$
created at: Mon Nov 15 12:24:34 JST 1993
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -15,18 +15,12 @@
#ifdef _WIN32
#include "missing/file.h"
#endif
-#ifdef __CYGWIN__
-#include <windows.h>
-#include <sys/cygwin.h>
-#endif
-#define OpenFile rb_io_t
#include "ruby.h"
#include "rubyio.h"
#include "rubysig.h"
#include "util.h"
#include "dln.h"
-#include <ctype.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
@@ -821,13 +815,12 @@ rb_file_lstat(obj)
#endif
}
-#ifndef HAVE_GROUP_MEMBER
static int
group_member(gid)
GETGROUPS_T gid;
{
#ifndef _WIN32
- if (getgid() == gid)
+ if (getgid() == gid || getegid() == gid)
return Qtrue;
# ifdef HAVE_GETGROUPS
@@ -851,7 +844,6 @@ group_member(gid)
#endif
return Qfalse;
}
-#endif
#ifndef S_IXUGO
# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
@@ -890,7 +882,7 @@ eaccess(path, mode)
if (st.st_uid == euid) /* owner */
mode <<= 6;
- else if (getegid() == st.st_gid || group_member(st.st_gid))
+ else if (group_member(st.st_gid))
mode <<= 3;
if ((st.st_mode & mode) == mode) return 0;
@@ -1271,10 +1263,10 @@ test_z(obj, fname)
/*
* call-seq:
- * File.file?(file_name) => integer or nil
+ * File.size?(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.
+ * Returns +nil+ if +file_name+ doesn't exist or has zero size, the size of the
+ * file otherwise.
*/
static VALUE
@@ -1336,7 +1328,7 @@ test_grpowned(obj, fname)
struct stat st;
if (rb_stat(fname, &st) < 0) return Qfalse;
- if (st.st_gid == getegid()) return Qtrue;
+ if (group_member(st.st_gid)) return Qtrue;
#endif
return Qfalse;
}
@@ -2016,13 +2008,16 @@ rb_file_s_utime(argc, argv)
VALUE *argv;
{
VALUE atime, mtime, rest;
- struct timeval tvp[2];
+ struct timeval tvs[2], *tvp = NULL;
long n;
rb_scan_args(argc, argv, "2*", &atime, &mtime, &rest);
- tvp[0] = rb_time_timeval(atime);
- tvp[1] = rb_time_timeval(mtime);
+ if (!NIL_P(atime) || !NIL_P(mtime)) {
+ tvp = tvs;
+ tvp[0] = rb_time_timeval(atime);
+ tvp[1] = rb_time_timeval(mtime);
+ }
n = apply2files(utime_internal, rest, tvp);
return LONG2FIX(n);
@@ -2055,16 +2050,19 @@ rb_file_s_utime(argc, argv)
VALUE atime, mtime, rest;
long n;
struct timeval tv;
- struct utimbuf utbuf;
+ struct utimbuf utbuf, *utp = NULL;
rb_scan_args(argc, argv, "2*", &atime, &mtime, &rest);
- tv = rb_time_timeval(atime);
- utbuf.actime = tv.tv_sec;
- tv = rb_time_timeval(mtime);
- utbuf.modtime = tv.tv_sec;
+ if (!NIL_P(atime) || !NIL_P(mtime)) {
+ utp = &utbuf;
+ tv = rb_time_timeval(atime);
+ utp->actime = tv.tv_sec;
+ tv = rb_time_timeval(mtime);
+ utp->modtime = tv.tv_sec;
+ }
- n = apply2files(utime_internal, rest, &utbuf);
+ n = apply2files(utime_internal, rest, utp);
return LONG2FIX(n);
}
@@ -2244,12 +2242,18 @@ rb_file_s_rename(klass, from, to)
errno = 0;
#endif
if (rename(src, dst) < 0) {
-#if defined DOSISH && !defined _WIN32
- switch (errno) {
- case EEXIST:
+#if defined __CYGWIN__
+ extern unsigned long __attribute__((stdcall)) GetLastError(void);
+ if (errno == 0) { /* This is a bug of old Cygwin */
+ /* incorrect as cygwin errno, but the last resort */
+ errno = GetLastError();
+ }
+#elif defined DOSISH && !defined _WIN32
+ if (errno == EEXIST
#if defined (__EMX__)
- case EACCES:
+ || errno == EACCES
#endif
+ ) {
if (chmod(dst, 0666) == 0 &&
unlink(dst) == 0 &&
rename(src, dst) == 0)
@@ -2298,17 +2302,12 @@ rb_file_s_umask(argc, argv)
return INT2FIX(omask);
}
-#ifdef __CYGWIN__
-#undef DOSISH
-#endif
-#if defined __CYGWIN__ || defined DOSISH
+#if defined DOSISH
#define DOSISH_UNC
-#define DOSISH_DRIVE_LETTER
#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))
@@ -2317,16 +2316,10 @@ rb_file_s_umask(argc, argv)
# endif
#endif
-#if defined _WIN32 || defined __CYGWIN__
-#define USE_NTFS 1
-#else
-#define USE_NTFS 0
-#endif
-
-#if USE_NTFS
-#define istrailinggabage(x) ((x) == '.' || (x) == ' ')
-#else
-#define istrailinggabage(x) 0
+#ifdef __CYGWIN__
+#undef DOSISH
+#define DOSISH_UNC
+#define DOSISH_DRIVE_LETTER
#endif
#ifdef DOSISH_DRIVE_LETTER
@@ -2440,9 +2433,8 @@ rb_path_last_separator(path)
return last;
}
-#define chompdirsep rb_path_end
-char *
-rb_path_end(path)
+static char *
+chompdirsep(path)
const char *path;
{
while (*path) {
@@ -2458,29 +2450,13 @@ rb_path_end(path)
return (char *)path;
}
-#if USE_NTFS
-static char *
-ntfs_tail(const char *path)
+char *
+rb_path_end(path)
+ const char *path;
{
- while (*path && *path != ':') {
- if (istrailinggabage(*path)) {
- const char *last = path++;
- while (istrailinggabage(*path)) path++;
- if (!*path || *path == ':') return (char *)last;
- }
- else if (isdirsep(*path)) {
- const char *last = path++;
- while (isdirsep(*path)) path++;
- if (!*path) return (char *)last;
- if (*path == ':') path++;
- }
- else {
- path = CharNext(path);
- }
- }
- return (char *)path;
+ if (isdirsep(*path)) path++;
+ return chompdirsep(path);
}
-#endif
#define BUFCHECK(cond) do {\
long bdiff = p - buf;\
@@ -2508,8 +2484,7 @@ static VALUE
file_expand_path(fname, dname, result)
VALUE fname, dname, result;
{
- const char *s, *b;
- char *buf, *p, *pend, *root;
+ char *s, *buf, *b, *p, *pend, *root;
long buflen, dirlen;
int tainted;
@@ -2650,21 +2625,15 @@ file_expand_path(fname, dname, result)
case '.':
if (*(s+1) == '\0' || isdirsep(*(s+1))) {
/* We must go back to the parent */
- char *n;
*p = '\0';
- if (!(n = strrdirsep(root))) {
+ if (!(b = strrdirsep(root))) {
*p = '/';
}
else {
- p = n;
+ p = b;
}
b = ++s;
}
-#if USE_NTFS
- else {
- do *++s; while (istrailinggabage(*s));
- }
-#endif
break;
case '/':
#if defined DOSISH || defined __CYGWIN__
@@ -2677,19 +2646,6 @@ file_expand_path(fname, dname, result)
break;
}
}
-#if USE_NTFS
- else {
- --s;
- case ' ': {
- const char *e = s;
- while (istrailinggabage(*s)) s++;
- if (!*s) {
- s = e;
- goto endpath;
- }
- }
- }
-#endif
break;
case '/':
#if defined DOSISH || defined __CYGWIN__
@@ -2712,79 +2668,15 @@ file_expand_path(fname, dname, result)
}
if (s > b) {
-#if USE_NTFS
- endpath:
- if (s > b + 6 && strncasecmp(s - 6, ":$DATA", 6) == 0) {
- /* alias of stream */
- /* get rid of a bug of x64 VC++ */
- if (*(s-7) == ':') s -= 7; /* prime */
- else if (memchr(b, ':', s - 6 - b)) s -= 6; /* alternative */
- }
-#endif
BUFCHECK(bdiff + (s-b) >= buflen);
memcpy(++p, b, s-b);
p += s-b;
}
if (p == skiproot(buf) - 1) p++;
- buflen = p - buf;
-
- RSTRING(result)->len = buflen;
- *p = '\0';
-#if USE_NTFS
- if (1 &&
-#ifdef __CYGWIN__
- !(buf[0] == '/' && !buf[1]) &&
-#endif
- !strpbrk(b = buf, "*?")) {
- size_t len;
- WIN32_FIND_DATA wfd;
-#ifdef __CYGWIN__
- int lnk_added = 0, is_symlink = 0;
- struct stat st;
- char w32buf[MAXPATHLEN], sep = 0;
- p = 0;
- if (lstat(buf, &st) == 0 && S_ISLNK(st.st_mode)) {
- is_symlink = 1;
- p = strrdirsep(buf);
- if (!p) p = skipprefix(buf);
- if (p) {
- sep = *p;
- *p = '\0';
- }
- }
- if (cygwin_conv_to_win32_path(buf, w32buf) == 0) {
- b = w32buf;
- }
- if (p) *p = sep;
- else p = buf;
- if (is_symlink && b == w32buf) {
- len = strlen(p);
- if (len > 4 && strcasecmp(p + len - 4, ".lnk") != 0) {
- lnk_added = 1;
- strlcat(w32buf, ".lnk", sizeof(w32buf));
- }
- }
-#endif
- HANDLE h = FindFirstFile(b, &wfd);
- if (h != INVALID_HANDLE_VALUE) {
- FindClose(h);
- p = strrdirsep(buf);
- len = strlen(wfd.cFileName);
-#ifdef __CYGWIN__
- if (lnk_added && len > 4 &&
- strcasecmp(wfd.cFileName + len - 4, ".lnk") == 0) {
- len -= 4;
- }
-#endif
- if (!p) p = buf;
- buflen = ++p - buf + len;
- rb_str_resize(result, buflen);
- memcpy(p, wfd.cFileName, len + 1);
- }
- }
-#endif
if (tainted) OBJ_TAINT(result);
+ RSTRING(result)->len = p - buf;
+ *p = '\0';
return result;
}
@@ -2828,21 +2720,18 @@ rb_file_s_expand_path(argc, argv)
}
static int
-rmext(p, l1, e)
+rmext(p, e)
const char *p, *e;
- int l1;
{
- int l2;
+ int l1, l2;
if (!e) return 0;
+ l1 = chompdirsep(p) - p;
l2 = strlen(e);
if (l2 == 2 && e[1] == '*') {
- unsigned char c = *e;
- e = p + l1;
- do {
- if (e <= p) return 0;
- } while (*--e != c);
+ e = strrchr(p, *e);
+ if (!e) return 0;
return e - p;
}
if (l1 < l2) return l1;
@@ -2877,7 +2766,7 @@ rb_file_s_basename(argc, argv)
#if defined DOSISH_DRIVE_LETTER || defined DOSISH_UNC
char *root;
#endif
- int f, n;
+ int f;
if (rb_scan_args(argc, argv, "11", &fname, &fext) == 2) {
StringValue(fext);
@@ -2911,22 +2800,18 @@ rb_file_s_basename(argc, argv)
#endif
#endif
}
- else {
- if (!(p = strrdirsep(name))) {
- p = name;
- }
- else {
- while (isdirsep(*p)) p++; /* skip last / */
+ 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;
}
-#if USE_NTFS
- n = ntfs_tail(p) - p;
-#else
- n = chompdirsep(p) - p;
-#endif
- if (NIL_P(fext) || !(f = rmext(p, n, StringValueCStr(fext)))) {
- f = n;
+ p = name;
+ }
+ else {
+ while (isdirsep(*p)) p++; /* skip last / */
+ if (NIL_P(fext) || !(f = rmext(p, StringValueCStr(fext)))) {
+ f = chompdirsep(p) - p;
}
- if (f == RSTRING(fname)->len) return fname;
}
basename = rb_str_new(p, f);
OBJ_INFECT(basename, fname);
@@ -2949,7 +2834,7 @@ static VALUE
rb_file_s_dirname(klass, fname)
VALUE klass, fname;
{
- char *name, *root, *p;
+ const char *name, *root, *p;
VALUE dirname;
name = StringValueCStr(fname);
@@ -2969,8 +2854,9 @@ rb_file_s_dirname(klass, fname)
return rb_str_new2(".");
#ifdef DOSISH_DRIVE_LETTER
if (has_drive_letter(name) && isdirsep(*(name + 2))) {
+ const char *top = skiproot(name + 2);
dirname = rb_str_new(name, 3);
- rb_str_cat(dirname, skiproot(name + 2), p - skiproot(name + 2));
+ rb_str_cat(dirname, top, p - top);
}
else
#endif
@@ -3001,49 +2887,22 @@ static VALUE
rb_file_s_extname(klass, fname)
VALUE klass, fname;
{
- const char *name, *p, *e;
+ char *name, *p, *e;
VALUE extname;
name = StringValueCStr(fname);
p = strrdirsep(name); /* get the last path component */
if (!p)
- p = name;
+ p = name;
else
- name = ++p;
-
- e = 0;
- while (*p) {
- if (*p == '.' || istrailinggabage(*p)) {
-#if USE_NTFS
- const char *last = p++, *dot = last;
- while (istrailinggabage(*p)) {
- if (*p == '.') dot = p;
- p++;
- }
- if (!*p || *p == ':') {
- p = last;
- break;
- }
- e = dot;
- continue;
-#else
- e = p; /* get the last dot of the last component */
-#endif
- }
-#if USE_NTFS
- else if (*p == ':') {
- break;
- }
-#endif
- else if (isdirsep(*p))
- break;
- p = CharNext(p);
- }
- if (!e || e == name || e+1 == p) /* no dot, or the only dot is first or end? */
- return rb_str_new(0, 0);
- extname = rb_str_new(e, p - e); /* keep the dot, too! */
- OBJ_INFECT(extname, fname);
- return extname;
+ p++;
+
+ e = strrchr(p, '.'); /* get the last dot of the last component */
+ if (!e || e == p || !e[1]) /* no dot, or the only dot is first or end? */
+ return rb_str_new2("");
+ extname = rb_str_new(e, chompdirsep(e) - e); /* keep the dot, too! */
+ OBJ_INFECT(extname, fname);
+ return extname;
}
/*
@@ -3245,7 +3104,7 @@ rb_file_truncate(obj, len)
f = GetWriteFile(fptr);
fflush(f);
fseeko(f, (off_t)0, SEEK_CUR);
-#ifdef HAVE_FTRUNCATE
+#ifdef HAVE_TRUNCATE
if (ftruncate(fileno(f), pos) < 0)
rb_sys_fail(fptr->path);
#else
@@ -3273,10 +3132,8 @@ rb_file_truncate(obj, len)
# endif
#ifdef __CYGWIN__
-#include <winerror.h>
-extern unsigned long __attribute__((stdcall)) GetLastError(void);
-
static int
+#include <winerror.h>
cygwin_flock(int fd, int op)
{
int old_errno = errno;
@@ -3889,7 +3746,7 @@ rb_stat_grpowned(obj)
VALUE obj;
{
#ifndef _WIN32
- if (get_stat(obj)->st_gid == getegid()) return Qtrue;
+ if (group_member(get_stat(obj)->st_gid)) return Qtrue;
#endif
return Qfalse;
}
@@ -4254,11 +4111,19 @@ is_absolute_path(path)
return 0;
}
-#ifndef DOSISH
+#ifndef ENABLE_PATH_CHECK
+# if defined DOSISH || defined __CYGWIN__
+# define ENABLE_PATH_CHECK 0
+# else
+# define ENABLE_PATH_CHECK 1
+# endif
+#endif
+
+#if ENABLE_PATH_CHECK
static int
-path_check_0(fpath, loadpath)
+path_check_0(fpath, execpath)
VALUE fpath;
- int loadpath;
+ int execpath;
{
struct stat st;
char *p0 = StringValueCStr(fpath);
@@ -4273,7 +4138,7 @@ path_check_0(fpath, loadpath)
rb_str_cat2(newpath, "/");
rb_str_cat2(newpath, p0);
- return path_check_0(newpath, loadpath);
+ p0 = RSTRING(fpath = newpath)->ptr;
}
for (;;) {
#ifndef S_IWOTH
@@ -4281,10 +4146,11 @@ path_check_0(fpath, loadpath)
#endif
if (stat(p0, &st) == 0 && S_ISDIR(st.st_mode) && (st.st_mode & S_IWOTH)
#ifdef S_ISVTX
- && (loadpath || !(st.st_mode & S_ISVTX))
+ && !(p && execpath && (st.st_mode & S_ISVTX))
#endif
) {
- rb_warn("Insecure world writable dir %s, mode 0%o", p0, st.st_mode);
+ rb_warn("Insecure world writable dir %s in %sPATH, mode 0%o",
+ p0, (execpath ? "" : "LOAD_"), st.st_mode);
if (p) *p = '/';
return 0;
}
@@ -4301,7 +4167,7 @@ static int
fpath_check(path)
char *path;
{
-#ifndef DOSISH
+#if ENABLE_PATH_CHECK
return path_check_0(rb_str_new2(path), Qfalse);
#else
return 1;
@@ -4312,7 +4178,7 @@ int
rb_path_check(path)
char *path;
{
-#ifndef DOSISH
+#if ENABLE_PATH_CHECK
char *p0, *p, *pend;
const char sep = PATH_SEP_CHAR;
@@ -4472,9 +4338,6 @@ rb_find_file(path)
}
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 {
@@ -4484,7 +4347,9 @@ rb_find_file(path)
if (!lpath) {
return 0; /* no path, no load */
}
- f = dln_find_file(f, lpath);
+ if (!(f = dln_find_file(f, lpath))) {
+ return 0;
+ }
if (rb_safe_level() >= 1 && !fpath_check(f)) {
rb_raise(rb_eSecurityError, "loading from unsafe file %s", f);
}
diff --git a/gc.c b/gc.c
index d0d00f934e..9ac3bfbf6f 100644
--- a/gc.c
+++ b/gc.c
@@ -2,8 +2,8 @@
gc.c -
- $Author: matz $
- $Date: 2006/08/25 08:12:46 $
+ $Author$
+ $Date$
created at: Tue Oct 5 09:44:46 JST 1993
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -30,20 +30,6 @@
#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
@@ -392,9 +378,6 @@ rb_newobj()
{
VALUE obj;
- if (during_gc)
- rb_bug("object allocation during garbage collection phase");
-
if (!freelist) garbage_collect();
obj = (VALUE)freelist;
@@ -426,6 +409,9 @@ rb_data_object_alloc(klass, datap, dmark, dfree)
extern st_table *rb_class_tbl;
VALUE *rb_gc_stack_start = 0;
+#ifdef __ia64
+VALUE *rb_gc_register_stack_start = 0;
+#endif
#ifdef DJGPP
/* set stack size (http://www.delorie.com/djgpp/v2faq/faq15_9.html) */
@@ -438,7 +424,7 @@ static unsigned int STACK_LEVEL_MAX = 65535;
unsigned int _stacksize = 262144;
# define STACK_LEVEL_MAX (_stacksize - 4096)
# undef HAVE_GETRLIMIT
-#elif defined(HAVE_GETRLIMIT)
+#elif defined(HAVE_GETRLIMIT) || defined(_WIN32)
static unsigned int STACK_LEVEL_MAX = 655300;
#else
# define STACK_LEVEL_MAX 655300
@@ -448,23 +434,24 @@ static unsigned int STACK_LEVEL_MAX = 655300;
# 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__)
+# if defined(__GNUC__) && defined(USE_BUILTIN_FRAME_ADDRESS) && !defined(__ia64)
# if ( __GNUC__ == 3 && __GNUC_MINOR__ > 0 ) || __GNUC__ > 3
__attribute__ ((noinline))
# endif
-static void
-stack_end_address(VALUE **stack_end_p)
+static VALUE *
+stack_end_address(void)
{
- VALUE stack_end;
- *stack_end_p = &stack_end;
+ return (VALUE *)__builtin_frame_address(0);
}
-# define SET_STACK_END VALUE *stack_end; stack_end_address(&stack_end)
+# define SET_STACK_END VALUE *stack_end = stack_end_address()
# else
# define SET_STACK_END VALUE *stack_end = alloca(1)
# endif
# define STACK_END (stack_end)
#endif
-#if STACK_GROW_DIRECTION < 0
+#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)
@@ -1387,23 +1374,10 @@ garbage_collect()
else
rb_gc_mark_locations(rb_gc_stack_start, (VALUE*)STACK_END + 1);
#endif
-#ifdef __ia64__
+#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);
- }
+ rb_gc_mark_locations(rb_gc_register_stack_start, (VALUE*)rb_ia64_bsp());
#endif
#if defined(__human68k__) || defined(__mc68000__)
rb_gc_mark_locations((VALUE*)((char*)STACK_END + 2),
@@ -1479,6 +1453,28 @@ void
Init_stack(addr)
VALUE *addr;
{
+#ifdef __ia64
+ if (rb_gc_register_stack_start == 0) {
+# 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.
+ */
+ rb_gc_register_stack_start = (4ULL<<61);
+# elif defined(HAVE___LIBC_IA64_REGISTER_BACKING_STORE_BASE)
+# pragma weak __libc_ia64_register_backing_store_base
+ extern unsigned long __libc_ia64_register_backing_store_base;
+ rb_gc_register_stack_start = (VALUE*)__libc_ia64_register_backing_store_base;
+# endif
+ }
+ {
+ VALUE *bsp = (VALUE*)rb_ia64_bsp();
+ if (rb_gc_register_stack_start == 0 ||
+ bsp < rb_gc_register_stack_start) {
+ rb_gc_register_stack_start = bsp;
+ }
+ }
+#endif
#if defined(_WIN32) || defined(__CYGWIN__)
MEMORY_BASIC_INFORMATION m;
memset(&m, 0, sizeof(m));
@@ -1487,8 +1483,10 @@ Init_stack(addr)
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;
+ {
+ extern void *STACK_END_ADDRESS;
+ rb_gc_stack_start = STACK_END_ADDRESS;
+ }
#else
if (!addr) addr = (VALUE *)&addr;
STACK_UPPER(&addr, addr, ++addr);
@@ -1515,6 +1513,50 @@ Init_stack(addr)
#endif
}
+void ruby_init_stack(VALUE *addr
+#ifdef __ia64
+ , void *bsp
+#endif
+ )
+{
+ if (!rb_gc_stack_start ||
+ STACK_UPPER(&addr,
+ rb_gc_stack_start > addr,
+ rb_gc_stack_start < addr)) {
+ rb_gc_stack_start = addr;
+ }
+#ifdef __ia64
+ if (!rb_gc_register_stack_start ||
+ (VALUE*)bsp < rb_gc_register_stack_start) {
+ rb_gc_register_stack_start = (VALUE*)bsp;
+ }
+#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);
+ }
+ }
+#elif defined _WIN32
+ {
+ MEMORY_BASIC_INFORMATION mi;
+ DWORD size;
+ DWORD space;
+
+ if (VirtualQuery(&mi, &mi, sizeof(mi))) {
+ size = (char *)mi.BaseAddress - (char *)mi.AllocationBase;
+ space = size / 5;
+ if (space > 1024*1024) space = 1024*1024;
+ STACK_LEVEL_MAX = (size - space) / sizeof(VALUE);
+ }
+ }
+#endif
+}
/*
* Document-class: ObjectSpace
@@ -1557,6 +1599,38 @@ Init_heap()
}
static VALUE
+os_live_obj()
+{
+ int i;
+ int n = 0;
+
+ for (i = 0; i < heaps_used; i++) {
+ RVALUE *p, *pend;
+
+ p = heaps[i].slot; pend = p + heaps[i].limit;
+ for (;p < pend; p++) {
+ if (p->as.basic.flags) {
+ switch (TYPE(p)) {
+ case T_ICLASS:
+ case T_VARMAP:
+ case T_SCOPE:
+ case T_NODE:
+ continue;
+ case T_CLASS:
+ if (FL_TEST(p, FL_SINGLETON)) continue;
+ default:
+ if (!p->as.basic.klass) continue;
+ rb_yield((VALUE)p);
+ n++;
+ }
+ }
+ }
+ }
+
+ return INT2FIX(n);
+}
+
+static VALUE
os_obj_of(of)
VALUE of;
{
@@ -1570,7 +1644,6 @@ os_obj_of(of)
for (;p < pend; p++) {
if (p->as.basic.flags) {
switch (TYPE(p)) {
- case T_NONE:
case T_ICLASS:
case T_VARMAP:
case T_SCOPE:
@@ -1580,7 +1653,7 @@ os_obj_of(of)
if (FL_TEST(p, FL_SINGLETON)) continue;
default:
if (!p->as.basic.klass) continue;
- if (!of || rb_obj_is_kind_of((VALUE)p, of)) {
+ if (rb_obj_is_kind_of((VALUE)p, of)) {
rb_yield((VALUE)p);
n++;
}
@@ -1634,9 +1707,11 @@ os_each_obj(argc, argv)
rb_secure(4);
if (rb_scan_args(argc, argv, "01", &of) == 0) {
- of = 0;
+ return os_live_obj();
+ }
+ else {
+ return os_obj_of(of);
}
- return os_obj_of(of);
}
static VALUE finalizers;
@@ -1880,7 +1955,6 @@ id2ref(obj, objid)
VALUE obj, objid;
{
unsigned long ptr, p0;
- int type;
rb_secure(4);
p0 = ptr = NUM2ULONG(objid);
@@ -1897,8 +1971,7 @@ id2ref(obj, objid)
return ID2SYM(symid);
}
- if (!is_pointer_to_heap((void *)ptr)||
- (type = BUILTIN_TYPE(ptr)) >= T_BLKTAG || type == T_ICLASS) {
+ 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 || RBASIC(ptr)->klass == 0) {
diff --git a/hash.c b/hash.c
index e3f6dc2050..e2f7345f5a 100644
--- a/hash.c
+++ b/hash.c
@@ -2,8 +2,8 @@
hash.c -
- $Author: shyouhei $
- $Date: 2006/12/05 18:53:00 $
+ $Author$
+ $Date$
created at: Mon Nov 22 18:51:18 JST 1993
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -590,23 +590,6 @@ index_i(key, value, args)
return ST_CONTINUE;
}
-static VALUE
-rb_hash_delete_key(hash, key)
- VALUE hash, key;
-{
- st_data_t ktmp = (st_data_t)key, val;
-
- if (RHASH(hash)->iter_lev > 0) {
- if (st_delete_safe(RHASH(hash)->tbl, &ktmp, &val, Qundef)) {
- FL_SET(hash, HASH_DELETED);
- return (VALUE)val;
- }
- }
- else if (st_delete(RHASH(hash)->tbl, &ktmp, &val))
- return (VALUE)val;
- return Qundef;
-}
-
/*
* call-seq:
* hsh.index(value) => key
@@ -686,8 +669,14 @@ rb_hash_delete(hash, key)
VALUE val;
rb_hash_modify(hash);
- val = rb_hash_delete_key(hash, key);
- if (val != Qundef) return val;
+ if (RHASH(hash)->iter_lev > 0) {
+ 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, (st_data_t*)&key, &val))
+ return val;
if (rb_block_given_p()) {
return rb_yield(key);
}
@@ -695,6 +684,7 @@ rb_hash_delete(hash, key)
}
struct shift_var {
+ int stop;
VALUE key;
VALUE val;
};
@@ -705,23 +695,13 @@ shift_i(key, value, var)
struct shift_var *var;
{
if (key == Qundef) return ST_CONTINUE;
- if (var->key != Qundef) return ST_STOP;
+ if (var->stop) return ST_STOP;
+ var->stop = 1;
var->key = key;
var->val = value;
return ST_DELETE;
}
-static int
-shift_i_safe(key, value, var)
- VALUE key, value;
- struct shift_var *var;
-{
- if (key == Qundef) return ST_CONTINUE;
- var->key = key;
- var->val = value;
- return ST_STOP;
-}
-
/*
* call-seq:
* hsh.shift -> anArray or obj
@@ -742,21 +722,10 @@ rb_hash_shift(hash)
struct shift_var var;
rb_hash_modify(hash);
- var.key = Qundef;
- if (RHASH(hash)->iter_lev > 0) {
- rb_hash_foreach(hash, shift_i_safe, (st_data_t)&var);
- if (var.key != Qundef) {
- st_data_t key = var.key;
- if (st_delete_safe(RHASH(hash)->tbl, &key, 0, Qundef)) {
- FL_SET(hash, HASH_DELETED);
- }
- }
- }
- else {
- rb_hash_foreach(hash, shift_i, (st_data_t)&var);
- }
+ var.stop = 0;
+ rb_hash_foreach(hash, shift_i, (st_data_t)&var);
- if (var.key != Qundef) {
+ if (var.stop) {
return rb_assoc_new(var.key, var.val);
}
else if (FL_TEST(hash, HASH_PROC_DEFAULT)) {
@@ -773,7 +742,7 @@ delete_if_i(key, value, hash)
{
if (key == Qundef) return ST_CONTINUE;
if (RTEST(rb_yield_values(2, key, value))) {
- rb_hash_delete_key(hash, key);
+ rb_hash_delete(hash, key);
}
return ST_CONTINUE;
}
@@ -2445,7 +2414,39 @@ env_update(env, hash)
* 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>.
- *
+ *
+ * <code>Hash</code> uses <code>key.eql?</code> to test keys for equality.
+ * If you need to use instances of your own classes as keys in a <code>Hash</code>,
+ * it is recommended that you define both the <code>eql?</code> and <code>hash</code>
+ * methods. The <code>hash</code> method must have the property that
+ * <code>a.eql?(b)</code> implies <code>a.hash == b.hash</code>.
+ *
+ * class MyClass
+ * attr_reader :str
+ * def initialize(str)
+ * @str = str
+ * end
+ * def eql?(o)
+ * o.is_a?(MyClass) && str == o.str
+ * end
+ * def hash
+ * @str.hash
+ * end
+ * end
+ *
+ * a = MyClass.new("some string")
+ * b = MyClass.new("some string")
+ * a.eql? b #=> true
+ *
+ * h = {}
+ *
+ * h[a] = 1
+ * h[a] #=> 1
+ * h[b] #=> 1
+ *
+ * h[b] = 2
+ * h[a] #=> 2
+ * h[b] #=> 2
*/
void
diff --git a/ia64.s b/ia64.s
new file mode 100644
index 0000000000..ba5241daf2
--- /dev/null
+++ b/ia64.s
@@ -0,0 +1,33 @@
+// rb_ia64_flushrs and rb_ia64_bsp is written in IA64 assembly language
+// because Intel Compiler for IA64 doesn't support inline assembly.
+//
+// This file is based on following C program compiled by gcc.
+//
+// void rb_ia64_flushrs(void) { __builtin_ia64_flushrs(); }
+// void *rb_ia64_bsp(void) { return __builtin_ia64_bsp(); }
+//
+ .file "ia64.c"
+ .text
+ .align 16
+ .global rb_ia64_flushrs#
+ .proc rb_ia64_flushrs#
+rb_ia64_flushrs:
+ .prologue
+ .body
+ flushrs
+ ;;
+ nop.i 0
+ br.ret.sptk.many b0
+ .endp rb_ia64_flushrs#
+ .align 16
+ .global rb_ia64_bsp#
+ .proc rb_ia64_bsp#
+rb_ia64_bsp:
+ .prologue
+ .body
+ nop.m 0
+ ;;
+ mov r8 = ar.bsp
+ br.ret.sptk.many b0
+ .endp rb_ia64_bsp#
+ .ident "GCC: (GNU) 3.3.5 (Debian 1:3.3.5-13)"
diff --git a/inits.c b/inits.c
index 4c6008e4b0..052573a443 100644
--- a/inits.c
+++ b/inits.c
@@ -2,8 +2,8 @@
inits.c -
- $Author: dave $
- $Date: 2003/12/19 03:58:57 $
+ $Author$
+ $Date$
created at: Tue Dec 28 16:01:58 JST 1993
Copyright (C) 1993-2003 Yukihiro Matsumoto
diff --git a/instruby.rb b/instruby.rb
index 1237b01abc..a5606e8452 100644..100755
--- a/instruby.rb
+++ b/instruby.rb
@@ -1,7 +1,7 @@
#!./miniruby
load "./rbconfig.rb"
-include Config
+include RbConfig
srcdir = File.dirname(__FILE__)
$:.unshift File.expand_path("lib", srcdir)
@@ -17,12 +17,17 @@ File.umask(0)
def parse_args()
$mantype = 'doc'
$destdir = nil
+ $extout = nil
$make = 'make'
$mflags = []
$install = []
+ $installed_list = nil
+ $dryrun = false
+ $rdocdir = nil
opt = OptionParser.new
opt.on('-n') {$dryrun = true}
opt.on('--dest-dir=DIR') {|dir| $destdir = dir}
+ opt.on('--extout=DIR') {|dir| $extout = (dir unless dir.empty?)}
opt.on('--make=COMMAND') {|make| $make = make}
opt.on('--mantype=MAN') {|man| $mantype = man}
opt.on('--make-flags=FLAGS', '--mflags', Shellwords) do |v|
@@ -31,7 +36,13 @@ def parse_args()
end
$mflags.concat(v)
end
- opt.on('--install=TYPE', [:bin, :lib, :man]) {|ins| $install << ins}
+ opt.on('-i', '--install=TYPE',
+ [:local, :bin, :lib, :man, :ext, :"ext-arch", :"ext-comm", :rdoc]) do |ins|
+ $install << ins
+ end
+ opt.on('--installed-list [FILENAME]') {|name| $installed_list = name}
+ opt.on('--rdoc-output [DIR]') {|dir| $rdocdir = dir}
+
opt.parse! rescue abort [$!.message, opt].join("\n")
$make, *rest = Shellwords.shellwords($make)
@@ -41,6 +52,10 @@ def parse_args()
grep(/\A-(?!-).*#{'%c' % flag}/i) { return true }
false
end
+ def $mflags.defined?(var)
+ grep(/\A#{var}=(.*)/) {return $1}
+ false
+ end
if $mflags.set?(?n)
$dryrun = true
@@ -48,37 +63,85 @@ def parse_args()
$mflags << '-n' if $dryrun
end
- $mflags << "DESTDIR=#{$destdir}"
+ $destdir ||= $mflags.defined?("DESTDIR")
+ if $extout ||= $mflags.defined?("EXTOUT")
+ Config.expand($extout)
+ end
$continue = $mflags.set?(?k)
+
+ if $installed_list ||= $mflags.defined?('INSTALLED_LIST')
+ Config.expand($installed_list, Config::CONFIG)
+ $installed_list = open($installed_list, "ab")
+ $installed_list.sync = true
+ end
+
+ $rdocdir ||= $mflags.defined?('RDOCOUT')
end
parse_args()
-include FileUtils::Verbose
+include FileUtils
include FileUtils::NoWrite if $dryrun
@fileutils_output = STDOUT
@fileutils_label = ''
-def install?(type)
- yield if $install.empty? or $install.include?(type)
+$install_procs = Hash.new {[]}
+def install?(*types, &block)
+ $install_procs[:all] <<= block
+ types.each do |type|
+ $install_procs[type] <<= block
+ end
end
def install(src, dest, options = {})
options[:preserve] = true
- super
+ super(src, with_destdir(dest), options)
+ if $installed_list
+ dest = File.join(dest, File.basename(src)) if $made_dirs[dest]
+ $installed_list.puts dest
+ end
+end
+
+def ln_sf(src, dest)
+ super(src, with_destdir(dest))
+ $installed_list.puts dest if $installed_list
end
$made_dirs = {}
def makedirs(dirs)
dirs = fu_list(dirs)
- dirs.reject! do |dir|
- $made_dirs.fetch(dir) do
+ dirs.collect! do |dir|
+ realdir = with_destdir(dir)
+ realdir unless $made_dirs.fetch(dir) do
$made_dirs[dir] = true
- File.directory?(dir)
+ $installed_list.puts(File.join(dir, "")) if $installed_list
+ File.directory?(realdir)
end
+ end.compact!
+ super(dirs, :mode => 0755) unless dirs.empty?
+end
+
+def install_recursive(src, dest, options = {})
+ noinst = options.delete(:no_install)
+ subpath = src.size..-1
+ Dir.glob("#{src}/**/*", File::FNM_DOTMATCH) do |src|
+ next if /\A\.{1,2}\z/ =~ (base = File.basename(src))
+ next if noinst and File.fnmatch?(noinst, File.basename(src))
+ d = dest + src[subpath]
+ if File.directory?(src)
+ makedirs(d)
+ else
+ install src, d
+ end
+ end
+end
+
+def open_for_install(path, mode, &block)
+ unless $dryrun
+ open(with_destdir(path), mode, &block)
end
- super(dirs, :mode => 0755, :verbose => true) unless dirs.empty?
+ $installed_list.puts path if /^w/ =~ mode and $installed_list
end
def with_destdir(dir)
@@ -93,39 +156,30 @@ 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"))
+bindir = CONFIG["bindir"]
+libdir = CONFIG["libdir"]
+rubylibdir = CONFIG["rubylibdir"]
+archlibdir = CONFIG["archdir"]
+sitelibdir = CONFIG["sitelibdir"]
+sitearchlibdir = CONFIG["sitearchdir"]
+mandir = 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]
+install?(:local, :arch, :bin) do
+ puts "installing binary commands"
-install?(:bin) do
- ruby_bin = File.join(bindir, ruby_install_name)
+ makedirs [bindir, libdir, archlibdir]
- install ruby_install_name+exeext, ruby_bin+exeext, :mode => 0755
- if File.exist?(ruby_install_name+exeext+".manifest")
- install ruby_install_name+exeext+".manifest", bindir, :mode => 0644
- end
+ install ruby_install_name+exeext, bindir, :mode => 0755
if rubyw_install_name and !rubyw_install_name.empty?
install rubyw_install_name+exeext, bindir, :mode => 0755
- if File.exist?(rubyw_install_name+exeext+".manifest")
- install rubyw_install_name+exeext+".manifest", bindir, :mode => 0644
- end
end
if enable_shared and dll != lib
install dll, bindir, :mode => 0755
- if File.exist?(dll+".manifest")
- install dll+".manifest", bindir, :mode => 0644
- end
end
install lib, libdir, :mode => 0755 unless lib == arc
install arc, libdir, :mode => 0644
@@ -144,101 +198,158 @@ install?(:bin) do
end
end
-Dir.chdir srcdir
+if $extout
+ extout = "#$extout"
+ install?(:ext, :arch, :'ext-arch') do
+ puts "installing extension objects"
+ makedirs [archlibdir, sitearchlibdir]
+ if noinst = CONFIG["no_install_files"] and noinst.empty?
+ noinst = nil
+ end
+ install_recursive("#{extout}/#{CONFIG['arch']}", archlibdir, :no_install => noinst)
+ end
+ install?(:ext, :comm, :'ext-comm') do
+ puts "installing extension scripts"
+ makedirs [rubylibdir, sitelibdir]
+ install_recursive("#{extout}/common", rubylibdir)
+ end
+end
+
+install?(:rdoc) do
+ if $rdocdir
+ puts "installing rdoc"
-install?(:lib) do
-ruby_shebang = File.join(CONFIG["bindir"], ruby_install_name)
-if File::ALT_SEPARATOR
- ruby_bin_dosish = ruby_shebang.tr(File::SEPARATOR, File::ALT_SEPARATOR)
+ ridatadir = File.join(CONFIG['datadir'], 'ri/$(MAJOR).$(MINOR)/system')
+ Config.expand(ridatadir)
+ makedirs [ridatadir]
+ install_recursive($rdocdir, ridatadir)
+ end
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)
+install?(:local, :comm, :bin) do
+ puts "installing command scripts"
- install src, dest, :mode => 0755
+ Dir.chdir srcdir
+ makedirs [bindir, rubylibdir]
- next if $dryrun
+ ruby_shebang = File.join(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
- shebang = ''
- body = ''
- open(dest, "r+") { |f|
- shebang = f.gets
- body = f.read
+ name = ruby_install_name.sub(/ruby/, File.basename(src))
+ dest = File.join(bindir, name)
- if shebang.sub!(/^\#!.*?ruby\b/) {"#!" + ruby_shebang}
- f.rewind
- f.print shebang, body
- f.truncate(f.pos)
- end
- }
+ install src, dest, :mode => 0755
- if ruby_bin_dosish
- batfile = File.join(CONFIG["bindir"], name + ".bat")
- open(with_destdir(batfile), "w") { |b|
- b.print <<EOH, shebang, body, <<EOF
+ next if $dryrun
+
+ shebang = ''
+ body = ''
+ open_for_install(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(bindir, name + ".bat")
+ open_for_install(batfile, "wb") {|b|
+ b.print((<<EOH+shebang+body+<<EOF).gsub(/\r?\n/, "\r\n"))
@echo off
-if not "%~d0" == "~d0" goto WinNT
+@if not "%~d0" == "~d0" goto WinNT
#{ruby_bin_dosish} -x "#{batfile}" %1 %2 %3 %4 %5 %6 %7 %8 %9
-goto endofruby
+@goto endofruby
:WinNT
"%~dp0#{ruby_install_name}" -x "%~f0" %*
-goto endofruby
+@goto endofruby
EOH
__END__
:endofruby
EOF
- }
+ }
+ end
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
-end
+install?(:local, :comm, :lib) do
+ puts "installing library scripts"
-install?(:bin) do
-for f in Dir["*.h"]
- install f, archlibdir, :mode => 0644
-end
+ Dir.chdir srcdir
+ makedirs [rubylibdir]
-if RUBY_PLATFORM =~ /mswin32|mingw|bccwin32/
- makedirs File.join(archlibdir, "win32")
- install "win32/win32.h", File.join(archlibdir, "win32"), :mode => 0644
+ for f in Dir["lib/**/*{.rb,help-message}"]
+ dir = File.dirname(f).sub!(/\Alib/, rubylibdir) || rubylibdir
+ makedirs dir
+ install f, dir, :mode => 0644
+ end
end
+
+install?(:local, :arch, :lib) do
+ puts "installing headers"
+
+ Dir.chdir(srcdir)
+ makedirs [archlibdir]
+ for f in Dir["*.h"]
+ install f, archlibdir, :mode => 0644
+ end
+
+ if RUBY_PLATFORM =~ /mswin32|mingw|bccwin32/
+ win32libdir = File.join(archlibdir, "win32")
+ makedirs win32libdir
+ install "win32/win32.h", win32libdir, :mode => 0644
+ end
end
-install?(:man) do
-for mdoc in Dir["*.[1-9]"]
- next unless File.file?(mdoc) and open(mdoc){|fh| fh.read(1) == '.'}
+install?(:local, :comm, :man) do
+ puts "installing manpages"
- section = mdoc[-1,1]
+ Dir.chdir(srcdir)
+ for mdoc in Dir["*.[1-9]"]
+ next unless File.file?(mdoc) and open(mdoc){|fh| fh.read(1) == '.'}
- destdir = mandir + section
- destfile = File.join(destdir, mdoc.sub(/ruby/, ruby_install_name))
+ destdir = mandir + mdoc[/(\d+)$/]
+ destfile = File.join(destdir, mdoc.sub(/ruby/, ruby_install_name))
- makedirs destdir
+ makedirs destdir
- if $mantype == "doc"
- install mdoc, destfile, :mode => 0644
- else
- require 'mdoc2man.rb'
+ if $mantype == "doc"
+ install mdoc, destfile, :mode => 0644
+ else
+ require 'mdoc2man.rb'
- w = Tempfile.open(mdoc)
+ w = Tempfile.open(mdoc)
- open(mdoc) { |r|
- Mdoc2Man.mdoc2man(r, w)
- }
+ open(mdoc) { |r|
+ Mdoc2Man.mdoc2man(r, w)
+ }
- w.close
+ w.close
- install w.path, destfile, :mode => 0644
+ install w.path, destfile, :mode => 0644
+ end
end
end
+
+$install.concat ARGV.collect {|n| n.intern}
+$install << :local << :ext if $install.empty?
+$install.each do |inst|
+ $install_procs[inst].each do |block|
+ dir = Dir.pwd
+ begin
+ block.call
+ ensure
+ Dir.chdir(dir)
+ end
+ end
end
# vi:set sw=2:
diff --git a/intern.h b/intern.h
index 072997503a..d063d53495 100644
--- a/intern.h
+++ b/intern.h
@@ -2,8 +2,8 @@
intern.h -
- $Author: matz $
- $Date: 2006/05/16 00:25:18 $
+ $Author$
+ $Date$
created at: Thu Jun 10 14:22:17 JST 1993
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -70,6 +70,7 @@ VALUE rb_str_to_inum _((VALUE, int, int));
VALUE rb_cstr2inum _((const char*, int));
VALUE rb_str2inum _((VALUE, int));
VALUE rb_big2str _((VALUE, int));
+VALUE rb_big2str0 _((VALUE, int, int));
long rb_big2long _((VALUE));
#define rb_big2int(x) rb_big2long(x)
unsigned long rb_big2ulong _((VALUE));
@@ -113,7 +114,6 @@ 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_big_rshift(VALUE, VALUE);
VALUE rb_class_private_instance_methods _((int, VALUE*, VALUE));
VALUE rb_obj_singleton_methods _((int, VALUE*, VALUE));
void rb_define_method_id _((VALUE, ID, VALUE (*)(ANYARGS), int));
@@ -204,14 +204,17 @@ int rb_thread_alone _((void));
void rb_thread_polling _((void));
void rb_thread_sleep _((int));
void rb_thread_sleep_forever _((void));
+enum rb_thread_status rb_thread_status _((VALUE));
VALUE rb_thread_stop _((void));
VALUE rb_thread_wakeup _((VALUE));
+VALUE rb_thread_wakeup_alive _((VALUE));
VALUE rb_thread_run _((VALUE));
VALUE rb_thread_kill _((VALUE));
+VALUE rb_thread_alive_p _((VALUE));
VALUE rb_thread_create _((VALUE (*)(ANYARGS), void*));
void rb_thread_interrupt _((void));
void rb_thread_trap_eval _((VALUE, int, int));
-void rb_thread_signal_raise _((char*));
+void rb_thread_signal_raise _((int));
void rb_thread_signal_exit _((void));
int rb_thread_select _((int, fd_set *, fd_set *, fd_set *, struct timeval *));
void rb_thread_wait_for _((struct timeval));
@@ -231,6 +234,7 @@ 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 *));
+VALUE rb_file_directory_p _((VALUE,VALUE));
/* gc.c */
NORETURN(void rb_memerror __((void)));
int ruby_stack_check _((void));
@@ -337,6 +341,7 @@ int rb_is_class_id _((ID));
int rb_is_local_id _((ID));
int rb_is_junk_id _((ID));
int rb_symname_p _((const char*));
+int rb_sym_interned_p _((VALUE));
VALUE rb_backref_get _((void));
void rb_backref_set _((VALUE));
VALUE rb_lastline_get _((void));
@@ -369,6 +374,8 @@ VALUE rb_reg_match2 _((VALUE));
int rb_reg_options _((VALUE));
void rb_set_kcode _((const char*));
const char* rb_get_kcode _((void));
+void rb_kcode_set_option _((VALUE));
+void rb_kcode_reset_option _((void));
/* ruby.c */
RUBY_EXTERN VALUE rb_argv;
RUBY_EXTERN VALUE rb_argv0;
@@ -390,6 +397,7 @@ void posix_signal _((int, RETSIGTYPE (*)(int)));
void rb_trap_exit _((void));
void rb_trap_exec _((void));
const char *ruby_signal_name _((int));
+void ruby_default_signal _((int));
/* sprintf.c */
VALUE rb_f_sprintf _((int, VALUE*));
/* string.c */
diff --git a/io.c b/io.c
index b59b39c148..8f8dfcdf2e 100644
--- a/io.c
+++ b/io.c
@@ -2,8 +2,8 @@
io.c -
- $Author: matz $
- $Date: 2006/07/31 06:34:09 $
+ $Author$
+ $Date$
created at: Fri Oct 15 18:08:59 JST 1993
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -245,7 +245,6 @@ flush_before_seek(fptr)
if (fptr->mode & FMODE_WBUF) {
io_fflush(GetWriteFile(fptr), fptr);
}
- errno = 0;
return fptr;
}
@@ -319,7 +318,7 @@ ruby_dup(orig)
fd = dup(orig);
if (fd < 0) {
- if (errno == EMFILE || errno == ENFILE) {
+ if (errno == EMFILE || errno == ENFILE || errno == ENOMEM) {
rb_gc();
fd = dup(orig);
}
@@ -669,7 +668,7 @@ rb_io_tell(io)
GetOpenFile(io, fptr);
pos = io_tell(fptr);
- if (pos < 0 && errno) rb_sys_fail(fptr->path);
+ if (pos < 0) rb_sys_fail(fptr->path);
return OFFT2NUM(pos);
}
@@ -684,7 +683,7 @@ rb_io_seek(io, offset, whence)
pos = NUM2OFFT(offset);
GetOpenFile(io, fptr);
pos = io_seek(fptr, pos, whence);
- if (pos < 0 && errno) rb_sys_fail(fptr->path);
+ if (pos < 0) rb_sys_fail(fptr->path);
clearerr(fptr->f);
return INT2FIX(0);
@@ -1053,7 +1052,7 @@ read_buffered_data(ptr, len, f)
#endif
}
-long
+static long
io_fread(ptr, len, fptr)
char *ptr;
long len;
@@ -2169,7 +2168,6 @@ fptr_finalize(fptr, noraise)
{
int n1 = 0, n2 = 0, f1, f2 = -1;
- errno = 0;
if (fptr->f2) {
f2 = fileno(fptr->f2);
while (n2 = 0, fflush(fptr->f2) < 0) {
@@ -3040,7 +3038,7 @@ pipe_open(pstr, pname, mode)
#endif
volatile int doexec;
- if (!pname) pname = StringValuePtr(pstr);
+ if (!pname) pname = StringValueCStr(pstr);
doexec = (strcmp("-", pname) != 0);
#if defined(DJGPP) || defined(__human68k__) || defined(__VMS) || defined(_WIN32)
@@ -3256,7 +3254,7 @@ rb_io_s_popen(argc, argv, klass)
mode = rb_io_modenum_mode(FIX2INT(pmode));
}
else {
- mode = rb_io_flags_mode(rb_io_mode_flags(StringValueCStr(pmode)));
+ mode = rb_io_flags_mode(rb_io_mode_flags(StringValuePtr(pmode)));
}
SafeStringValue(pname);
port = pipe_open(pname, 0, mode);
@@ -3284,13 +3282,12 @@ rb_open_file(argc, argv, io)
VALUE io;
{
VALUE fname, vmode, perm;
- char *path, *mode;
+ char *mode;
int flags, fmode;
rb_scan_args(argc, argv, "12", &fname, &vmode, &perm);
SafeStringValue(fname);
- path = StringValueCStr(fname);
if (FIXNUM_P(vmode) || !NIL_P(perm)) {
if (FIXNUM_P(vmode)) {
flags = FIX2INT(vmode);
@@ -3301,11 +3298,11 @@ rb_open_file(argc, argv, io)
}
fmode = NIL_P(perm) ? 0666 : NUM2INT(perm);
- rb_file_sysopen_internal(io, path, flags, fmode);
+ rb_file_sysopen_internal(io, RSTRING(fname)->ptr, flags, fmode);
}
else {
- mode = NIL_P(vmode) ? "r" : StringValueCStr(vmode);
- rb_file_open_internal(io, path, mode);
+ mode = NIL_P(vmode) ? "r" : StringValuePtr(vmode);
+ rb_file_open_internal(io, RSTRING(fname)->ptr, mode);
}
return io;
}
@@ -3658,7 +3655,7 @@ rb_io_reopen(argc, argv, file)
}
if (!NIL_P(nmode)) {
- fptr->mode = rb_io_mode_flags(StringValueCStr(nmode));
+ fptr->mode = rb_io_mode_flags(StringValuePtr(nmode));
}
if (fptr->path) {
@@ -3666,7 +3663,7 @@ rb_io_reopen(argc, argv, file)
fptr->path = 0;
}
- fptr->path = strdup(StringValueCStr(fname));
+ fptr->path = strdup(RSTRING(fname)->ptr);
mode = rb_io_flags_mode(fptr->mode);
if (!fptr->f) {
fptr->f = rb_fopen(fptr->path, mode);
@@ -3677,16 +3674,16 @@ rb_io_reopen(argc, argv, file)
return file;
}
- if (freopen(fptr->path, mode, fptr->f) == 0) {
+ if (freopen(RSTRING(fname)->ptr, mode, fptr->f) == 0) {
rb_sys_fail(fptr->path);
}
#ifdef USE_SETVBUF
if (setvbuf(fptr->f, NULL, _IOFBF, 0) != 0)
- rb_warn("setvbuf() can't be honoured for %s", fptr->path);
+ rb_warn("setvbuf() can't be honoured for %s", RSTRING(fname)->ptr);
#endif
if (fptr->f2) {
- if (freopen(fptr->path, "w", fptr->f2) == 0) {
+ if (freopen(RSTRING(fname)->ptr, "w", fptr->f2) == 0) {
rb_sys_fail(fptr->path);
}
}
@@ -4235,7 +4232,7 @@ rb_io_initialize(argc, argv, io)
}
else {
SafeStringValue(mode);
- flags = rb_io_mode_modenum(StringValueCStr(mode));
+ flags = rb_io_mode_modenum(RSTRING(mode)->ptr);
}
}
else {
@@ -4405,7 +4402,7 @@ next_argv()
retry:
if (RARRAY(rb_argv)->len > 0) {
filename = rb_ary_shift(rb_argv);
- fn = StringValueCStr(filename);
+ fn = StringValuePtr(filename);
if (strlen(fn) == 1 && fn[0] == '-') {
current_file = rb_stdin;
if (ruby_inplace_mode) {
@@ -5066,7 +5063,7 @@ rb_f_syscall(argc, argv)
if (!NIL_P(v)) {
StringValue(v);
rb_str_modify(v);
- arg[i] = (unsigned long)StringValueCStr(v);
+ arg[i] = (unsigned long)RSTRING(v)->ptr;
}
else {
arg[i] = (unsigned long)NUM2LONG(*argv);
@@ -5274,7 +5271,7 @@ rb_io_s_foreach(argc, argv)
else if (!NIL_P(arg.sep)) {
StringValue(arg.sep);
}
- arg.io = rb_io_open(StringValueCStr(fname), "r");
+ arg.io = rb_io_open(RSTRING(fname)->ptr, "r");
if (NIL_P(arg.io)) return Qnil;
return rb_ensure(io_s_foreach, (VALUE)&arg, rb_io_close, arg.io);
@@ -5313,7 +5310,7 @@ rb_io_s_readlines(argc, argv, io)
SafeStringValue(fname);
arg.argc = argc - 1;
- arg.io = rb_io_open(StringValueCStr(fname), "r");
+ arg.io = rb_io_open(RSTRING(fname)->ptr, "r");
if (NIL_P(arg.io)) return Qnil;
return rb_ensure(io_s_readlines, (VALUE)&arg, rb_io_close, arg.io);
}
@@ -5351,7 +5348,7 @@ rb_io_s_read(argc, argv, io)
SafeStringValue(fname);
arg.argc = argc ? 1 : 0;
- arg.io = rb_io_open(StringValueCStr(fname), "r");
+ arg.io = rb_io_open(RSTRING(fname)->ptr, "r");
if (NIL_P(arg.io)) return Qnil;
if (!NIL_P(offset)) {
rb_io_seek(arg.io, offset, SEEK_SET);
@@ -5627,7 +5624,7 @@ opt_i_set(val)
StringValue(val);
if (ruby_inplace_mode) free(ruby_inplace_mode);
ruby_inplace_mode = 0;
- ruby_inplace_mode = strdup(StringValueCStr(val));
+ ruby_inplace_mode = strdup(RSTRING(val)->ptr);
}
/*
diff --git a/lib/.document b/lib/.document
index 542ca3764c..2159be8360 100644
--- a/lib/.document
+++ b/lib/.document
@@ -8,6 +8,7 @@
English.rb
Env.rb
+README
abbrev.rb
base64.rb
benchmark.rb
@@ -23,6 +24,7 @@ debug.rb
delegate.rb
drb
drb.rb
+e2mmap.rb
erb.rb
eregex.rb
fileutils.rb
@@ -36,6 +38,7 @@ getopts.rb
gserver.rb
importenv.rb
ipaddr.rb
+irb
irb.rb
jcode.rb
logger.rb
diff --git a/lib/README b/lib/README
index d60c5cb1e9..19d6309166 100644
--- a/lib/README
+++ b/lib/README
@@ -6,7 +6,7 @@ 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 support
+complex.rb complex number suppor
csv.rb CSV parser/generator
date.rb date object
date/format.rb date parsing and formatting
diff --git a/lib/abbrev.rb b/lib/abbrev.rb
index bf489526cf..6530679681 100644
--- a/lib/abbrev.rb
+++ b/lib/abbrev.rb
@@ -8,7 +8,7 @@
#
# $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: abbrev.rb,v 1.1.2.1 2004/01/20 05:27:12 dave Exp $
+# $Id$
=end
# Calculate the set of unique abbreviations for a given set of strings.
diff --git a/lib/base64.rb b/lib/base64.rb
index d80eb5a570..05be9ddf78 100644
--- a/lib/base64.rb
+++ b/lib/base64.rb
@@ -102,7 +102,7 @@ module Base64
#
# require 'base64'
# data = "Now is the time for all good coders\nto learn Ruby"
- # puts Base64.b64encode(data)
+ # Base64.b64encode(data)
#
# <i>Generates:</i>
#
@@ -110,7 +110,7 @@ module Base64
# UnVieQ==
def b64encode(bin, len = 60)
- encode64(bin).scan(/.{1,#{len}}/) do
+ encode64(bin).scan(/.{1,#{len}}/o) do
print $&, "\n"
end
end
diff --git a/lib/benchmark.rb b/lib/benchmark.rb
index 36cd4b55a9..36e593518f 100644
--- a/lib/benchmark.rb
+++ b/lib/benchmark.rb
@@ -2,7 +2,7 @@
#
# benchmark.rb - a performance benchmarking library
#
-# $Id: benchmark.rb,v 1.8.2.2 2004/04/18 23:20:32 nobu Exp $
+# $Id$
#
# Created by Gotoken (gotoken@notwork.org).
#
@@ -304,10 +304,7 @@ module Benchmark
# Returns the elapsed real time used to execute the given block.
#
def realtime(&blk) # :yield:
- r0 = Time.now
- yield
- r1 = Time.now
- r1.to_f - r0.to_f
+ Benchmark::measure(&blk).real
end
@@ -333,7 +330,7 @@ module Benchmark
# Registers the given label and block pair in the job list.
#
def item(label = "", &blk) # :yield:
- raise ArgumentError, "no block" unless block_given?
+ raise ArgmentError, "no block" unless block_given?
label.concat ' '
w = label.length
@width = w if @width < w
diff --git a/lib/cgi.rb b/lib/cgi.rb
index c07f412442..a442d44930 100644
--- a/lib/cgi.rb
+++ b/lib/cgi.rb
@@ -284,7 +284,7 @@ class CGI
# Standard internet newline sequence
EOL = CR + LF
- REVISION = '$Id: cgi.rb,v 1.68.2.16.2.2 2006/12/03 08:06:27 shugo Exp $' #:nodoc:
+ REVISION = '$Id$' #:nodoc:
NEEDS_BINMODE = true if /WIN/ni.match(RUBY_PLATFORM)
@@ -367,13 +367,13 @@ class CGI
# CGI::unescapeHTML("Usage: foo &quot;bar&quot; &lt;baz&gt;")
# # => "Usage: foo \"bar\" <baz>"
def CGI::unescapeHTML(string)
- string.gsub(/&(.*?);/n) do
+ string.gsub(/&(amp|quot|gt|lt|\#[0-9]+|\#x[0-9A-Fa-f]+);/n) do
match = $1.dup
case match
- when /\Aamp\z/ni then '&'
- when /\Aquot\z/ni then '"'
- when /\Agt\z/ni then '>'
- when /\Alt\z/ni then '<'
+ when 'amp' then '&'
+ when 'quot' then '"'
+ when 'gt' then '>'
+ when 'lt' then '<'
when /\A#0*(\d+)\z/n then
if Integer($1) < 256
Integer($1).chr
@@ -709,13 +709,13 @@ class CGI
require "nkf"
case options["charset"]
when /iso-2022-jp/ni
- content = NKF::nkf('-j', content)
+ content = NKF::nkf('-m0 -x -j', content)
options["language"] = "ja" unless options.has_key?("language")
when /euc-jp/ni
- content = NKF::nkf('-e', content)
+ content = NKF::nkf('-m0 -x -e', content)
options["language"] = "ja" unless options.has_key?("language")
when /shift_jis/ni
- content = NKF::nkf('-s', content)
+ content = NKF::nkf('-m0 -x -s', content)
options["language"] = "ja" unless options.has_key?("language")
end
end
@@ -1032,13 +1032,13 @@ class CGI
if "--" == $2
content_length = -1
end
- boundary_end = $2.dup
+ boundary_end = $2.dup
""
end
body.rewind
- /Content-Disposition:.* filename=(?:"((?:\\.|[^\"\s])*)"|([^;\s]*))/ni.match(head)
+ /Content-Disposition:.* filename=(?:"((?:\\.|[^\"])*)"|([^;]*))/ni.match(head)
filename = ($1 or $2 or "")
if /Mac/ni.match(env_table['HTTP_USER_AGENT']) and
/Mozilla/ni.match(env_table['HTTP_USER_AGENT']) and
@@ -1046,7 +1046,7 @@ class CGI
filename = CGI::unescape(filename)
end
- /Content-Type: ([^\s]*)/ni.match(head)
+ /Content-Type: (.*)/ni.match(head)
content_type = ($1 or "")
(class << body; self; end).class_eval do
@@ -1055,7 +1055,7 @@ class CGI
define_method(:content_type) {content_type.dup.taint}
end
- /Content-Disposition:.* name="?([^\";\s]*)"?/ni.match(head)
+ /Content-Disposition:.* name="?([^\";]*)"?/ni.match(head)
name = $1.dup
if params.has_key?(name)
@@ -1064,7 +1064,7 @@ class CGI
params[name] = [body]
end
break if buf.size == 0
- break if content_length === -1
+ break if content_length == -1
end
raise EOFError, "bad boundary end of body part" unless boundary_end=~/--/
diff --git a/lib/cgi/session.rb b/lib/cgi/session.rb
index 5568b28dce..82eb7534d8 100644
--- a/lib/cgi/session.rb
+++ b/lib/cgi/session.rb
@@ -391,9 +391,8 @@ class CGI
unless @hash
@hash = {}
begin
- lockf = File.open(@path+".lock", "r")
- lockf.flock File::LOCK_SH
f = File.open(@path, 'r')
+ f.flock File::LOCK_SH
for line in f
line.chomp!
k, v = line.split('=',2)
@@ -401,7 +400,6 @@ class CGI
end
ensure
f.close unless f.nil?
- lockf.close if lockf
end
end
@hash
@@ -411,17 +409,13 @@ class CGI
def update
return unless @hash
begin
- lockf = File.open(@path+".lock", File::CREAT|File::RDWR, 0600)
- lockf.flock File::LOCK_EX
- f = File.open(@path+".new", File::CREAT|File::TRUNC|File::WRONLY, 0600)
+ 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
- f.close
- File.rename @path+".new", @path
ensure
- f.close if f and !f.closed?
- lockf.close if lockf
+ f.close unless f.nil?
end
end
@@ -432,8 +426,6 @@ class CGI
# Close and delete the session's FileStore file.
def delete
- File::unlink @path+".lock" rescue nil
- File::unlink @path+".new" rescue nil
File::unlink @path
rescue Errno::ENOENT
end
diff --git a/lib/csv.rb b/lib/csv.rb
index 31b698f08c..f6c12fa285 100644
--- a/lib/csv.rb
+++ b/lib/csv.rb
@@ -1,7 +1,7 @@
# CSV -- module for generating/parsing CSV data.
# Copyright (C) 2000-2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>.
-# $Id: csv.rb,v 1.4.2.4 2004/05/27 14:39:10 nahi Exp $
+# $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;
diff --git a/lib/date.rb b/lib/date.rb
index 8639b31575..6da4d6aa8e 100644
--- a/lib/date.rb
+++ b/lib/date.rb
@@ -6,7 +6,7 @@
# Documentation: William Webber <william@williamwebber.com>
#
#--
-# $Id: date.rb,v 2.15 2005-02-06 11:09:53+09 tadf Exp $
+# $Id: date.rb,v 2.30 2006-12-30 21:43:41+09 tadf Exp $
#++
#
# == Overview
@@ -14,7 +14,7 @@
# This file provides two classes for working with
# dates and times.
#
-# The first class, Date, represents dates.
+# The first class, Date, represents dates.
# It works with years, months, weeks, and days.
# See the Date class documentation for more details.
#
@@ -80,7 +80,7 @@
# 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.
+# 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*.
@@ -148,7 +148,7 @@
# 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).
+# 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
@@ -249,6 +249,54 @@ class Date
# Abbreviated day names, in English.
ABBR_DAYNAMES = %w(Sun Mon Tue Wed Thu Fri Sat)
+ [MONTHNAMES, DAYNAMES, ABBR_MONTHNAMES, ABBR_DAYNAMES].each do |xs|
+ xs.each{|x| x.freeze}.freeze
+ end
+
+ class Infinity < Numeric # :nodoc:
+
+ include Comparable
+
+ def initialize(d=1) @d = d <=> 0 end
+
+ def d() @d end
+
+ protected :d
+
+ def zero? () false end
+ def finite? () false end
+ def infinite? () d.nonzero? end
+ def nan? () d.zero? end
+
+ def abs() self.class.new end
+
+ def -@ () self.class.new(-d) end
+ def +@ () self.class.new(+d) end
+
+ def <=> (other)
+ case other
+ when Infinity; d <=> other.d
+ when Numeric; d
+ else
+ begin
+ l, r = other.coerce(self)
+ return l <=> r
+ rescue NoMethodError
+ end
+ end
+ nil
+ end
+
+ def coerce(other)
+ case other
+ when Numeric; return -d, d
+ else
+ super
+ end
+ end
+
+ end
+
# The Julian Day Number of the Day of Calendar Reform for Italy
# and the Catholic countries.
ITALY = 2299161 # 1582-10-15
@@ -259,11 +307,13 @@ class Date
# A constant used to indicate that a Date should always use the
# Julian calendar.
- JULIAN = false
+ JULIAN = Infinity.new
# A constant used to indicate that a Date should always use the
# Gregorian calendar.
- GREGORIAN = true
+ GREGORIAN = -Infinity.new
+
+ UNIXEPOCH = 2440588 # 1970-01-01 :nodoc:
# Does a given Julian Day Number fall inside the old-style (Julian)
# calendar?
@@ -273,10 +323,17 @@ class Date
# 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)
+
+ def self.julian? (jd, sg)
case sg
- when Numeric; jd < sg
- else; not sg
+ when Numeric
+ jd < sg
+ else
+ if $VERBOSE
+ warn("#{caller.shift.sub(/:in .*/, '')}: " \
+"warning: do not use non-numerical object as julian day number anymore")
+ end
+ not sg
end
end
@@ -285,7 +342,38 @@ class Date
#
# The reverse of self.os? See the documentation for that method for
# more details.
- def self.ns? (jd, sg) not os?(jd, sg) end
+ def self.gregorian? (jd, sg) !julian?(jd, sg) end
+
+ def self.fix_style(jd, sg) # :nodoc:
+ if julian?(jd, sg)
+ then JULIAN
+ else GREGORIAN end
+ end
+
+ private_class_method :fix_style
+
+ # 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
+
+ # 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, fix_style(jd, sg))
+ return y, doy
+ end
# Convert a Civil Date to a Julian Day Number.
# +y+, +m+, and +d+ are the year, month, and day of the
@@ -302,7 +390,7 @@ class Date
jd = (365.25 * (y + 4716)).floor +
(30.6001 * (m + 1)).floor +
d + b - 1524
- if os?(jd, sg)
+ if julian?(jd, sg)
jd -= b
end
jd
@@ -315,7 +403,7 @@ class Date
# 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)
+ if julian?(jd, sg)
a = jd
else
x = ((jd - 1867216.25) / 36524.25).floor
@@ -336,27 +424,16 @@ class Date
return y, m, dom
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
-
- # Convert a Julian Day Number to an Ordinal Date.
+ # Convert a Commercial Date to a Julian Day Number.
#
- # +jd+ is the Julian Day Number to convert.
+ # +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.
- #
- # 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
+ 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
# Convert a Julian Day Number to a Commercial Date
@@ -367,56 +444,45 @@ class Date
# 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)
+ ns = fix_style(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).floor
d = (jd + 1) % 7
- if d.zero? then d = 7 end
+ d = 7 if d == 0
return y, w, d
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)
+ def self.weeknum_to_jd(y, w, d, f=0, ns=GREGORIAN) # :nodoc:
+ a = civil_to_jd(y, 1, 1, ns) + 6
+ (a - ((a - f) + 1) % 7 - 7) + 7 * w + d
end
- %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;
+ def self.jd_to_weeknum(jd, f=0, sg=GREGORIAN) # :nodoc:
+ ns = fix_style(jd, sg)
+ y, m, d = jd_to_civil(jd, ns)
+ a = civil_to_jd(y, 1, 1, ns) + 6
+ w, d = (jd - (a - ((a - f) + 1) % 7) + 7).divmod(7)
+ return y, w, d
end
- private_class_method :clfloor
- private :clfloor
-
+ private_class_method :weeknum_to_jd, :jd_to_weeknum
# Convert an Astronomical Julian Day Number to a (civil) Julian
# Day Number.
#
- # +ajd+ is the Astronomical Julian Day Number to convert.
+ # +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
+ def self.ajd_to_jd(ajd, of=0) (ajd + of + 1.to_r/2).divmod(1) 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.
+ # 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
@@ -426,9 +492,9 @@ class Date
# 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)
+ h, fr = fr.divmod(1.to_r/24)
+ min, fr = fr.divmod(1.to_r/1440)
+ s, fr = fr.divmod(1.to_r/86400)
return h, min, s, fr
end
@@ -476,10 +542,10 @@ class Date
#
# 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
+ def self.gregorian_leap? (y) y % 4 == 0 && y % 100 != 0 || y % 400 == 0 end
class << self; alias_method :leap?, :gregorian_leap? end
- class << self; alias_method :new0, :new end
+ class << self; alias_method :new!, :new end
# Is +jd+ a valid Julian Day Number?
#
@@ -487,16 +553,6 @@ class Date
# 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
-
# 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.
@@ -505,16 +561,16 @@ class Date
# 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.
+ # -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)
+ ny, = (y + 1).divmod(1)
jd = ordinal_to_jd(ny, d + 1, sg)
- ns = ns?(jd, sg)
+ ns = fix_style(jd, sg)
return unless [y] == jd_to_ordinal(jd, sg)[0..0]
return unless [ny, 1] == jd_to_ordinal(jd - d, ns)
else
@@ -524,23 +580,6 @@ class Date
jd
end
- # 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
-
# 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.
@@ -558,10 +597,10 @@ class Date
m += 13
end
if d < 0
- ny, nm = clfloor(y * 12 + m, 12)
- nm, = clfloor(nm + 1, 1)
+ ny, nm = (y * 12 + m).divmod(12)
+ nm, = (nm + 1).divmod(1)
jd = civil_to_jd(ny, nm, d + 1, sg)
- ns = ns?(jd, sg)
+ ns = fix_style(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
@@ -573,28 +612,6 @@ class Date
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
-
- 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.
@@ -614,14 +631,106 @@ class Date
d += 8
end
if w < 0
- w = jd_to_commercial(commercial_to_jd(y + 1, 1, 1) + w * 7)[1]
+ ny, nw, nd =
+ jd_to_commercial(commercial_to_jd(y + 1, 1, 1) + w * 7)
+ return unless ny == y
+ w = nw
end
jd = commercial_to_jd(y, w, d)
- return unless ns?(jd, sg)
+ return unless gregorian?(jd, sg)
return unless [y, w, d] == jd_to_commercial(jd)
jd
end
+ def self.valid_weeknum? (y, w, d, f, sg=ITALY) # :nodoc:
+ if d < 0
+ d += 7
+ end
+ if w < 0
+ ny, nw, nd, nf =
+ jd_to_weeknum(weeknum_to_jd(y + 1, 1, f, f) + w * 7, f)
+ return unless ny == y
+ w = nw
+ end
+ jd = weeknum_to_jd(y, w, d, f)
+ return unless gregorian?(jd, sg)
+ return unless [y, w, d] == jd_to_weeknum(jd, f)
+ jd
+ end
+
+ private_class_method :valid_weeknum?
+
+ # 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..23) === h &&
+ (0..59) === min &&
+ (0..59) === s) ||
+ (24 == h &&
+ 0 == min &&
+ 0 == s)
+ time_to_day_fraction(h, min, s)
+ 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)
+ new!(jd_to_ajd(jd, 0, 0), 0, sg)
+ end
+
+ # 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
+ new!(jd_to_ajd(jd, 0, 0), 0, sg)
+ 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
+ new!(jd_to_ajd(jd, 0, 0), 0, sg)
+ end
+
+ class << self; alias_method :new, :civil end
+
# Create a new Date object for the Commercial Date specified by
# year +y+, week-of-year +w+, and day-of-week +d+.
#
@@ -640,20 +749,191 @@ class Date
unless jd = valid_commercial?(y, w, d, sg)
raise ArgumentError, 'invalid date'
end
- new0(jd_to_ajd(jd, 0, 0), 0, sg)
+ new!(jd_to_ajd(jd, 0, 0), 0, sg)
end
- def self.new_with_hash(elem, sg)
+ def self.weeknum(y=1582, w=41, d=5, f=0, sg=ITALY) # :nodoc:
+ unless jd = valid_weeknum?(y, w, d, f, sg)
+ raise ArgumentError, 'invalid date'
+ end
+ new!(jd_to_ajd(jd, 0, 0), 0, sg)
+ end
+
+ private_class_method :weeknum
+
+ def self.rewrite_frags(elem) # :nodoc:
elem ||= {}
- y, m, d = elem.values_at(:year, :mon, :mday)
- if [y, m, d].include? nil
- raise ArgumentError, '3 elements of civil date are necessary'
- else
- civil(y, m, d, sg)
+ if seconds = elem[:seconds]
+ d, fr = seconds.divmod(86400)
+ h, fr = fr.divmod(3600)
+ min, fr = fr.divmod(60)
+ s, fr = fr.divmod(1)
+ elem[:jd] = UNIXEPOCH + d
+ elem[:hour] = h
+ elem[:min] = min
+ elem[:sec] = s
+ elem[:sec_fraction] = fr
+ elem.delete(:seconds)
+ elem.delete(:offset)
+ end
+ elem
+ end
+
+ private_class_method :rewrite_frags
+
+ def self.complete_frags(elem) # :nodoc:
+ i = 0
+ g = [[:time, [:hour, :min, :sec]],
+ [nil, [:jd]],
+ [:ordinal, [:year, :yday, :hour, :min, :sec]],
+ [:civil, [:year, :mon, :mday, :hour, :min, :sec]],
+ [:commercial, [:cwyear, :cweek, :cwday, :hour, :min, :sec]],
+ [:wday, [:wday, :hour, :min, :sec]],
+ [:wnum0, [:year, :wnum0, :wday, :hour, :min, :sec]],
+ [:wnum1, [:year, :wnum1, :wday, :hour, :min, :sec]],
+ [nil, [:cwyear, :cweek, :wday, :hour, :min, :sec]],
+ [nil, [:year, :wnum0, :cwday, :hour, :min, :sec]],
+ [nil, [:year, :wnum1, :cwday, :hour, :min, :sec]]].
+ collect{|k, a| e = elem.values_at(*a).compact; [k, a, e]}.
+ select{|k, a, e| e.size > 0}.
+ sort_by{|k, a, e| [e.size, i -= 1]}.last
+
+ d = nil
+
+ if g && g[0] && (g[1].size - g[2].size) != 0
+ d ||= Date.today
+
+ case g[0]
+ when :ordinal
+ elem[:year] ||= d.year
+ elem[:yday] ||= 1
+ when :civil
+ g[1].each do |e|
+ break if elem[e]
+ elem[e] = d.__send__(e)
+ end
+ elem[:mon] ||= 1
+ elem[:mday] ||= 1
+ when :commercial
+ g[1].each do |e|
+ break if elem[e]
+ elem[e] = d.__send__(e)
+ end
+ elem[:cweek] ||= 1
+ elem[:cwday] ||= 1
+ when :wday
+ elem[:jd] ||= (d - d.wday + elem[:wday]).jd
+ when :wnum0
+ g[1].each do |e|
+ break if elem[e]
+ elem[e] = d.__send__(e)
+ end
+ elem[:wnum0] ||= 0
+ elem[:wday] ||= 0
+ when :wnum1
+ g[1].each do |e|
+ break if elem[e]
+ elem[e] = d.__send__(e)
+ end
+ elem[:wnum1] ||= 0
+ elem[:wday] ||= 0
+ end
+ end
+
+ if g && g[0] == :time
+ if self <= DateTime
+ d ||= Date.today
+ elem[:jd] ||= d.jd
+ end
end
+
+ elem[:hour] ||= 0
+ elem[:min] ||= 0
+ elem[:sec] ||= 0
+ elem[:sec] = [elem[:sec], 59].min
+
+ elem
end
- private_class_method :new_with_hash
+ private_class_method :complete_frags
+
+ def self.valid_date_frags?(elem, sg) # :nodoc:
+ catch :jd do
+ a = elem.values_at(:jd)
+ if a.all?
+ if jd = valid_jd?(*(a << sg))
+ throw :jd, jd
+ end
+ end
+
+ a = elem.values_at(:year, :yday)
+ if a.all?
+ if jd = valid_ordinal?(*(a << sg))
+ throw :jd, jd
+ end
+ end
+
+ a = elem.values_at(:year, :mon, :mday)
+ if a.all?
+ if jd = valid_civil?(*(a << sg))
+ throw :jd, jd
+ end
+ end
+
+ a = elem.values_at(:cwyear, :cweek, :cwday)
+ if a[2].nil? && elem[:wday]
+ a[2] = elem[:wday].nonzero? || 7
+ end
+ if a.all?
+ if jd = valid_commercial?(*(a << sg))
+ throw :jd, jd
+ end
+ end
+
+ a = elem.values_at(:year, :wnum0, :wday)
+ if a[2].nil? && elem[:cwday]
+ a[2] = elem[:cwday] % 7
+ end
+ if a.all?
+ if jd = valid_weeknum?(*(a << 0 << sg))
+ throw :jd, jd
+ end
+ end
+
+ a = elem.values_at(:year, :wnum1, :wday)
+ if a[2]
+ a[2] = (a[2] - 1) % 7
+ end
+ if a[2].nil? && elem[:cwday]
+ a[2] = (elem[:cwday] - 1) % 7
+ end
+ if a.all?
+ if jd = valid_weeknum?(*(a << 1 << sg))
+ throw :jd, jd
+ end
+ end
+ end
+ end
+
+ private_class_method :valid_date_frags?
+
+ def self.valid_time_frags? (elem) # :nodoc:
+ h, min, s = elem.values_at(:hour, :min, :sec)
+ valid_time?(h, min, s)
+ end
+
+ private_class_method :valid_time_frags?
+
+ def self.new_by_frags(elem, sg) # :nodoc:
+ elem = rewrite_frags(elem)
+ elem = complete_frags(elem)
+ unless jd = valid_date_frags?(elem, sg)
+ raise ArgumentError, 'invalid date'
+ end
+ new!(jd_to_ajd(jd, 0, 0), 0, sg)
+ end
+
+ private_class_method :new_by_frags
# Create a new Date object by parsing from a String
# according to a specified format.
@@ -672,13 +952,13 @@ class Date
# parsed.
def self.strptime(str='-4712-01-01', fmt='%F', sg=ITALY)
elem = _strptime(str, fmt)
- new_with_hash(elem, sg)
+ new_by_frags(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.
+ # +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
@@ -692,32 +972,18 @@ class Date
# +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)
+ new_by_frags(elem, sg)
end
class << self
def once(*ids) # :nodoc:
for id in ids
- module_eval <<-"end;", __FILE__, __LINE__
+ module_eval <<-"end;"
alias_method :__#{id.to_i}__, :#{id.to_s}
private :__#{id.to_i}__
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
+ (@__#{id.to_i}__ ||= [__#{id.to_i}__(*args, &block)])[0]
end
end;
end
@@ -727,7 +993,7 @@ class Date
end
- # *NOTE* this is the documentation for the method new0(). If
+ # *NOTE* this is the documentation for the method new!(). If
# you are reading this as the documentation for new(), that is
# because rdoc doesn't fully support the aliasing of the
# initialize() method.
@@ -772,16 +1038,19 @@ class Date
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
+ def civil() self.class.jd_to_civil(jd, @sg) end # :nodoc:
# Get the date as an Ordinal Date, [year, day_of_year]
- def ordinal() self.class.jd_to_ordinal(jd, @sg) end
+ def ordinal() self.class.jd_to_ordinal(jd, @sg) end # :nodoc:
# Get the date as a Commercial Date, [year, week_of_year, day_of_week]
- def commercial() self.class.jd_to_commercial(jd, @sg) end
+ def commercial() self.class.jd_to_commercial(jd, @sg) end # :nodoc:
+
+ def weeknum0() self.class.__send__(:jd_to_weeknum, jd, 0, @sg) end # :nodoc:
+ def weeknum1() self.class.__send__(:jd_to_weeknum, jd, 1, @sg) end # :nodoc:
- once :civil, :ordinal, :commercial
- private :civil, :ordinal, :commercial
+ once :civil, :ordinal, :commercial, :weeknum0, :weeknum1
+ private :civil, :ordinal, :commercial, :weeknum0, :weeknum1
# Get the year of this date.
def year() civil[0] end
@@ -802,9 +1071,14 @@ class Date
alias_method :month, :mon
alias_method :day, :mday
+ def wnum0() weeknum0[1] end # :nodoc:
+ def wnum1() weeknum1[1] end # :nodoc:
+
+ private :wnum0, :wnum1
+
# 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
+ def time() self.class.day_fraction_to_time(day_fraction) end # :nodoc:
once :time
private :time
@@ -818,12 +1092,13 @@ class Date
# Get the second of this date.
def sec() time[2] end
- # Get the fraction-of-a-second of this date.
+ # Get the fraction-of-a-second of this date. The unit is in days.
+ # I do NOT recommend you to use this method.
def sec_fraction() time[3] end
private :hour, :min, :sec, :sec_fraction
- def zone() strftime('%Z') end
+ def zone() strftime('%:z') end
private :zone
@@ -844,18 +1119,38 @@ class Date
once :wday
+=begin
+ MONTHNAMES.each_with_index do |n, i|
+ if n
+ define_method(n.downcase + '?'){mon == i}
+ end
+ end
+
+ DAYNAMES.each_with_index do |n, i|
+ define_method(n.downcase + '?'){wday == i}
+ end
+=end
+
# Is the current date old-style (Julian Calendar)?
- def os? () self.class.os?(jd, @sg) end
+ def julian? () self.class.julian?(jd, @sg) end
# Is the current date new-style (Gregorian Calendar)?
- def ns? () self.class.ns?(jd, @sg) end
+ def gregorian? () self.class.gregorian?(jd, @sg) end
+
+ once :julian?, :gregorian?
- once :os?, :ns?
+ def fix_style # :nodoc:
+ if julian?
+ then self.class::JULIAN
+ else self.class::GREGORIAN end
+ end
+
+ private :fix_style
# Is this a leap year?
def leap?
- self.class.jd_to_civil(self.class.civil_to_jd(year, 3, 1, ns?) - 1,
- ns?)[-1] == 29
+ self.class.jd_to_civil(self.class.civil_to_jd(year, 3, 1, fix_style) - 1,
+ fix_style)[-1] == 29
end
once :leap?
@@ -864,7 +1159,7 @@ class Date
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
+ def new_start(sg=self.class::ITALY) self.class.new!(@ajd, @of, sg) end
# Create a copy of this Date object that uses the Italian/Catholic
# Day of Calendar Reform.
@@ -883,7 +1178,13 @@ class Date
def gregorian() new_start(self.class::GREGORIAN) end
def offset() @of end
- def new_offset(of=0) self.class.new0(@ajd, of, @sg) end
+
+ def new_offset(of=0)
+ if String === of
+ of = (self.class.zone_to_diff(of) || 0).to_r/86400
+ end
+ self.class.new!(@ajd, of, @sg)
+ end
private :offset, :new_offset
@@ -898,7 +1199,7 @@ class Date
# particular, two Dates cannot be added to each other.
def + (n)
case n
- when Numeric; return self.class.new0(@ajd + n, @of, @sg)
+ when Numeric; return self.class.new!(@ajd + n, @of, @sg)
end
raise TypeError, 'expected numeric'
end
@@ -913,7 +1214,7 @@ class Date
# If +x+ is neither Numeric nor a Date, a TypeError is raised.
def - (x)
case x
- when Numeric; return self.class.new0(@ajd - x, @of, @sg)
+ when Numeric; return self.class.new!(@ajd - x, @of, @sg)
when Date; return @ajd - x.ajd
end
raise TypeError, 'expected numeric or date'
@@ -952,6 +1253,16 @@ class Date
false
end
+ def next_day(n=1) self + n end
+# def prev_day(n=1) self - n end
+
+ private :next_day
+
+ # Return a new Date one day after this one.
+ def next() next_day end
+
+ alias_method :succ, :next
+
# Return a new Date object that is +n+ months later than
# the current one.
#
@@ -959,10 +1270,10 @@ class Date
# 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 = clfloor(year * 12 + (mon - 1) + n, 12)
- m, = clfloor(m + 1, 1)
+ y, m = (year * 12 + (mon - 1) + n).divmod(12)
+ m, = (m + 1) .divmod(1)
d = mday
- d -= 1 until jd2 = self.class.valid_civil?(y, m, d, ns?)
+ d -= 1 until jd2 = self.class.valid_civil?(y, m, d, fix_style)
self + (jd2 - jd)
end
@@ -974,13 +1285,28 @@ class Date
# of the returned Date will be the last day of the target month.
def << (n) self >> -n end
+=begin
+ def next_month(n=1) self >> n end
+ def prev_month(n=1) self << n end
+
+ def next_year(n=1) self >> n * 12 end
+ def prev_year(n=1) self << n * 12 end
+=end
+
+# require 'enumerator'
+
# 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
+ def step(limit, step=1) # :yield: date
+=begin
+ unless block_given?
+ return to_enum(:step, limit, step)
+ end
+=end
da = self
- op = [:-,:<=,:>=][step<=>0]
+ op = %w(- <= >=)[step <=> 0]
while da.__send__(op, limit)
yield da
da += step
@@ -990,25 +1316,20 @@ class Date
# 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)
+ 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)
+ 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 eql? (other) Date === other && self == other end
# Calculate a hash value for this date.
def hash() @ajd.hash end
@@ -1024,7 +1345,7 @@ class Date
# Dump to Marshal format.
def _dump(limit) Marshal.dump([@ajd, @of, @sg], -1) end
-# def self._load(str) new0(*Marshal.load(str)) end
+# def self._load(str) new!(*Marshal.load(str)) end
# Load from Marshall format.
def self._load(str)
@@ -1036,7 +1357,7 @@ class Date
else
ajd, of, sg = a
end
- new0(ajd, of, sg)
+ new!(ajd, of, sg)
end
end
@@ -1071,7 +1392,8 @@ end
# === sec_fraction()
#
# Get the fraction of a second of the time. This is returned as
-# a +Rational+.
+# a +Rational+. The unit is in days.
+# I do NOT recommend you to use this method.
#
# === zone()
#
@@ -1091,25 +1413,6 @@ end
#
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+.
#
@@ -1124,11 +1427,14 @@ class DateTime < Date
#
# 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
+ unless (jd = valid_jd?(jd, sg)) &&
(fr = valid_time?(h, min, s))
raise ArgumentError, 'invalid date'
end
- new0(jd_to_ajd(jd, fr, of), of, sg)
+ if String === of
+ of = (zone_to_diff(of) || 0).to_r/86400
+ end
+ new!(jd_to_ajd(jd, fr, of), of, sg)
end
# Create a new DateTime object corresponding to the specified
@@ -1146,11 +1452,14 @@ class DateTime < Date
# +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
+ unless (jd = valid_ordinal?(y, d, sg)) &&
(fr = valid_time?(h, min, s))
raise ArgumentError, 'invalid date'
end
- new0(jd_to_ajd(jd, fr, of), of, sg)
+ if String === of
+ of = (zone_to_diff(of) || 0).to_r/86400
+ end
+ new!(jd_to_ajd(jd, fr, of), of, sg)
end
# Create a new DateTime object corresponding to the specified
@@ -1168,11 +1477,14 @@ class DateTime < Date
# +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
+ unless (jd = valid_civil?(y, m, d, sg)) &&
(fr = valid_time?(h, min, s))
raise ArgumentError, 'invalid date'
end
- new0(jd_to_ajd(jd, fr, of), of, sg)
+ if String === of
+ of = (zone_to_diff(of) || 0).to_r/86400
+ end
+ new!(jd_to_ajd(jd, fr, of), of, sg)
end
class << self; alias_method :new, :civil end
@@ -1193,31 +1505,44 @@ class DateTime < Date
# 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
+ unless (jd = valid_commercial?(y, w, d, sg)) &&
(fr = valid_time?(h, min, s))
raise ArgumentError, 'invalid date'
end
- new0(jd_to_ajd(jd, fr, of), of, sg)
+ if String === of
+ of = (zone_to_diff(of) || 0).to_r/86400
+ end
+ new!(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, '3 elements of civil date are necessary'
- else
- civil(y, m, d, h, min, s, of.to_r/86400, sg) + (fr/86400)
+ def self.weeknum(y=1582, w=41, d=5, f=0, h=0, min=0, s=0, of=0, sg=ITALY) # :nodoc:
+ unless (jd = valid_weeknum?(y, w, d, f, sg)) &&
+ (fr = valid_time?(h, min, s))
+ raise ArgumentError, 'invalid date'
+ end
+ if String === of
+ of = (zone_to_diff(of) || 0).to_r/86400
+ end
+ new!(jd_to_ajd(jd, fr, of), of, sg)
+ end
+
+ private_class_method :weeknum
+
+ def self.new_by_frags(elem, sg) # :nodoc:
+ elem = rewrite_frags(elem)
+ elem = complete_frags(elem)
+ unless (jd = valid_date_frags?(elem, sg)) &&
+ (fr = valid_time_frags?(elem))
+ raise ArgumentError, 'invalid date'
end
+ sf = (elem[:sec_fraction] || 0)
+ fr += sf/86400
+ of = (elem[:offset] || 0)
+ of = of.to_r/86400
+ new!(jd_to_ajd(jd, fr, of), of, sg)
end
- private_class_method :new_with_hash
+ private_class_method :new_by_frags
# Create a new DateTime object by parsing from a String
# according to a specified format.
@@ -1226,22 +1551,22 @@ class DateTime < Date
# +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.
+ # The default +str+ is '-4712-01-01T00:00:00+00:00', 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)
+ def self.strptime(str='-4712-01-01T00:00:00+00:00', fmt='%FT%T%z', sg=ITALY)
elem = _strptime(str, fmt)
- new_with_hash(elem, sg)
+ new_by_frags(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.
+ # +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
@@ -1249,40 +1574,93 @@ class DateTime < Date
# for more details. If parsing fails, an ArgumentError
# will be raised.
#
- # The default +str+ is '-4712-01-01T00:00:00Z'; this is Julian
+ # The default +str+ is '-4712-01-01T00:00:00+00:00'; 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)
+ def self.parse(str='-4712-01-01T00:00:00+00:00', comp=false, sg=ITALY)
elem = _parse(str, comp)
- new_with_hash(elem, sg)
+ new_by_frags(elem, sg)
end
- class << self; undef_method :today end rescue nil
+ public :hour, :min, :sec, :sec_fraction, :zone, :offset, :new_offset
+
+end
+
+class Time
+
+# def to_time() getlocal end
+
+ def to_date
+ jd = Date.civil_to_jd(year, mon, mday, Date::ITALY)
+ Date.new!(Date.jd_to_ajd(jd, 0, 0), 0, Date::ITALY)
+ end
+
+ def to_datetime
+ jd = DateTime.civil_to_jd(year, mon, mday, DateTime::ITALY)
+ fr = DateTime.time_to_day_fraction(hour, min, [sec, 59].min) +
+ usec.to_r/86400000000
+ of = utc_offset.to_r/86400
+ DateTime.new!(DateTime.jd_to_ajd(jd, fr, of), of, DateTime::ITALY)
+ end
+
+ private :to_date, :to_datetime
+
+end
+
+class Date
+
+=begin
+ def to_time() Time.local(year, mon, mday) end
+ def to_date() self end
+ def to_datetime() DateTime.new!(self.class.jd_to_ajd(jd, 0, 0), @of, @sg) end
+=end
+
+ # Create a new Date object representing today.
+ #
+ # +sg+ specifies the Day of Calendar Reform.
+ def self.today(sg=ITALY) Time.now.__send__(:to_date) .new_start(sg) 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)
+ def self.now (sg=ITALY) Time.now.__send__(:to_datetime).new_start(sg) end
+
+ private_class_method :now
+
+end
+
+class DateTime < Date
+
+=begin
+ def to_time
+ d = new_offset(0)
+ d.instance_eval do
+ Time.utc(year, mon, mday, hour, min, sec,
+ (sec_fraction * 86400000000).to_i)
+ end.
+ getlocal
end
- public :hour, :min, :sec, :sec_fraction, :zone, :offset, :new_offset
+ def to_date() Date.new!(self.class.jd_to_ajd(jd, 0, 0), 0, @sg) end
+ def to_datetime() self end
+=end
+
+ private_class_method :today
+ public_class_method :now
end
class Date
- [ %w(exist1? valid_jd?),
+ [ %w(os? julian?),
+ %w(ns? gregorian?),
+ %w(exist1? valid_jd?),
%w(exist2? valid_ordinal?),
%w(exist3? valid_date?),
%w(exist? valid_date?),
%w(existw? valid_commercial?),
+ %w(new0 new!),
%w(new1 jd),
%w(new2 ordinal),
%w(new3 new),
@@ -1300,7 +1678,9 @@ class Date
end;
end
- [ %w(sg start),
+ [ %w(os? julian?),
+ %w(ns? gregorian?),
+ %w(sg start),
%w(newsg new_start),
%w(of offset),
%w(newof new_offset)
diff --git a/lib/date/format.rb b/lib/date/format.rb
index 4425635d33..8bd14c7fd0 100644
--- a/lib/date/format.rb
+++ b/lib/date/format.rb
@@ -1,603 +1,1088 @@
-# format.rb: Written by Tadayoshi Funaba 1999-2006
-# $Id: format.rb,v 2.15 2005-02-06 13:28:48+09 tadf Exp $
+# format.rb: Written by Tadayoshi Funaba 1999-2007
+# $Id: format.rb,v 2.30 2007-01-07 09:16:24+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]?.|./mo) do |c|
- cc = c.sub(/\A%[EO]?(.)\z/mo, '%\\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
-=begin
- when '%N'
- return unless str.sub!(/\A(\d+)/o, '')
- val = $1.to_i.to_r / (10**9)
- elem[:sec_fraction] = val
-=end
- 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[-1,1] == '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'
+ module Format # :nodoc:
+
+ 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,
+
+ 'afghanistan' => 16200, 'alaskan' => -32400,
+ 'arab' => 10800, 'arabian' => 14400,
+ 'arabic' => 10800, 'atlantic' => -14400,
+ 'aus central' => 34200, 'aus eastern' => 36000,
+ 'azores' => -3600, 'canada central' => -21600,
+ 'cape verde' => -3600, 'caucasus' => 14400,
+ 'cen. australia' => 34200, 'central america' => -21600,
+ 'central asia' => 21600, 'central europe' => 3600,
+ 'central european' => 3600, 'central pacific' => 39600,
+ 'central' => -21600, 'china' => 28800,
+ 'dateline' => -43200, 'e. africa' => 10800,
+ 'e. australia' => 36000, 'e. europe' => 7200,
+ 'e. south america' => -10800, 'eastern' => -18000,
+ 'egypt' => 7200, 'ekaterinburg' => 18000,
+ 'fiji' => 43200, 'fle' => 7200,
+ 'greenland' => -10800, 'greenwich' => 0,
+ 'gtb' => 7200, 'hawaiian' => -36000,
+ 'india' => 19800, 'iran' => 12600,
+ 'jerusalem' => 7200, 'korea' => 32400,
+ 'mexico' => -21600, 'mid-atlantic' => -7200,
+ 'mountain' => -25200, 'myanmar' => 23400,
+ 'n. central asia' => 21600, 'nepal' => 20700,
+ 'new zealand' => 43200, 'newfoundland' => -12600,
+ 'north asia east' => 28800, 'north asia' => 25200,
+ 'pacific sa' => -14400, 'pacific' => -28800,
+ 'romance' => 3600, 'russian' => 10800,
+ 'sa eastern' => -10800, 'sa pacific' => -18000,
+ 'sa western' => -14400, 'samoa' => -39600,
+ 'se asia' => 25200, 'malay peninsula' => 28800,
+ 'south africa' => 7200, 'sri lanka' => 21600,
+ 'taipei' => 28800, 'tasmania' => 36000,
+ 'tokyo' => 32400, 'tonga' => 46800,
+ 'us eastern' => -18000, 'us mountain' => -25200,
+ 'vladivostok' => 36000, 'w. australia' => 28800,
+ 'w. central africa' => 3600, 'w. europe' => 3600,
+ 'west asia' => 18000, 'west pacific' => 36000,
+ 'yakutsk' => 32400
+ }
+
+ [MONTHS, DAYS, ABBR_MONTHS, ABBR_DAYS, ZONES].each do |x|
+ x.freeze
+ end
+
+ class Bag # :nodoc:
+
+ def initialize
+ @elem = {}
+ end
+
+ def method_missing(t, *args, &block)
+ t = t.to_s
+ set = t.chomp!('=')
+ t = t.intern
+ if set
+ @elem[t] = args[0]
+ else
+ @elem[t]
+ end
+ end
+
+ def to_hash
+ @elem.reject{|k, v| /\A_/ =~ k.to_s || v.nil?}
+ end
+
+ end
+
+ end
+
+ def emit(e, f) # :nodoc:
+ case e
+ when Numeric
+ sign = %w(+ + -)[e <=> 0]
+ e = e.abs
+ end
+
+ s = e.to_s
+
+ if f[:s] && f[:p] == '0'
+ f[:w] -= 1
+ end
+
+ if f[:s] && f[:p] == "\s"
+ s[0,0] = sign
+ end
+
+ if f[:p] != '-'
+ s = s.rjust(f[:w], f[:p])
+ end
+
+ if f[:s] && f[:p] != "\s"
+ s[0,0] = sign
+ end
+
+ s = s.upcase if f[:u]
+ s = s.downcase if f[:d]
+ s
+ end
+
+ def emit_w(e, w, f) # :nodoc:
+ f[:w] = [f[:w], w].compact.max
+ emit(e, f)
+ end
+
+ def emit_n(e, w, f) # :nodoc:
+ f[:p] ||= '0'
+ emit_w(e, w, f)
+ end
+
+ def emit_sn(e, w, f) # :nodoc:
+ if e < 0
+ w += 1
+ f[:s] = true
+ end
+ emit_n(e, w, f)
+ end
+
+ def emit_z(e, w, f) # :nodoc:
+ w += 1
+ f[:s] = true
+ emit_n(e, w, f)
+ end
+
+ def emit_a(e, w, f) # :nodoc:
+ f[:p] ||= "\s"
+ emit_w(e, w, f)
+ end
+
+ def emit_ad(e, w, f) # :nodoc:
+ if f[:x]
+ f[:u] = true
+ f[:d] = false
+ end
+ emit_a(e, w, f)
+ end
+
+ def emit_au(e, w, f) # :nodoc:
+ if f[:x]
+ f[:u] = false
+ f[:d] = true
+ end
+ emit_a(e, w, f)
+ end
+
+ private :emit, :emit_w, :emit_n, :emit_sn, :emit_z,
+ :emit_a, :emit_ad, :emit_au
+
+ def strftime(fmt='%F')
+ fmt.gsub(/%([-_0^#]+)?(\d+)?[EO]?(:{1,3}z|.)/m) do |m|
+ f = {}
+ s, w, c = $1, $2, $3
+ if s
+ s.scan(/./) do |k|
+ case k
+ when '-'; f[:p] = '-'
+ when '_'; f[:p] = "\s"
+ when '0'; f[:p] = '0'
+ when '^'; f[:u] = true
+ when '#'; f[:x] = true
+ end
+ end
+ end
+ if w
+ f[:w] = w.to_i
+ end
+ case c
+ when 'A'; emit_ad(DAYNAMES[wday], 0, f)
+ when 'a'; emit_ad(ABBR_DAYNAMES[wday], 0, f)
+ when 'B'; emit_ad(MONTHNAMES[mon], 0, f)
+ when 'b'; emit_ad(ABBR_MONTHNAMES[mon], 0, f)
+ when 'C'; emit_sn((year / 100).floor, 2, f)
+ when 'c'; emit_a(strftime('%a %b %e %H:%M:%S %Y'), 0, f)
+ when 'D'; emit_a(strftime('%m/%d/%y'), 0, f)
+ when 'd'; emit_n(mday, 2, f)
+ when 'e'; emit_a(mday, 2, f)
+ when 'F'
+ if m == '%F'
+ format('%.4d-%02d-%02d', year, mon, mday) # 4p
+ else
+ emit_a(strftime('%Y-%m-%d'), 0, f)
+ end
+ when 'G'; emit_sn(cwyear, 4, f)
+ when 'g'; emit_n(cwyear % 100, 2, f)
+ when 'H'; emit_n(hour, 2, f)
+ when 'h'; emit_ad(strftime('%b'), 0, f)
+ when 'I'; emit_n((hour % 12).nonzero? || 12, 2, f)
+ when 'j'; emit_n(yday, 3, f)
+ when 'k'; emit_a(hour, 2, f)
+ when 'L'
+ emit_n((sec_fraction / (1.to_r/86400/(10**3))).round, 3, f)
+ when 'l'; emit_a((hour % 12).nonzero? || 12, 2, f)
+ when 'M'; emit_n(min, 2, f)
+ when 'm'; emit_n(mon, 2, f)
+ when 'N'
+ emit_n((sec_fraction / (1.to_r/86400/(10**9))).round, 9, f)
+ when 'n'; "\n"
+ when 'P'; emit_ad(strftime('%p').downcase, 0, f)
+ when 'p'; emit_au(if hour < 12 then 'AM' else 'PM' end, 0, f)
+ when 'Q'
+ d = ajd - self.class.jd_to_ajd(self.class::UNIXEPOCH, 0)
+ s = (d * 86400*10**3).to_i
+ emit_sn(s, 1, f)
+ when 'R'; emit_a(strftime('%H:%M'), 0, f)
+ when 'r'; emit_a(strftime('%I:%M:%S %p'), 0, f)
+ when 'S'; emit_n(sec, 2, f)
+ when 's'
+ d = ajd - self.class.jd_to_ajd(self.class::UNIXEPOCH, 0)
+ s = (d * 86400).to_i
+ emit_sn(s, 1, f)
+ when 'T'
+ if m == '%T'
+ format('%02d:%02d:%02d', hour, min, sec) # 4p
+ else
+ emit_a(strftime('%H:%M:%S'), 0, f)
+ end
+ when 't'; "\t"
+ when 'U', 'W'
+ emit_n(if c == 'U' then wnum0 else wnum1 end, 2, f)
+ when 'u'; emit_n(cwday, 1, f)
+ when 'V'; emit_n(cweek, 2, f)
+ when 'v'; emit_a(strftime('%e-%b-%Y'), 0, f)
+ when 'w'; emit_n(wday, 1, f)
+ when 'X'; emit_a(strftime('%H:%M:%S'), 0, f)
+ when 'x'; emit_a(strftime('%m/%d/%y'), 0, f)
+ when 'Y'; emit_sn(year, 4, f)
+ when 'y'; emit_n(year % 100, 2, f)
+ when 'Z'; emit_au(strftime('%:z'), 0, f)
+ when /\A(:{0,3})z/
+ t = $1.size
+ sign = if offset < 0 then -1 else +1 end
+ fr = offset.abs
+ hh, fr = fr.divmod(1.to_r/24)
+ mm, fr = fr.divmod(1.to_r/1440)
+ ss, fr = fr.divmod(1.to_r/86400)
+ if t == 3
+ if ss.nonzero? then t = 2
+ elsif mm.nonzero? then t = 1
+ else t = -1
+ end
+ end
+ case t
+ when -1
+ tail = []
+ sep = ''
+ when 0
+ f[:w] -= 2 if f[:w]
+ tail = ['%02d' % mm]
+ sep = ''
+ when 1
+ f[:w] -= 3 if f[:w]
+ tail = ['%02d' % mm]
+ sep = ':'
+ when 2
+ f[:w] -= 6 if f[:w]
+ tail = ['%02d' % mm, '%02d' % ss]
+ sep = ':'
+ end
+ ([emit_z(sign * hh, 2, f)] + tail).join(sep)
+ when '%'; emit_a('%', 0, f)
+ when '+'; emit_a(strftime('%a %b %e %H:%M:%S %Z %Y'), 0, f)
+ when '1'
if $VERBOSE
- warn("warning: %1 is deprecated; forget this")
+ warn("warning: strftime: %1 is deprecated; forget this")
end
- return unless str.sub!(/\A(\d+)/o, '')
- val = $1.to_i
- elem[:jd] = val
- when '%2'
+ emit_n(jd, 1, f)
+ when '2'
if $VERBOSE
- warn("warning: %2 is deprecated; use '%Y-%j'")
+ warn("warning: strftime: %2 is deprecated; use '%Y-%j'")
end
- return unless __strptime(str, '%Y-%j', elem)
- when '%3'
+ emit_a(strftime('%Y-%j'), 0, f)
+ when '3'
if $VERBOSE
- warn("warning: %3 is deprecated; use '%F'")
+ warn("warning: strftime: %3 is deprecated; use '%F'")
end
- return unless __strptime(str, '%F', elem)
- when /\A%(.)/m
- return unless str.sub!(Regexp.new('\\A' + Regexp.quote($1)), '')
+ emit_a(strftime('%F'), 0, f)
else
- return unless str.sub!(Regexp.new('\\A' + Regexp.quote(c)), '')
+ c
end
end
+ end
- if cent = elem.delete(:cent)
- if elem[:cwyear]
- elem[:cwyear] += cent * 100
- end
- if elem[:year]
- elem[:year] += cent * 100
+# alias_method :format, :strftime
+
+ def asctime() strftime('%c') end
+
+ alias_method :ctime, :asctime
+
+=begin
+ def iso8601() strftime('%F') end
+
+ def rfc3339() iso8601 end
+
+ def rfc2822() strftime('%a, %-d %b %Y %T %z') end
+
+ alias_method :rfc822, :rfc2822
+
+ def jisx0301
+ if jd < 2405160
+ iso8601
+ else
+ case jd
+ when 2405160...2419614
+ g = 'M%02d' % (year - 1867)
+ when 2419614...2424875
+ g = 'T%02d' % (year - 1911)
+ when 2424875...2447535
+ g = 'S%02d' % (year - 1925)
+ else
+ g = 'H%02d' % (year - 1988)
end
+ g + strftime('.%m.%d')
end
+ end
- if merid = elem.delete(:merid)
- if elem[:hour]
- elem[:hour] %= 12
- elem[:hour] += merid
+ def beat(n=0)
+ i, f = (new_offset(1.to_r/24).day_fraction * 1000).divmod(1)
+ ('@%03d' % i) +
+ if n < 1
+ ''
+ else
+ '.%0*d' % [n, (f / (1.to_r/(10**n))).round]
end
- end
+ end
+=end
+
+ def self.num_pattern? (s) # :nodoc:
+ /\A%[EO]?[CDdeFGgHIjkLlMmNQRrSsTUuVvWwXxYy\d]/ =~ s || /\A\d/ =~ s
+ end
+
+ private_class_method :num_pattern?
- str
+ def self._strptime_i(str, fmt, e) # :nodoc:
+ fmt.scan(/%[EO]?(:{1,3}z|.)|(.)/m) do |s, c|
+ if s
+ case s
+ when 'A', 'a'
+ return unless str.sub!(/\A(#{Format::DAYS.keys.join('|')})/io, '') ||
+ str.sub!(/\A(#{Format::ABBR_DAYS.keys.join('|')})/io, '')
+ val = Format::DAYS[$1.downcase] || Format::ABBR_DAYS[$1.downcase]
+ return unless val
+ e.wday = val
+ when 'B', 'b', 'h'
+ return unless str.sub!(/\A(#{Format::MONTHS.keys.join('|')})/io, '') ||
+ str.sub!(/\A(#{Format::ABBR_MONTHS.keys.join('|')})/io, '')
+ val = Format::MONTHS[$1.downcase] || Format::ABBR_MONTHS[$1.downcase]
+ return unless val
+ e.mon = val
+ when 'C'
+ return unless str.sub!(if num_pattern?($')
+ then /\A([-+]?\d{1,2})/
+ else /\A([-+]?\d{1,})/
+ end, '')
+ val = $1.to_i
+ e._cent = val
+ when 'c'
+ return unless _strptime_i(str, '%a %b %e %H:%M:%S %Y', e)
+ when 'D'
+ return unless _strptime_i(str, '%m/%d/%y', e)
+ when 'd', 'e'
+ return unless str.sub!(/\A( \d|\d{1,2})/, '')
+ val = $1.to_i
+ return unless (1..31) === val
+ e.mday = val
+ when 'F'
+ return unless _strptime_i(str, '%Y-%m-%d', e)
+ when 'G'
+ return unless str.sub!(if num_pattern?($')
+ then /\A([-+]?\d{1,4})/
+ else /\A([-+]?\d{1,})/
+ end, '')
+ val = $1.to_i
+ e.cwyear = val
+ when 'g'
+ return unless str.sub!(/\A(\d{1,2})/, '')
+ val = $1.to_i
+ return unless (0..99) === val
+ e.cwyear = val
+ e._cent ||= if val >= 69 then 19 else 20 end
+ when 'H', 'k'
+ return unless str.sub!(/\A( \d|\d{1,2})/, '')
+ val = $1.to_i
+ return unless (0..24) === val
+ e.hour = val
+ when 'I', 'l'
+ return unless str.sub!(/\A( \d|\d{1,2})/, '')
+ val = $1.to_i
+ return unless (1..12) === val
+ e.hour = val
+ when 'j'
+ return unless str.sub!(/\A(\d{1,3})/, '')
+ val = $1.to_i
+ return unless (1..366) === val
+ e.yday = val
+ when 'L'
+ return unless str.sub!(if num_pattern?($')
+ then /\A([-+]?\d{1,3})/
+ else /\A([-+]?\d{1,})/
+ end, '')
+# val = $1.to_i.to_r / (10**3)
+ val = $1.to_i.to_r / (10**$1.size)
+ e.sec_fraction = val
+ when 'M'
+ return unless str.sub!(/\A(\d{1,2})/, '')
+ val = $1.to_i
+ return unless (0..59) === val
+ e.min = val
+ when 'm'
+ return unless str.sub!(/\A(\d{1,2})/, '')
+ val = $1.to_i
+ return unless (1..12) === val
+ e.mon = val
+ when 'N'
+ return unless str.sub!(if num_pattern?($')
+ then /\A([-+]?\d{1,9})/
+ else /\A([-+]?\d{1,})/
+ end, '')
+# val = $1.to_i.to_r / (10**9)
+ val = $1.to_i.to_r / (10**$1.size)
+ e.sec_fraction = val
+ when 'n', 't'
+ return unless _strptime_i(str, "\s", e)
+ when 'P', 'p'
+ return unless str.sub!(/\A([ap])(?:m\b|\.m\.)/i, '')
+ e._merid = if $1.downcase == 'a' then 0 else 12 end
+ when 'Q'
+ return unless str.sub!(/\A(-?\d{1,})/, '')
+ val = $1.to_i.to_r / 10**3
+ e.seconds = val
+ when 'R'
+ return unless _strptime_i(str, '%H:%M', e)
+ when 'r'
+ return unless _strptime_i(str, '%I:%M:%S %p', e)
+ when 'S'
+ return unless str.sub!(/\A(\d{1,2})/, '')
+ val = $1.to_i
+ return unless (0..60) === val
+ e.sec = val
+ when 's'
+ return unless str.sub!(/\A(-?\d{1,})/, '')
+ val = $1.to_i
+ e.seconds = val
+ when 'T'
+ return unless _strptime_i(str, '%H:%M:%S', e)
+ when 'U', 'W'
+ return unless str.sub!(/\A(\d{1,2})/, '')
+ val = $1.to_i
+ return unless (0..53) === val
+ e.__send__(if s == 'U' then :wnum0= else :wnum1= end, val)
+ when 'u'
+ return unless str.sub!(/\A(\d{1})/, '')
+ val = $1.to_i
+ return unless (1..7) === val
+ e.cwday = val
+ when 'V'
+ return unless str.sub!(/\A(\d{1,2})/, '')
+ val = $1.to_i
+ return unless (1..53) === val
+ e.cweek = val
+ when 'v'
+ return unless _strptime_i(str, '%e-%b-%Y', e)
+ when 'w'
+ return unless str.sub!(/\A(\d{1})/, '')
+ val = $1.to_i
+ return unless (0..6) === val
+ e.wday = val
+ when 'X'
+ return unless _strptime_i(str, '%H:%M:%S', e)
+ when 'x'
+ return unless _strptime_i(str, '%m/%d/%y', e)
+ when 'Y'
+ return unless str.sub!(if num_pattern?($')
+ then /\A([-+]?\d{1,4})/
+ else /\A([-+]?\d{1,})/
+ end, '')
+ val = $1.to_i
+ e.year = val
+ when 'y'
+ return unless str.sub!(/\A(\d{1,2})/, '')
+ val = $1.to_i
+ return unless (0..99) === val
+ e.year = val
+ e._cent ||= if val >= 69 then 19 else 20 end
+ when 'Z', /\A:{0,3}z/
+ return unless str.sub!(/\A((?:gmt|utc?)?[-+]\d+(?:[,.:]\d+(?::\d+)?)?
+ |[a-z.\s]+(?:standard|daylight)\s+time\b
+ |[a-z]+(?:\s+dst)?\b
+ )/ix, '')
+ val = $1
+ e.zone = val
+ offset = zone_to_diff(val)
+ e.offset = offset
+ when '%'
+ return unless str.sub!(/\A%/, '')
+ when '+'
+ return unless _strptime_i(str, '%a %b %e %H:%M:%S %Z %Y', e)
+ when '1'
+ if $VERBOSE
+ warn("warning: strptime: %1 is deprecated; forget this")
+ end
+ return unless str.sub!(/\A(\d+)/, '')
+ val = $1.to_i
+ e.jd = val
+ when '2'
+ if $VERBOSE
+ warn("warning: strptime: %2 is deprecated; use '%Y-%j'")
+ end
+ return unless _strptime_i(str, '%Y-%j', e)
+ when '3'
+ if $VERBOSE
+ warn("warning: strptime: %3 is deprecated; use '%F'")
+ end
+ return unless _strptime_i(str, '%F', e)
+ else
+ return unless str.sub!(Regexp.new('\\A' + Regexp.quote(s)), '')
+ end
+ else
+ case c
+ when /\A[\s\v]/
+ str.sub!(/\A[\s\v]+/, '')
+ else
+ return unless str.sub!(Regexp.new('\\A' + Regexp.quote(c)), '')
+ end
+ end
+ end
end
- private_class_method :__strptime
+ private_class_method :_strptime_i
def self._strptime(str, fmt='%F')
- elem = {}
- elem if __strptime(str.dup, fmt, elem)
+ e = Format::Bag.new
+ return unless _strptime_i(str.dup, fmt, e)
+
+ if e._cent
+ if e.cwyear
+ e.cwyear += e._cent * 100
+ end
+ if e.year
+ e. year += e._cent * 100
+ end
+ end
+
+ if e._merid
+ if e.hour
+ e.hour %= 12
+ e.hour += e._merid
+ end
+ end
+
+ e.to_hash
end
- PARSE_MONTHPAT = ABBR_MONTHS.keys.join('|')
- PARSE_DAYPAT = ABBR_DAYS. keys.join('|')
+ def self.s3e(e, y, m, d, bc=false)
+ unless String === m
+ m = m.to_s
+ end
+
+ if y == nil
+ if d && d.size > 2
+ y = d
+ d = nil
+ end
+ if d && d[0,1] == "'"
+ y = d
+ d = nil
+ end
+ end
- def self._parse(str, comp=false)
- str = str.dup
+ if y
+ y.scan(/(\d+)(.+)?/)
+ if $2
+ y, d = d, $1
+ end
+ end
+
+ if m
+ if m[0,1] == "'" || m.size > 2
+ y, m, d = m, d, y # us -> be
+ end
+ end
+
+ if d
+ if d[0,1] == "'" || d.size > 2
+ y, d = d, y
+ end
+ end
+
+ if y
+ y =~ /([-+])?(\d+)/
+ if $1 || $2.size > 2
+ c = false
+ end
+ iy = $&.to_i
+ if bc
+ iy = -iy + 1
+ end
+ e.year = iy
+ end
+
+ if m
+ m =~ /\d+/
+ e.mon = $&.to_i
+ end
+
+ if d
+ d =~ /\d+/
+ e.mday = $&.to_i
+ end
+
+ if c != nil
+ e._comp = c
+ end
- str.gsub!(/[^-+,.\/:0-9a-z]+/ino, ' ')
+ end
+
+ private_class_method :s3e
- # day
- if str.sub!(/(#{PARSE_DAYPAT})\S*/ino, ' ')
- wday = ABBR_DAYS[$1.downcase]
+ def self._parse_day(str, e) # :nodoc:
+ if str.sub!(/\b(#{Format::ABBR_DAYS.keys.join('|')})[^-\d\s]*/ino, ' ')
+ e.wday = Format::ABBR_DAYS[$1.downcase]
+ true
+=begin
+ elsif str.sub!(/\b(?!\dth)(su|mo|tu|we|th|fr|sa)\b/in, ' ')
+ e.wday = %w(su mo tu we th fr sa).index($1.downcase)
+ true
+=end
end
+ end
- # time
+ def self._parse_time(str, e) # :nodoc:
if str.sub!(
- /(\d+):(\d+)
- (?:
- :(\d+)(?:[,.](\d*))?
- )?
- (?:
- \s*
- ([ap])(?:m\b|\.m\.)
- )?
+ /(
+ (?:
+ \d+\s*:\s*\d+
+ (?:
+ \s*:\s*\d+(?:[,.]\d*)?
+ )?
+ |
+ \d+\s*h(?:\s*\d+m?(?:\s*\d+s?)?)?
+ )
+ (?:
+ \s*
+ [ap](?:m\b|\.m\.)
+ )?
+ |
+ \d+\s*[ap](?:m\b|\.m\.)
+ )
(?:
\s*
(
- [a-z]+(?:\s+dst)?\b
+ (?:gmt|utc?)?[-+]\d+(?:[,.:]\d+(?::\d+)?)?
+ |
+ [a-z.\s]+(?:standard|daylight)\stime\b
|
- [-+]\d+(?::?\d+)
+ [a-z]+(?:\sdst)?\b
)
)?
- /inox,
+ /inx,
' ')
- 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
+
+ t = $1
+ e.zone = $2 if $2
+
+ t =~ /\A(\d+)h?
+ (?:\s*:?\s*(\d+)m?
+ (?:
+ \s*:?\s*(\d+)(?:[,.](\d+))?s?
+ )?
+ )?
+ (?:\s*([ap])(?:m\b|\.m\.))?/inx
+
+ e.hour = $1.to_i
+ e.min = $2.to_i if $2
+ e.sec = $3.to_i if $3
+ e.sec_fraction = $4.to_i.to_r / (10**$4.size) if $4
if $5
- hour %= 12
+ e.hour %= 12
if $5.downcase == 'p'
- hour += 12
+ e.hour += 12
end
end
+ true
+ end
+ end
- if $6
- zone = $6
- end
+ def self._parse_beat(str, e) # :nodoc:
+ if str.sub!(/@\s*(\d+)(?:[,.](\d*))?/, ' ')
+ beat = $1.to_i.to_r
+ beat += $2.to_i.to_r / (10**$2.size) if $2
+ secs = beat.to_r / 1000
+ h, min, s, fr = self.day_fraction_to_time(secs)
+ e.hour = h
+ e.min = min
+ e.sec = s
+ e.sec_fraction = fr * 86400
+ e.zone = '+01:00'
+ true
end
+ end
- # eu
+ def self._parse_eu(str, e) # :nodoc:
if str.sub!(
- /(\d+)\S*
- \s+
- (#{PARSE_MONTHPAT})\S*
+ /'?(\d+)[^-\d\s]*
+ \s*
+ (#{Format::ABBR_MONTHS.keys.join('|')})[^-\d\s']*
(?:
- \s+
- (-?\d+)
+ \s*
+ (c(?:e|\.e\.)|b(?:ce|\.c\.e\.)|a(?:d|\.d\.)|b(?:c|\.c\.))?
+ \s*
+ ('?-?\d+(?:(?:st|nd|rd|th)\b)?)
)?
/inox,
- ' ')
- mday = $1.to_i
- mon = ABBR_MONTHS[$2.downcase]
-
- if $3
- year = $3.to_i
- if $3.size > 2
- comp = false
- end
- end
+ ' ') # '
+ s3e(e, $4, Format::ABBR_MONTHS[$2.downcase], $1,
+ $3 && $3[0,1].downcase == 'b')
+ true
+ end
+ end
- # us
- elsif str.sub!(
- /(#{PARSE_MONTHPAT})\S*
- \s+
- (\d+)\S*
- (?:
- \s+
- (-?\d+)
- )?
- /inox,
- ' ')
- mon = ABBR_MONTHS[$1.downcase]
- mday = $2.to_i
+ def self._parse_us(str, e) # :nodoc:
+ if str.sub!(
+ /\b(#{Format::ABBR_MONTHS.keys.join('|')})[^-\d\s']*
+ \s*
+ ('?\d+)[^-\d\s']*
+ (?:
+ \s*
+ (c(?:e|\.e\.)|b(?:ce|\.c\.e\.)|a(?:d|\.d\.)|b(?:c|\.c\.))?
+ \s*
+ ('?-?\d+)
+ )?
+ /inox,
+ ' ') # '
+ s3e(e, $4, Format::ABBR_MONTHS[$1.downcase], $2,
+ $3 && $3[0,1].downcase == 'b')
+ true
+ end
+ end
- if $3
- year = $3.to_i
- if $3.size > 2
- comp = false
- end
- end
+ def self._parse_iso(str, e) # :nodoc:
+ if str.sub!(/('?[-+]?\d+)-(\d+)-('?-?\d+)/n, ' ')
+ s3e(e, $1, $2, $3)
+ true
+ 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
+ def self._parse_iso2(str, e) # :nodoc:
+ if str.sub!(/\b(\d{2}|\d{4})?-?w(\d{2})(?:-?(\d+))?/in, ' ')
+ e.cwyear = $1.to_i if $1
+ e.cweek = $2.to_i
+ e.cwday = $3.to_i if $3
+ true
+ elsif str.sub!(/--(\d{2})-(\d{2})\b/n, ' ')
+ e.mon = $1.to_i
+ e.mday = $2.to_i
+ true
+ elsif str.sub!(/\b(\d{2}|\d{4})-(\d{2,3})\b/n, ' ')
+ e.year = $1.to_i
+ if $2.size < 3
+ e.mon = $2.to_i
+ else
+ e.yday = $2.to_i
end
+ true
+ end
+ end
- # jis
- elsif str.sub!(/([MTSH])(\d+)\.(\d+)\.(\d+)/ino, ' ')
- e = { 'm'=>1867,
- 't'=>1911,
- 's'=>1925,
- 'h'=>1988
+ def self._parse_jis(str, e) # :nodoc:
+ if str.sub!(/\b([MTSH])(\d+)\.(\d+)\.(\d+)/in, ' ')
+ era = { '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
+ e.year = $2.to_i + era
+ e.mon = $3.to_i
+ e.mday = $4.to_i
+ true
+ end
+ end
- # sla
- elsif str.sub!(%r|(-?\d+)/(\d+)(?:/(-?\d+))?|no, ' ')
- mon = $1.to_i
- mday = $2.to_i
+ def self._parse_vms(str, e) # :nodoc:
+ if str.sub!(/('?-?\d+)-(#{Format::ABBR_MONTHS.keys.join('|')})[^-]*
+ -('?-?\d+)/inox, ' ')
+ s3e(e, $3, Format::ABBR_MONTHS[$2.downcase], $1)
+ true
+ elsif str.sub!(/\b(#{Format::ABBR_MONTHS.keys.join('|')})[^-]*
+ -('?-?\d+)(?:-('?-?\d+))?/inox, ' ')
+ s3e(e, $3, Format::ABBR_MONTHS[$1.downcase], $2)
+ true
+ end
+ end
- if $3
- year = $3.to_i
- if $3.size > 2
- comp = false
- end
- end
+ def self._parse_sla_ja(str, e) # :nodoc:
+ if str.sub!(%r|('?-?\d+)[/.]\s*('?\d+)(?:[^\d]\s*('?-?\d+))?|n, ' ') # '
+ s3e(e, $1, $2, $3)
+ true
+ end
+ end
- if $3 && $1.size > 2
- comp = false
- year, mon, mday = mon, mday, year
- end
+ def self._parse_sla_eu(str, e) # :nodoc:
+ if str.sub!(%r|('?-?\d+)[/.]\s*('?\d+)(?:[^\d]\s*('?-?\d+))?|n, ' ') # '
+ s3e(e, $3, $2, $1)
+ true
+ end
+ end
+
+ def self._parse_sla_us(str, e) # :nodoc:
+ if str.sub!(%r|('?-?\d+)[/.]\s*('?\d+)(?:[^\d]\s*('?-?\d+))?|n, ' ') # '
+ s3e(e, $3, $1, $2)
+ true
+ end
+ end
+
+ def self._parse_year(str, e) # :nodoc:
+ if str.sub!(/'(\d+)\b/in, ' ')
+ e.year = $1.to_i
+ true
+ end
+ end
+
+ def self._parse_mon(str, e) # :nodoc:
+ if str.sub!(/\b(#{Format::ABBR_MONTHS.keys.join('|')})\S*/ino, ' ')
+ e.mon = Format::ABBR_MONTHS[$1.downcase]
+ true
+ end
+ end
- # ddd
- elsif str.sub!(
- /([-+]?)(\d{4,14})
- (?:
- \s*
- T?
- \s*
- (\d{2,6})(?:[,.](\d*))?
- )?
- (?:
- \s*
- (
- Z
- |
- [-+]\d{2,4}
- )
- \b
- )?
- /inox,
- ' ')
+ def self._parse_mday(str, e) # :nodoc:
+ if str.sub!(/(\d+)(st|nd|rd|th)\b/in, ' ')
+ e.mday = $1.to_i
+ true
+ end
+ end
+
+ def self._parse_ddd(str, e) # :nodoc:
+ if str.sub!(
+ /([-+]?)(\d{2,14})
+ (?:
+ \s*
+ T?
+ \s*
+ (\d{2,6})(?:[,.](\d*))?
+ )?
+ (?:
+ \s*
+ (
+ Z
+ |
+ [-+]\d{1,4}
+ )
+ \b
+ )?
+ /inx,
+ ' ')
case $2.size
+ when 2
+ e.mday = $2[ 0, 2].to_i
when 4
- mon = $2[ 0, 2].to_i
- mday = $2[ 2, 2].to_i
+ e.mon = $2[ 0, 2].to_i
+ e.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
+ e.year = ($1 + $2[ 0, 2]).to_i
+ e.mon = $2[ 2, 2].to_i
+ e.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
+ e.year = ($1 + $2[ 0, 4]).to_i
+ e.mon = $2[ 4, 2].to_i
+ e.mday = $2[ 6, 2].to_i
+ e.hour = $2[ 8, 2].to_i if $2.size >= 10
+ e.min = $2[10, 2].to_i if $2.size >= 12
+ e.sec = $2[12, 2].to_i if $2.size >= 14
+ e._comp = false
+ when 3
+ e.yday = $2[ 0, 3].to_i
+ when 5
+ e.year = ($1 + $2[ 0, 2]).to_i
+ e.yday = $2[ 2, 3].to_i
+ when 7
+ e.year = ($1 + $2[ 0, 4]).to_i
+ e.yday = $2[ 4, 3].to_i
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
+ e.hour = $3[ 0, 2].to_i
+ e.min = $3[ 2, 2].to_i if $3.size >= 4
+ e.sec = $3[ 4, 2].to_i if $3.size >= 6
end
end
if $4
- sec_fraction = $4.to_i.to_r / (10**$4.size)
+ e.sec_fraction = $4.to_i.to_r / (10**$4.size)
end
if $5
- zone = $5
+ e.zone = $5
end
+ true
end
+ end
+
+ private_class_method :_parse_day, :_parse_time, :_parse_beat,
+ :_parse_eu, :_parse_us, :_parse_iso, :_parse_iso2,
+ :_parse_jis, :_parse_vms,
+ :_parse_sla_ja, :_parse_sla_eu, :_parse_sla_us,
+ :_parse_year, :_parse_mon, :_parse_mday, :_parse_ddd
+
+ def self._parse(str, comp=false)
+ str = str.dup
+
+ e = Format::Bag.new
+
+ e._comp = comp
- if str.sub!(/\b(bc\b|bce\b|b\.c\.|b\.c\.e\.)/ino, ' ')
- if year
- year = -year + 1
+ str.gsub!(/[^-+',.\/:0-9@a-z\x80-\xff]+/in, ' ')
+
+ _parse_time(str, e) # || _parse_beat(str, e)
+ _parse_day(str, e)
+
+ _parse_eu(str, e) ||
+ _parse_us(str, e) ||
+ _parse_iso(str, e) ||
+ _parse_jis(str, e) ||
+ _parse_vms(str, e) ||
+ _parse_sla_us(str, e) ||
+ _parse_iso2(str, e) ||
+ _parse_year(str, e) ||
+ _parse_mon(str, e) ||
+ _parse_mday(str, e) ||
+ _parse_ddd(str, e)
+
+ if str.sub!(/\b(bc\b|bce\b|b\.c\.|b\.c\.e\.)/in, ' ')
+ if e.year
+ e.year = -e.year + 1
end
end
- if comp and year
- if year >= 0 and year <= 99
- if year >= 69
- year += 1900
- else
- year += 2000
+ if str.sub!(/\A\s*(\d{1,2})\s*\z/n, ' ')
+ if e.hour && !e.mday
+ v = $1.to_i
+ if (1..31) === v
+ e.mday = v
+ end
+ end
+ if e.mday && !e.hour
+ v = $1.to_i
+ if (0..24) === v
+ e.hour = v
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 == '-'
+ if e._comp and e.year
+ if e.year >= 0 and e.year <= 99
+ if e.year >= 69
+ e.year += 1900
+ else
+ e.year += 2000
+ end
+ end
end
- offset
+
+ e.offset ||= zone_to_diff(e.zone) if e.zone
+
+ e.to_hash
end
- def strftime(fmt='%F')
- o = ''
- fmt.scan(/%[EO]?.|./mo) do |c|
- cc = c.sub(/\A%[EO]?(.)\z/mo, '%\\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
-=begin
- when '%N' # GNU date
- o << '%09d' % (sec_fraction / (1.to_r/86400/(10**9)))
-=end
- 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[-1,1] == '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'
- if $VERBOSE
- warn("warning: %1 is deprecated; forget this")
- end
- o << '%d' % jd
- when '%2'
- if $VERBOSE
- warn("warning: %2 is deprecated; use '%Y-%j'")
- end
- o << strftime('%Y-%j')
- when '%3'
- if $VERBOSE
- warn("warning: %3 is deprecated; use '%F'")
- end
- o << strftime('%F')
- when /\A%(.)/m
- o << $1
+ def self.zone_to_diff(zone) # :nodoc:
+ zone = zone.downcase
+ if zone.sub!(/\s+(standard|daylight)\s+time\z/, '')
+ dst = $1 == 'daylight'
+ else
+ dst = zone.sub!(/\s+dst\z/, '')
+ end
+ if Format::ZONES.include?(zone)
+ offset = Format::ZONES[zone]
+ offset += 3600 if dst
+ elsif zone.sub!(/\A(?:gmt|utc?)?([-+])/, '')
+ sign = $1
+ if zone.include?(':')
+ hour, min, sec, = zone.split(':')
+ elsif zone.include?(',') || zone.include?('.')
+ hour, fr, = zone.split(/[,.]/)
+ min = fr.to_i.to_r / (10**fr.size) * 60
else
- o << c
+ case zone.size
+ when 3
+ hour = zone[0,1]
+ min = zone[1,2]
+ else
+ hour = zone[0,2]
+ min = zone[2,2]
+ sec = zone[4,2]
+ end
end
+ offset = hour.to_i * 3600 + min.to_i * 60 + sec.to_i
+ offset *= -1 if sign == '-'
end
- o
+ offset
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')
+ def strftime(fmt='%FT%T%:z')
+ super(fmt)
+ end
+
+ def self._strptime(str, fmt='%FT%T%z')
super(str, fmt)
end
- def strftime(fmt='%FT%T%Z')
- super(fmt)
+=begin
+ def iso8601_timediv(n) # :nodoc:
+ strftime('T%T' +
+ if n < 1
+ ''
+ else
+ '.%0*d' % [n, (sec_fraction / (1.to_r/86400/(10**n))).round]
+ end +
+ '%:z')
+ end
+
+ private :iso8601_timediv
+
+ def iso8601(n=0)
+ super() + iso8601_timediv(n)
end
+ def rfc3339(n=0) iso8601(n) end
+
+ def jisx0301(n=0)
+ super() + iso8601_timediv(n)
+ end
+=end
+
end
diff --git a/lib/delegate.rb b/lib/delegate.rb
index 93c9803a18..d810ccad42 100644
--- a/lib/delegate.rb
+++ b/lib/delegate.rb
@@ -184,6 +184,7 @@ class Delegator
# Reinitializes delegation from a serialized object.
def marshal_load(obj)
initialize_methods(obj)
+ __setobj__(obj)
end
end
diff --git a/lib/drb/acl.rb b/lib/drb/acl.rb
index aa86dbe70f..861c8a514d 100644
--- a/lib/drb/acl.rb
+++ b/lib/drb/acl.rb
@@ -13,6 +13,8 @@ class ACL
def initialize(str)
if str == '*' or str == 'all'
@pat = [:all]
+ elsif str.include?('*')
+ @pat = [:name, dot_pat(str)]
else
begin
@pat = [:ip, IPAddr.new(str)]
diff --git a/lib/drb/unix.rb b/lib/drb/unix.rb
index 989ec57eed..57feed8301 100644
--- a/lib/drb/unix.rb
+++ b/lib/drb/unix.rb
@@ -88,7 +88,7 @@ module DRb
public
def close
return unless @socket
- path = @socket.path
+ path = @socket.path if @server_mode
@socket.close
File.unlink(path) if @server_mode
@socket = nil
diff --git a/lib/erb.rb b/lib/erb.rb
index bf4b441028..b714aa1ea6 100644
--- a/lib/erb.rb
+++ b/lib/erb.rb
@@ -236,7 +236,7 @@
# Rails, the web application framework, uses ERB to create views.
#
class ERB
- Revision = '$Date: 2006/02/12 15:09:25 $' #'
+ Revision = '$Date$' #'
# Returns revision information for the erb.rb module.
def self.version
diff --git a/lib/fileutils.rb b/lib/fileutils.rb
index 043a24d2b5..3fdb6cbfe6 100644
--- a/lib/fileutils.rb
+++ b/lib/fileutils.rb
@@ -1,7 +1,7 @@
#
# = fileutils.rb
#
-# Copyright (c) 2000-2005 Minero Aoki <aamine@loveruby.net>
+# Copyright (c) 2000-2006 Minero Aoki
#
# This program is free software.
# You can distribute/modify this program under the same terms of ruby.
@@ -116,7 +116,7 @@ module FileUtils
# FileUtils.cd('/', :verbose => true) # chdir and report it
#
def cd(dir, options = {}, &block) # :yield: dir
- fu_check_options options, :verbose
+ fu_check_options options, OPT_TABLE['cd']
fu_output_message "cd #{dir}" if options[:verbose]
Dir.chdir(dir, &block)
fu_output_message 'cd -' if options[:verbose] and block
@@ -127,7 +127,7 @@ module FileUtils
module_function :chdir
OPT_TABLE['cd'] =
- OPT_TABLE['chdir'] = %w( verbose )
+ OPT_TABLE['chdir'] = [:verbose]
#
# Options: (none)
@@ -163,7 +163,7 @@ module FileUtils
# FileUtils.mkdir 'tmp', :mode => 0700
#
def mkdir(list, options = {})
- fu_check_options options, :mode, :noop, :verbose
+ fu_check_options options, OPT_TABLE['mkdir']
list = fu_list(list)
fu_output_message "mkdir #{options[:mode] ? ('-m %03o ' % options[:mode]) : ''}#{list.join ' '}" if options[:verbose]
return if options[:noop]
@@ -174,7 +174,7 @@ module FileUtils
end
module_function :mkdir
- OPT_TABLE['mkdir'] = %w( noop verbose mode )
+ OPT_TABLE['mkdir'] = [:mode, :noop, :verbose]
#
# Options: mode noop verbose
@@ -193,7 +193,7 @@ module FileUtils
# You can pass several directories at a time in a list.
#
def mkdir_p(list, options = {})
- fu_check_options options, :mode, :noop, :verbose
+ fu_check_options options, OPT_TABLE['mkdir_p']
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]
@@ -232,7 +232,7 @@ module FileUtils
OPT_TABLE['mkdir_p'] =
OPT_TABLE['mkpath'] =
- OPT_TABLE['makedirs'] = %w( noop verbose )
+ OPT_TABLE['makedirs'] = [:mode, :noop, :verbose]
def fu_mkdir(path, mode) #:nodoc:
path = path.sub(%r</\z>, '')
@@ -256,7 +256,7 @@ module FileUtils
# FileUtils.rmdir 'somedir', :verbose => true, :noop => true
#
def rmdir(list, options = {})
- fu_check_options options, :noop, :verbose
+ fu_check_options options, OPT_TABLE['rmdir']
list = fu_list(list)
fu_output_message "rmdir #{list.join ' '}" if options[:verbose]
return if options[:noop]
@@ -266,7 +266,7 @@ module FileUtils
end
module_function :rmdir
- OPT_TABLE['rmdir'] = %w( noop verbose )
+ OPT_TABLE['rmdir'] = [:noop, :verbose]
#
# Options: force noop verbose
@@ -291,7 +291,7 @@ module FileUtils
# FileUtils.ln %w(cp mv mkdir), '/bin' # Now /sbin/cp and /bin/cp are linked.
#
def ln(src, dest, options = {})
- fu_check_options options, :force, :noop, :verbose
+ fu_check_options options, OPT_TABLE['ln']
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|
@@ -305,7 +305,7 @@ module FileUtils
module_function :link
OPT_TABLE['ln'] =
- OPT_TABLE['link'] = %w( noop verbose force )
+ OPT_TABLE['link'] = [:force, :noop, :verbose]
#
# Options: force noop verbose
@@ -330,7 +330,7 @@ module FileUtils
# FileUtils.ln_s Dir.glob('bin/*.rb'), '/home/aamine/bin'
#
def ln_s(src, dest, options = {})
- fu_check_options options, :force, :noop, :verbose
+ fu_check_options options, OPT_TABLE['ln_s']
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|
@@ -344,7 +344,7 @@ module FileUtils
module_function :symlink
OPT_TABLE['ln_s'] =
- OPT_TABLE['symlink'] = %w( noop verbose force )
+ OPT_TABLE['symlink'] = [:force, :noop, :verbose]
#
# Options: noop verbose
@@ -353,14 +353,14 @@ module FileUtils
# #ln_s(src, dest, :force)
#
def ln_sf(src, dest, options = {})
- fu_check_options options, :noop, :verbose
+ fu_check_options options, OPT_TABLE['ln_sf']
options = options.dup
options[:force] = true
ln_s src, dest, options
end
module_function :ln_sf
- OPT_TABLE['ln_sf'] = %w( noop verbose )
+ OPT_TABLE['ln_sf'] = [:noop, :verbose]
#
# Options: preserve noop verbose
@@ -376,7 +376,7 @@ module FileUtils
# FileUtils.cp 'symlink', 'dest' # copy content, "dest" is not a symlink
#
def cp(src, dest, options = {})
- fu_check_options options, :preserve, :noop, :verbose
+ fu_check_options options, OPT_TABLE['cp']
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|
@@ -389,10 +389,10 @@ module FileUtils
module_function :copy
OPT_TABLE['cp'] =
- OPT_TABLE['copy'] = %w( noop verbose preserve )
+ OPT_TABLE['copy'] = [:preserve, :noop, :verbose]
#
- # Options: preserve noop verbose dereference_root
+ # Options: preserve noop verbose dereference_root remove_destination
#
# Copies +src+ to +dest+. If +src+ is a directory, this method copies
# all its contents recursively. If +dest+ is a directory, copies
@@ -415,17 +415,18 @@ module FileUtils
# # but this doesn't.
#
def cp_r(src, dest, options = {})
- fu_check_options options, :preserve, :noop, :verbose, :dereference_root
- fu_output_message "cp -r#{options[:preserve] ? 'p' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
+ fu_check_options options, OPT_TABLE['cp_r']
+ fu_output_message "cp -r#{options[:preserve] ? 'p' : ''}#{options[:remove_destination] ? ' --remove-destination' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
return if options[:noop]
options[:dereference_root] = true unless options.key?(:dereference_root)
fu_each_src_dest(src, dest) do |s, d|
- copy_entry s, d, options[:preserve], options[:dereference_root]
+ copy_entry s, d, options[:preserve], options[:dereference_root], options[:remove_destination]
end
end
module_function :cp_r
- OPT_TABLE['cp_r'] = %w( noop verbose preserve dereference_root )
+ OPT_TABLE['cp_r'] = [:preserve, :noop, :verbose,
+ :dereference_root, :remove_destination]
#
# Copies a file system entry +src+ to +dest+.
@@ -441,9 +442,12 @@ module FileUtils
#
# If +dereference_root+ is true, this method dereference tree root.
#
- def copy_entry(src, dest, preserve = false, dereference_root = false)
+ # If +remove_destination+ is true, this method removes each destination file before copy.
+ #
+ def copy_entry(src, dest, preserve = false, dereference_root = false, remove_destination = false)
Entry_.new(src, nil, dereference_root).traverse do |ent|
destent = Entry_.new(dest, ent.rel, false)
+ File.unlink destent.path if remove_destination && File.file?(destent.path)
ent.copy destent.path
ent.copy_metadata destent.path if preserve
end
@@ -484,7 +488,7 @@ module FileUtils
# FileUtils.mv Dir.glob('test*.rb'), 'test', :noop => true, :verbose => true
#
def mv(src, dest, options = {})
- fu_check_options options, :force, :noop, :verbose, :secure
+ fu_check_options options, OPT_TABLE['mv']
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|
@@ -518,7 +522,7 @@ module FileUtils
module_function :move
OPT_TABLE['mv'] =
- OPT_TABLE['move'] = %w[force noop verbose secure]
+ OPT_TABLE['move'] = [:force, :noop, :verbose, :secure]
def rename_cannot_overwrite_file? #:nodoc:
/djgpp|cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM
@@ -536,7 +540,7 @@ module FileUtils
# FileUtils.rm 'NotExistFile', :force => true # never raises exception
#
def rm(list, options = {})
- fu_check_options options, :force, :noop, :verbose
+ fu_check_options options, OPT_TABLE['rm']
list = fu_list(list)
fu_output_message "rm#{options[:force] ? ' -f' : ''} #{list.join ' '}" if options[:verbose]
return if options[:noop]
@@ -551,7 +555,7 @@ module FileUtils
module_function :remove
OPT_TABLE['rm'] =
- OPT_TABLE['remove'] = %w( noop verbose force )
+ OPT_TABLE['remove'] = [:force, :noop, :verbose]
#
# Options: noop verbose
@@ -561,7 +565,7 @@ module FileUtils
# #rm(list, :force => true)
#
def rm_f(list, options = {})
- fu_check_options options, :noop, :verbose
+ fu_check_options options, OPT_TABLE['rm_f']
options = options.dup
options[:force] = true
rm list, options
@@ -572,7 +576,7 @@ module FileUtils
module_function :safe_unlink
OPT_TABLE['rm_f'] =
- OPT_TABLE['safe_unlink'] = %w( noop verbose )
+ OPT_TABLE['safe_unlink'] = [:noop, :verbose]
#
# Options: force noop verbose secure
@@ -596,7 +600,7 @@ module FileUtils
# See also #remove_entry_secure.
#
def rm_r(list, options = {})
- fu_check_options options, :force, :noop, :verbose, :secure
+ fu_check_options options, OPT_TABLE['rm_r']
# options[:secure] = true unless options.key?(:secure)
list = fu_list(list)
fu_output_message "rm -r#{options[:force] ? 'f' : ''} #{list.join ' '}" if options[:verbose]
@@ -611,7 +615,7 @@ module FileUtils
end
module_function :rm_r
- OPT_TABLE['rm_r'] = %w( noop verbose force secure )
+ OPT_TABLE['rm_r'] = [:force, :noop, :verbose, :secure]
#
# Options: noop verbose secure
@@ -624,7 +628,7 @@ module FileUtils
# Read the documentation of #rm_r first.
#
def rm_rf(list, options = {})
- fu_check_options options, :noop, :verbose, :secure
+ fu_check_options options, OPT_TABLE['rm_rf']
options = options.dup
options[:force] = true
rm_r list, options
@@ -635,7 +639,7 @@ module FileUtils
module_function :rmtree
OPT_TABLE['rm_rf'] =
- OPT_TABLE['rmtree'] = %w( noop verbose secure )
+ OPT_TABLE['rmtree'] = [:noop, :verbose, :secure]
#
# This method removes a file system entry +path+. +path+ shall be a
@@ -820,16 +824,17 @@ module FileUtils
module_function :compare_stream
#
- # Options: mode noop verbose
+ # Options: mode preserve 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+.
+ # This method removes destination before copy.
#
# 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_check_options options, OPT_TABLE['install']
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|
@@ -844,7 +849,7 @@ module FileUtils
end
module_function :install
- OPT_TABLE['install'] = %w( noop verbose preserve mode )
+ OPT_TABLE['install'] = [:mode, :preserve, :noop, :verbose]
#
# Options: noop verbose
@@ -857,7 +862,7 @@ module FileUtils
# FileUtils.chmod 0755, '/usr/bin/ruby', :verbose => true
#
def chmod(mode, list, options = {})
- fu_check_options options, :noop, :verbose
+ fu_check_options options, OPT_TABLE['chmod']
list = fu_list(list)
fu_output_message sprintf('chmod %o %s', mode, list.join(' ')) if options[:verbose]
return if options[:noop]
@@ -867,7 +872,7 @@ module FileUtils
end
module_function :chmod
- OPT_TABLE['chmod'] = %w( noop verbose )
+ OPT_TABLE['chmod'] = [:noop, :verbose]
#
# Options: noop verbose force
@@ -878,7 +883,7 @@ module FileUtils
# FileUtils.chmod_R 0700, "/tmp/app.#{$$}"
#
def chmod_R(mode, list, options = {})
- fu_check_options options, :noop, :verbose, :force
+ fu_check_options options, OPT_TABLE['chmod_R']
list = fu_list(list)
fu_output_message sprintf('chmod -R%s %o %s',
(options[:force] ? 'f' : ''),
@@ -896,7 +901,7 @@ module FileUtils
end
module_function :chmod_R
- OPT_TABLE['chmod_R'] = %w( noop verbose )
+ OPT_TABLE['chmod_R'] = [:noop, :verbose, :force]
#
# Options: noop verbose
@@ -911,7 +916,7 @@ module FileUtils
# FileUtils.chown nil, 'bin', Dir.glob('/usr/bin/*'), :verbose => true
#
def chown(user, group, list, options = {})
- fu_check_options options, :noop, :verbose
+ fu_check_options options, OPT_TABLE['chown']
list = fu_list(list)
fu_output_message sprintf('chown %s%s',
[user,group].compact.join(':') + ' ',
@@ -925,7 +930,7 @@ module FileUtils
end
module_function :chown
- OPT_TABLE['chown'] = %w( noop verbose )
+ OPT_TABLE['chown'] = [:noop, :verbose]
#
# Options: noop verbose force
@@ -940,7 +945,7 @@ module FileUtils
# FileUtils.chown_R 'cvs', 'cvs', '/var/cvs', :verbose => true
#
def chown_R(user, group, list, options = {})
- fu_check_options options, :noop, :verbose, :force
+ fu_check_options options, OPT_TABLE['chown_R']
list = fu_list(list)
fu_output_message sprintf('chown -R%s %s%s',
(options[:force] ? 'f' : ''),
@@ -962,7 +967,7 @@ module FileUtils
end
module_function :chown_R
- OPT_TABLE['chown_R'] = %w( noop verbose )
+ OPT_TABLE['chown_R'] = [:noop, :verbose, :force]
begin
require 'etc'
@@ -1010,24 +1015,31 @@ module FileUtils
# FileUtils.touch Dir.glob('*.c'); system 'make'
#
def touch(list, options = {})
- fu_check_options options, :noop, :verbose
+ fu_check_options options, OPT_TABLE['touch']
list = fu_list(list)
- fu_output_message "touch #{list.join ' '}" if options[:verbose]
+ created = nocreate = options[:nocreate]
+ t = options[:mtime]
+ if options[:verbose]
+ fu_output_message "touch #{nocreate ? ' -c' : ''}#{t ? t.strftime(' -t %Y%m%d%H%M.%S') : ''}#{list.join ' '}"
+ end
return if options[:noop]
- t = Time.now
list.each do |path|
+ created = nocreate
begin
File.utime(t, t, path)
rescue Errno::ENOENT
+ raise if created
File.open(path, 'a') {
;
}
+ created = true
+ retry if t
end
end
end
module_function :touch
- OPT_TABLE['touch'] = %w( noop verbose )
+ OPT_TABLE['touch'] = [:noop, :verbose, :mtime, :nocreate]
private
@@ -1420,10 +1432,10 @@ module FileUtils
end
private_module_function :fu_have_st_ino?
- def fu_check_options(options, *optdecl) #:nodoc:
+ def fu_check_options(options, optdecl) #:nodoc:
h = options.dup
- optdecl.each do |name|
- h.delete name
+ optdecl.each do |opt|
+ h.delete opt
end
raise ArgumentError, "no such option: #{h.keys.join(' ')}" unless h.empty?
end
@@ -1449,8 +1461,6 @@ module FileUtils
end
private_module_function :fu_output_message
- METHODS = singleton_methods() - ['private_module_function']
-
#
# Returns an Array of method names which have any options.
#
@@ -1466,7 +1476,7 @@ module FileUtils
# p FileUtils.options #=> ["noop", "force", "verbose", "preserve", "mode"]
#
def FileUtils.options
- OPT_TABLE.values.flatten.uniq
+ OPT_TABLE.values.flatten.uniq.map {|sym| sym.to_s }
end
#
@@ -1478,7 +1488,7 @@ module FileUtils
#
def FileUtils.have_option?(mid, opt)
li = OPT_TABLE[mid.to_s] or raise ArgumentError, "no such method: #{mid}"
- li.include?(opt.to_s)
+ li.include?(opt)
end
#
@@ -1487,7 +1497,7 @@ module FileUtils
# p FileUtils.options(:rm) #=> ["noop", "verbose", "force"]
#
def FileUtils.options_of(mid)
- OPT_TABLE[mid.to_s]
+ OPT_TABLE[mid.to_s].map {|sym| sym.to_s }
end
#
@@ -1496,9 +1506,12 @@ module FileUtils
# p FileUtils.collect_method(:preserve) #=> ["cp", "cp_r", "copy", "install"]
#
def FileUtils.collect_method(opt)
- OPT_TABLE.keys.select {|m| OPT_TABLE[m].include?(opt.to_s) }
+ OPT_TABLE.keys.select {|m| OPT_TABLE[m].include?(opt) }
end
+ METHODS = singleton_methods() - %w( private_module_function
+ commands options have_option? options_of collect_method )
+
#
# This module has all methods of FileUtils module, but it outputs messages
# before acting. This equates to passing the <tt>:verbose</tt> flag to
@@ -1508,7 +1521,7 @@ module FileUtils
include FileUtils
@fileutils_output = $stderr
@fileutils_label = ''
- ::FileUtils.collect_method('verbose').each do |name|
+ ::FileUtils.collect_method(:verbose).each do |name|
module_eval(<<-EOS, __FILE__, __LINE__ + 1)
def #{name}(*args)
super(*fu_update_option(args, :verbose => true))
@@ -1533,7 +1546,7 @@ module FileUtils
include FileUtils
@fileutils_output = $stderr
@fileutils_label = ''
- ::FileUtils.collect_method('noop').each do |name|
+ ::FileUtils.collect_method(:noop).each do |name|
module_eval(<<-EOS, __FILE__, __LINE__ + 1)
def #{name}(*args)
super(*fu_update_option(args, :noop => true))
@@ -1559,7 +1572,7 @@ module FileUtils
include FileUtils
@fileutils_output = $stderr
@fileutils_label = ''
- ::FileUtils.collect_method('noop').each do |name|
+ ::FileUtils.collect_method(:noop).each do |name|
module_eval(<<-EOS, __FILE__, __LINE__ + 1)
def #{name}(*args)
super(*fu_update_option(args, :noop => true, :verbose => true))
diff --git a/lib/forwardable.rb b/lib/forwardable.rb
index 4383ce9bbb..b6344cd4f6 100644
--- a/lib/forwardable.rb
+++ b/lib/forwardable.rb
@@ -1,8 +1,8 @@
# = forwardable - Support for the Delegation Pattern
#
# $Release Version: 1.1$
-# $Revision: 1.2.2.2 $
-# $Date: 2006/06/02 13:23:01 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ishitsuka.com)
#
# Documentation by James Edward Gray II and Gavin Sinclair
diff --git a/lib/generator.rb b/lib/generator.rb
index 21970981fc..a010559b60 100644
--- a/lib/generator.rb
+++ b/lib/generator.rb
@@ -2,7 +2,7 @@
#--
# $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,v 1.2.2.2 2004/05/07 08:48:23 matz Exp $
+# $Id$
#++
#
# = generator.rb: convert an internal iterator to an external one
diff --git a/lib/getopts.rb b/lib/getopts.rb
index 0e21bf96c7..7124269351 100644
--- a/lib/getopts.rb
+++ b/lib/getopts.rb
@@ -1,8 +1,8 @@
#
# getopts.rb -
# $Release Version: $
-# $Revision: 1.8.2.4 $
-# $Date: 2006/08/04 22:00:21 $
+# $Revision$
+# $Date$
# by Yasuo OHBA(SHL Japan Inc. Technology Dept.)
#
# --
@@ -17,7 +17,7 @@
warn "Warning:#{caller[0].sub(/:in `.*'\z/, '')}: getopts is deprecated after Ruby 1.8.1; use optparse instead" if caller[0] and $VERBOSE
-$RCS_ID=%q$Header: /src/ruby/lib/getopts.rb,v 1.8.2.4 2006/08/04 22:00:21 drbrain Exp $
+$RCS_ID=%q$Header$
# getopts is obsolete. Use GetoptLong.
diff --git a/lib/ipaddr.rb b/lib/ipaddr.rb
index 67e2b65332..17e47f016f 100644
--- a/lib/ipaddr.rb
+++ b/lib/ipaddr.rb
@@ -6,7 +6,7 @@
#
# You can redistribute and/or modify it under the same terms as Ruby.
#
-# $Id: ipaddr.rb,v 1.5.2.3 2006/08/04 22:00:21 drbrain Exp $
+# $Id$
#
# TODO:
# - scope_id support
diff --git a/lib/irb.rb b/lib/irb.rb
index 1f49768b7d..1fb4397e68 100644
--- a/lib/irb.rb
+++ b/lib/irb.rb
@@ -1,8 +1,8 @@
#
# irb.rb - irb main module
# $Release Version: 0.9.5 $
-# $Revision: 1.7.2.2 $
-# $Date: 2005/10/25 06:38:25 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
@@ -23,7 +23,7 @@ require "irb/locale"
STDOUT.sync = true
module IRB
- @RCS_ID='-$Id: irb.rb,v 1.7.2.2 2005/10/25 06:38:25 matz Exp $-'
+ @RCS_ID='-$Id$-'
class Abort < Exception;end
@@ -149,15 +149,10 @@ module IRB
line.untaint
@context.evaluate(line, line_no)
output_value if @context.echo?
- exc = nil
- rescue Interrupt => exc
- rescue SystemExit, SignalException
- raise
- rescue Exception => exc
- end
- if exc
- print exc.class, ": ", exc, "\n"
- if exc.backtrace[0] =~ /irb(2)?(\/.*|-.*|\.rb)?:/ && exc.class.to_s !~ /^IRB/
+ 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
@@ -166,7 +161,7 @@ module IRB
messages = []
lasts = []
levels = 0
- for m in exc.backtrace
+ for m in $@
m = @context.workspace.filter_backtrace(m) unless irb_bug
if m
if messages.size < @context.back_trace_limit
@@ -188,7 +183,8 @@ module IRB
print "Maybe IRB bug!!\n" if irb_bug
end
if $SAFE > 2
- abort "Error: irb does not work for $SAFE level higher than 2"
+ warn "Error: irb does not work for $SAFE level higher than 2"
+ exit 1
end
end
end
diff --git a/lib/irb/cmd/chws.rb b/lib/irb/cmd/chws.rb
index 63be940f7a..88585b778b 100644
--- a/lib/irb/cmd/chws.rb
+++ b/lib/irb/cmd/chws.rb
@@ -1,8 +1,8 @@
#
# change-ws.rb -
# $Release Version: 0.9.5$
-# $Revision: 1.1.2.1 $
-# $Date: 2005/04/19 19:24:58 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
diff --git a/lib/irb/cmd/fork.rb b/lib/irb/cmd/fork.rb
index 67dee460f1..2866b1373b 100644
--- a/lib/irb/cmd/fork.rb
+++ b/lib/irb/cmd/fork.rb
@@ -1,8 +1,8 @@
#
# fork.rb -
# $Release Version: 0.9.5 $
-# $Revision: 1.2.2.1 $
-# $Date: 2005/04/19 19:24:58 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
@@ -10,7 +10,7 @@
#
#
-@RCS_ID='-$Id: fork.rb,v 1.2.2.1 2005/04/19 19:24:58 keiju Exp $-'
+@RCS_ID='-$Id$-'
module IRB
diff --git a/lib/irb/cmd/help.rb b/lib/irb/cmd/help.rb
index 578d9e63a6..3e8d1388e0 100644
--- a/lib/irb/cmd/help.rb
+++ b/lib/irb/cmd/help.rb
@@ -1,8 +1,8 @@
#
# help.rb - helper using ri
# $Release Version: 0.9.5$
-# $Revision: 1.2.4.1 $
-# $Date: 2005/04/19 19:24:58 $
+# $Revision$
+# $Date$
#
# --
#
diff --git a/lib/irb/cmd/load.rb b/lib/irb/cmd/load.rb
index aec5d8a391..cbc5d91d03 100644
--- a/lib/irb/cmd/load.rb
+++ b/lib/irb/cmd/load.rb
@@ -1,8 +1,8 @@
#
# load.rb -
# $Release Version: 0.9.5$
-# $Revision: 1.1.2.1 $
-# $Date: 2005/04/19 19:24:58 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
diff --git a/lib/irb/cmd/nop.rb b/lib/irb/cmd/nop.rb
index f0e786e8d4..aa553c959e 100644
--- a/lib/irb/cmd/nop.rb
+++ b/lib/irb/cmd/nop.rb
@@ -1,8 +1,8 @@
#
# nop.rb -
# $Release Version: 0.9.5$
-# $Revision: 1.1.2.1 $
-# $Date: 2005/04/19 19:24:58 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
@@ -13,7 +13,7 @@ module IRB
module ExtendCommand
class Nop
- @RCS_ID='-$Id: nop.rb,v 1.1.2.1 2005/04/19 19:24:58 keiju Exp $-'
+ @RCS_ID='-$Id$-'
def self.execute(conf, *opts)
command = new(conf)
diff --git a/lib/irb/cmd/pushws.rb b/lib/irb/cmd/pushws.rb
index 7acfee094f..eddaeae631 100644
--- a/lib/irb/cmd/pushws.rb
+++ b/lib/irb/cmd/pushws.rb
@@ -1,8 +1,8 @@
#
# change-ws.rb -
# $Release Version: 0.9.5$
-# $Revision: 1.1.2.1 $
-# $Date: 2005/04/19 19:24:58 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
diff --git a/lib/irb/cmd/subirb.rb b/lib/irb/cmd/subirb.rb
index 3ea9db33a0..79d654b172 100644
--- a/lib/irb/cmd/subirb.rb
+++ b/lib/irb/cmd/subirb.rb
@@ -2,8 +2,8 @@
#
# multi.rb -
# $Release Version: 0.9.5$
-# $Revision: 1.1.2.1 $
-# $Date: 2005/04/19 19:24:58 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
diff --git a/lib/irb/completion.rb b/lib/irb/completion.rb
index 49fb4556fa..000658e2a3 100644
--- a/lib/irb/completion.rb
+++ b/lib/irb/completion.rb
@@ -1,8 +1,8 @@
#
# irb/completor.rb -
# $Release Version: 0.9$
-# $Revision: 1.8.2.3 $
-# $Date: 2006/07/19 15:08:56 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ishitsuka.com)
# From Original Idea of shugo@ruby-lang.org
#
@@ -12,7 +12,7 @@ require "readline"
module IRB
module InputCompletor
- @RCS_ID='-$Id: completion.rb,v 1.8.2.3 2006/07/19 15:08:56 keiju Exp $-'
+ @RCS_ID='-$Id$-'
ReservedWords = [
"BEGIN", "END",
diff --git a/lib/irb/context.rb b/lib/irb/context.rb
index c82be24db1..d01bd4aefa 100644
--- a/lib/irb/context.rb
+++ b/lib/irb/context.rb
@@ -1,8 +1,8 @@
#
# irb/context.rb - irb context
# $Release Version: 0.9.5$
-# $Revision: 1.8.2.3 $
-# $Date: 2005/07/31 15:10:26 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
diff --git a/lib/irb/ext/change-ws.rb b/lib/irb/ext/change-ws.rb
index d75fe485c8..fff8f58fe5 100644
--- a/lib/irb/ext/change-ws.rb
+++ b/lib/irb/ext/change-ws.rb
@@ -1,8 +1,8 @@
#
# irb/ext/cb.rb -
# $Release Version: 0.9.5$
-# $Revision: 1.1.2.1 $
-# $Date: 2005/04/19 19:24:58 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
diff --git a/lib/irb/ext/history.rb b/lib/irb/ext/history.rb
index 2354ca96f7..40f8692e8b 100644
--- a/lib/irb/ext/history.rb
+++ b/lib/irb/ext/history.rb
@@ -1,8 +1,8 @@
#
# history.rb -
# $Release Version: 0.9.5$
-# $Revision: 1.1.2.2 $
-# $Date: 2005/04/19 19:24:58 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
@@ -49,7 +49,7 @@ module IRB
end
class History
- @RCS_ID='-$Id: history.rb,v 1.1.2.2 2005/04/19 19:24:58 keiju Exp $-'
+ @RCS_ID='-$Id$-'
def initialize(size = 16)
@size = size
diff --git a/lib/irb/ext/loader.rb b/lib/irb/ext/loader.rb
index 67fdc31c8e..837e2553ac 100644
--- a/lib/irb/ext/loader.rb
+++ b/lib/irb/ext/loader.rb
@@ -1,8 +1,8 @@
#
# loader.rb -
# $Release Version: 0.9.5$
-# $Revision: 1.1.2.1 $
-# $Date: 2005/04/19 19:24:58 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
@@ -15,7 +15,7 @@ module IRB
class LoadAbort < Exception;end
module IrbLoader
- @RCS_ID='-$Id: loader.rb,v 1.1.2.1 2005/04/19 19:24:58 keiju Exp $-'
+ @RCS_ID='-$Id$-'
alias ruby_load load
alias ruby_require require
diff --git a/lib/irb/ext/math-mode.rb b/lib/irb/ext/math-mode.rb
index dfb01f8202..bd443b96ed 100644
--- a/lib/irb/ext/math-mode.rb
+++ b/lib/irb/ext/math-mode.rb
@@ -1,8 +1,8 @@
#
# math-mode.rb -
# $Release Version: 0.9.5$
-# $Revision: 1.2.2.1 $
-# $Date: 2005/04/19 19:24:58 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
diff --git a/lib/irb/ext/multi-irb.rb b/lib/irb/ext/multi-irb.rb
index 946840fd40..4589b1d554 100644
--- a/lib/irb/ext/multi-irb.rb
+++ b/lib/irb/ext/multi-irb.rb
@@ -1,8 +1,8 @@
#
# irb/multi-irb.rb - multiple irb module
# $Release Version: 0.9.5$
-# $Revision: 1.2.2.1 $
-# $Date: 2005/04/19 19:24:58 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
@@ -15,7 +15,7 @@ require "thread"
module IRB
# job management class
class JobManager
- @RCS_ID='-$Id: multi-irb.rb,v 1.2.2.1 2005/04/19 19:24:58 keiju Exp $-'
+ @RCS_ID='-$Id$-'
def initialize
# @jobs = [[thread, irb],...]
diff --git a/lib/irb/ext/save-history.rb b/lib/irb/ext/save-history.rb
index 889d81d5be..5260bfcdd8 100644
--- a/lib/irb/ext/save-history.rb
+++ b/lib/irb/ext/save-history.rb
@@ -2,8 +2,8 @@
#
# save-history.rb -
# $Release Version: 0.9.5$
-# $Revision: 1.2.4.1 $
-# $Date: 2005/04/19 19:24:58 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKAkeiju@ruby-lang.org)
#
# --
@@ -15,7 +15,7 @@ require "readline"
module IRB
module HistorySavingAbility
- @RCS_ID='-$Id: save-history.rb,v 1.2.4.1 2005/04/19 19:24:58 keiju Exp $-'
+ @RCS_ID='-$Id$-'
end
class Context
diff --git a/lib/irb/ext/tracer.rb b/lib/irb/ext/tracer.rb
index 8660bfed17..805f630a4d 100644
--- a/lib/irb/ext/tracer.rb
+++ b/lib/irb/ext/tracer.rb
@@ -1,8 +1,8 @@
#
# irb/lib/tracer.rb -
# $Release Version: 0.9.5$
-# $Revision: 1.1.2.1 $
-# $Date: 2005/04/19 19:24:58 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
diff --git a/lib/irb/ext/use-loader.rb b/lib/irb/ext/use-loader.rb
index 68bd1dd592..1b4d480fcd 100644
--- a/lib/irb/ext/use-loader.rb
+++ b/lib/irb/ext/use-loader.rb
@@ -1,8 +1,8 @@
#
# use-loader.rb -
# $Release Version: 0.9.5$
-# $Revision: 1.1.2.1 $
-# $Date: 2005/04/19 19:24:58 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
diff --git a/lib/irb/ext/workspaces.rb b/lib/irb/ext/workspaces.rb
index b09e52ca34..79098570dc 100644
--- a/lib/irb/ext/workspaces.rb
+++ b/lib/irb/ext/workspaces.rb
@@ -1,8 +1,8 @@
#
# push-ws.rb -
# $Release Version: 0.9.5$
-# $Revision: 1.1.2.1 $
-# $Date: 2005/04/19 19:24:58 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
diff --git a/lib/irb/extend-command.rb b/lib/irb/extend-command.rb
index 934f9f6fbb..8994f2f8d2 100644
--- a/lib/irb/extend-command.rb
+++ b/lib/irb/extend-command.rb
@@ -1,8 +1,8 @@
#
# irb/extend-command.rb - irb extend command
# $Release Version: 0.9.5$
-# $Revision: 1.4.2.3 $
-# $Date: 2006/08/08 15:16:21 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
diff --git a/lib/irb/frame.rb b/lib/irb/frame.rb
index a6f15d23e9..f0b0a9abf3 100644
--- a/lib/irb/frame.rb
+++ b/lib/irb/frame.rb
@@ -1,8 +1,8 @@
#
# frame.rb -
# $Release Version: 0.9$
-# $Revision: 1.4 $
-# $Date: 2002/07/09 11:17:16 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
#
# --
diff --git a/lib/irb/help.rb b/lib/irb/help.rb
index e239fdda4c..f091999bd1 100644
--- a/lib/irb/help.rb
+++ b/lib/irb/help.rb
@@ -1,8 +1,8 @@
#
# irb/help.rb - print usase module
# $Release Version: 0.9.5$
-# $Revision: 1.2.2.1 $
-# $Date: 2005/04/19 19:24:57 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ishitsuka.com)
#
# --
diff --git a/lib/irb/init.rb b/lib/irb/init.rb
index 938e6e3d29..db22ca639b 100644
--- a/lib/irb/init.rb
+++ b/lib/irb/init.rb
@@ -1,8 +1,8 @@
#
# irb/init.rb - irb initialize module
# $Release Version: 0.9.5$
-# $Revision: 1.6.2.6 $
-# $Date: 2006/08/04 10:15:49 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
diff --git a/lib/irb/input-method.rb b/lib/irb/input-method.rb
index d6abadba76..bfb90fa59a 100644
--- a/lib/irb/input-method.rb
+++ b/lib/irb/input-method.rb
@@ -1,8 +1,8 @@
#
# irb/input-method.rb - input methods used irb
# $Release Version: 0.9.5$
-# $Revision: 1.4.2.2 $
-# $Date: 2005/05/25 13:53:41 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
@@ -18,7 +18,7 @@ module IRB
#
STDIN_FILE_NAME = "(line)"
class InputMethod
- @RCS_ID='-$Id: input-method.rb,v 1.4.2.2 2005/05/25 13:53:41 shugo Exp $-'
+ @RCS_ID='-$Id$-'
def initialize(file = STDIN_FILE_NAME)
@file_name = file
diff --git a/lib/irb/lc/error.rb b/lib/irb/lc/error.rb
index 54420e3508..247596b7fe 100644
--- a/lib/irb/lc/error.rb
+++ b/lib/irb/lc/error.rb
@@ -1,8 +1,8 @@
#
# irb/lc/error.rb -
# $Release Version: 0.9.5$
-# $Revision: 1.5.2.1 $
-# $Date: 2005/04/19 19:24:59 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
diff --git a/lib/irb/lc/help-message b/lib/irb/lc/help-message
index f33d95e543..32087d113c 100644
--- a/lib/irb/lc/help-message
+++ b/lib/irb/lc/help-message
@@ -1,8 +1,8 @@
#
# irb/lc/help-message.rb -
# $Release Version: 0.9.5$
-# $Revision: 1.4.2.2 $
-# $Date: 2005/04/19 19:24:59 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
diff --git a/lib/irb/lc/ja/error.rb b/lib/irb/lc/ja/error.rb
index 25f8af68e0..4c2fb3b839 100644
--- a/lib/irb/lc/ja/error.rb
+++ b/lib/irb/lc/ja/error.rb
@@ -1,8 +1,8 @@
#
# irb/lc/ja/error.rb -
# $Release Version: 0.9.5$
-# $Revision: 1.5.2.1 $
-# $Date: 2005/04/19 19:24:59 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
diff --git a/lib/irb/lc/ja/help-message b/lib/irb/lc/ja/help-message
index 606f9e8984..debbfe9355 100644
--- a/lib/irb/lc/ja/help-message
+++ b/lib/irb/lc/ja/help-message
@@ -1,8 +1,8 @@
#
# irb/lc/ja/help-message.rb -
# $Release Version: 0.9.5$
-# $Revision: 1.3.2.2 $
-# $Date: 2005/04/19 19:24:59 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
diff --git a/lib/irb/locale.rb b/lib/irb/locale.rb
index 1f4f9f67d8..5ed9f54507 100644
--- a/lib/irb/locale.rb
+++ b/lib/irb/locale.rb
@@ -1,8 +1,8 @@
#
# irb/locale.rb - internationalization module
# $Release Version: 0.9.5$
-# $Revision: 1.6.2.3 $
-# $Date: 2005/09/01 18:30:46 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
@@ -14,7 +14,7 @@ autoload :Kconv, "kconv"
module IRB
class Locale
- @RCS_ID='-$Id: locale.rb,v 1.6.2.3 2005/09/01 18:30:46 keiju Exp $-'
+ @RCS_ID='-$Id$-'
JPDefaultLocale = "ja"
LOCALE_DIR = "/lc/"
@@ -71,7 +71,7 @@ module IRB
end
def puts(*opts)
- ary = opts.collect{|opt| String(opts)}
+ ary = opts.collect{|opt| String(opt)}
super(*ary)
end
@@ -153,8 +153,8 @@ module IRB
end
def search_file(path, file)
- if File.exists?(p1 = path + lc_path(file, "C"))
- if File.exists?(p2 = path + lc_path(file))
+ if File.exist?(p1 = path + lc_path(file, "C"))
+ if File.exist?(p2 = path + lc_path(file))
return p2
else
end
diff --git a/lib/irb/notifier.rb b/lib/irb/notifier.rb
index b03f445873..c8e66fa859 100644
--- a/lib/irb/notifier.rb
+++ b/lib/irb/notifier.rb
@@ -1,8 +1,8 @@
#
# notifier.rb - optput methods used by irb
# $Release Version: 0.9.5$
-# $Revision: 1.2.4.1 $
-# $Date: 2005/04/19 19:24:57 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
diff --git a/lib/irb/output-method.rb b/lib/irb/output-method.rb
index 01bfefb5af..b9a3a8851e 100644
--- a/lib/irb/output-method.rb
+++ b/lib/irb/output-method.rb
@@ -1,8 +1,8 @@
#
# output-method.rb - optput methods used by irb
# $Release Version: 0.9.5$
-# $Revision: 1.2.4.1 $
-# $Date: 2005/04/19 19:24:57 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
@@ -17,7 +17,7 @@ module IRB
# StdioOutputMethod
class OutputMethod
- @RCS_ID='-$Id: output-method.rb,v 1.2.4.1 2005/04/19 19:24:57 keiju Exp $-'
+ @RCS_ID='-$Id$-'
def print(*opts)
IRB.fail NotImplementError, "print"
diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb
index 6310fb626b..ab584d5253 100644
--- a/lib/irb/ruby-lex.rb
+++ b/lib/irb/ruby-lex.rb
@@ -1,8 +1,8 @@
#
# irb/ruby-lex.rb - ruby lexcal analizer
# $Release Version: 0.9.5$
-# $Revision: 1.22.2.6 $
-# $Date: 2006/08/04 10:15:49 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
@@ -15,7 +15,7 @@ require "irb/slex"
require "irb/ruby-token"
class RubyLex
- @RCS_ID='-$Id: ruby-lex.rb,v 1.22.2.6 2006/08/04 10:15:49 keiju Exp $-'
+ @RCS_ID='-$Id$-'
extend Exception2MessageMapper
def_exception(:AlreadyDefinedToken, "Already defined token(%s)")
diff --git a/lib/irb/ruby-token.rb b/lib/irb/ruby-token.rb
index 4d56754d36..525d4df14c 100644
--- a/lib/irb/ruby-token.rb
+++ b/lib/irb/ruby-token.rb
@@ -1,8 +1,8 @@
#
# irb/ruby-token.rb - ruby tokens
# $Release Version: 0.9.5$
-# $Revision: 1.5.2.1 $
-# $Date: 2005/04/19 19:24:57 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
diff --git a/lib/irb/slex.rb b/lib/irb/slex.rb
index ed99e8fc86..a6ea6fb473 100644
--- a/lib/irb/slex.rb
+++ b/lib/irb/slex.rb
@@ -1,8 +1,8 @@
#
# irb/slex.rb - symple lex analizer
# $Release Version: 0.9.5$
-# $Revision: 1.6.2.3 $
-# $Date: 2005/04/19 19:24:57 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
@@ -15,7 +15,7 @@ require "irb/notifier"
module IRB
class SLex
- @RCS_ID='-$Id: slex.rb,v 1.6.2.3 2005/04/19 19:24:57 keiju Exp $-'
+ @RCS_ID='-$Id$-'
extend Exception2MessageMapper
def_exception :ErrNodeNothing, "node nothing"
diff --git a/lib/irb/version.rb b/lib/irb/version.rb
index 95192669db..28b079740a 100644
--- a/lib/irb/version.rb
+++ b/lib/irb/version.rb
@@ -1,8 +1,8 @@
#
# irb/version.rb - irb version definition file
# $Release Version: 0.9.5$
-# $Revision: 1.4.2.1 $
-# $Date: 2005/04/19 19:24:57 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ishitsuka.com)
#
# --
diff --git a/lib/irb/workspace.rb b/lib/irb/workspace.rb
index 364820f997..7d1794cd7b 100644
--- a/lib/irb/workspace.rb
+++ b/lib/irb/workspace.rb
@@ -1,8 +1,8 @@
#
# irb/workspace-binding.rb -
# $Release Version: 0.9.5$
-# $Revision: 1.5.2.2 $
-# $Date: 2005/04/19 19:24:57 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
diff --git a/lib/irb/ws-for-case-2.rb b/lib/irb/ws-for-case-2.rb
index ca30eb34c0..afd49d23e1 100644
--- a/lib/irb/ws-for-case-2.rb
+++ b/lib/irb/ws-for-case-2.rb
@@ -1,8 +1,8 @@
#
# irb/ws-for-case-2.rb -
# $Release Version: 0.9.5$
-# $Revision: 1.2.2.1 $
-# $Date: 2005/04/19 19:24:57 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
diff --git a/lib/irb/xmp.rb b/lib/irb/xmp.rb
index 0a0883245b..4bcc2ca22f 100644
--- a/lib/irb/xmp.rb
+++ b/lib/irb/xmp.rb
@@ -1,8 +1,8 @@
#
# xmp.rb - irb version of gotoken xmp
# $Release Version: 0.9$
-# $Revision: 1.3 $
-# $Date: 2002/07/09 11:17:16 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(Nippon Rational Inc.)
#
# --
@@ -14,7 +14,7 @@ require "irb"
require "irb/frame"
class XMP
- @RCS_ID='-$Id: xmp.rb,v 1.3 2002/07/09 11:17:16 keiju Exp $-'
+ @RCS_ID='-$Id$-'
def initialize(bind = nil)
IRB.init_config(nil)
diff --git a/lib/jcode.rb b/lib/jcode.rb
index e5367e815b..78422f296f 100644
--- a/lib/jcode.rb
+++ b/lib/jcode.rb
@@ -77,7 +77,7 @@ class String
def succ!
reg = end_regexp
- if self =~ reg
+ if $KCODE != 'NONE' && self =~ reg
succ_table = SUCC[$KCODE[0,1].downcase]
begin
self[-1] += succ_table[self[-1]]
diff --git a/lib/logger.rb b/lib/logger.rb
index 3012ac2cc7..60e72424ad 100644
--- a/lib/logger.rb
+++ b/lib/logger.rb
@@ -10,7 +10,7 @@ require 'monitor'
# 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: logger.rb,v 1.5.2.9 2006/08/04 22:00:21 drbrain Exp $
+# Revision:: $Id$
#
# == Description
#
@@ -170,7 +170,7 @@ require 'monitor'
class Logger
VERSION = "1.2.6"
- /: (\S+),v (\S+)/ =~ %q$Id: logger.rb,v 1.5.2.9 2006/08/04 22:00:21 drbrain Exp $
+ /: (\S+),v (\S+)/ =~ %q$Id$
ProgName = "#{$1}/#{$2}"
class Error < RuntimeError; end
diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index 563ce9e5f4..21fc2fce1f 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -68,7 +68,7 @@ def config_string(key, config = CONFIG)
end
def dir_re(dir)
- Regexp.new('\$(?:\('+dir+'\)|\{'+dir+'\})(?:\$\(target_prefix\)|\{target_prefix\})?')
+ Regexp.new('\$(?:\('+dir+'\)|\{'+dir+'\})(?:\$(?:\(target_prefix\)|\{target_prefix\}))?')
end
INSTALL_DIRS = [
@@ -83,8 +83,8 @@ INSTALL_DIRS = [
def install_dirs(target_prefix = nil)
if $extout
dirs = [
- ['RUBYCOMMONDIR', '$(extout)'],
- ['RUBYLIBDIR', '$(extout)$(target_prefix)'],
+ ['RUBYCOMMONDIR', '$(extout)/common'],
+ ['RUBYLIBDIR', '$(RUBYCOMMONDIR)$(target_prefix)'],
['RUBYARCHDIR', '$(extout)/$(arch)$(target_prefix)'],
['extout', "#$extout"],
['extout_prefix', "#$extout_prefix"],
@@ -265,8 +265,9 @@ ensure
log_src(src)
end
-def link_command(ldflags, opt="", libpath=$LIBPATH)
- conf = Config::CONFIG.merge('hdrdir' => $hdrdir.quote,
+def link_command(ldflags, opt="", libpath=$DEFLIBPATH|$LIBPATH)
+ Config::expand(TRY_LINK.dup,
+ CONFIG.merge('hdrdir' => $hdrdir.quote,
'src' => CONFTEST_C,
'INCFLAGS' => $INCFLAGS,
'CPPFLAGS' => $CPPFLAGS,
@@ -275,25 +276,27 @@ def link_command(ldflags, opt="", libpath=$LIBPATH)
'LDFLAGS' => "#$LDFLAGS #{ldflags}",
'LIBPATH' => libpathflag(libpath),
'LOCAL_LIBS' => "#$LOCAL_LIBS #$libs",
- 'LIBS' => "#$LIBRUBYARG_STATIC #{opt} #$LIBS")
- Config::expand(TRY_LINK.dup, conf)
+ 'LIBS' => "#$LIBRUBYARG_STATIC #{opt} #$LIBS"))
end
def cc_command(opt="")
- conf = Config::CONFIG.merge('hdrdir' => $hdrdir.quote, 'srcdir' => $srcdir.quote)
Config::expand("$(CC) #$INCFLAGS #$CPPFLAGS #$CFLAGS #$ARCH_FLAG #{opt} -c #{CONFTEST_C}",
- conf)
+ CONFIG.merge('hdrdir' => $hdrdir.quote, 'srcdir' => $srcdir.quote))
end
def cpp_command(outfile, opt="")
- conf = Config::CONFIG.merge('hdrdir' => $hdrdir.quote, 'srcdir' => $srcdir.quote)
Config::expand("$(CPP) #$INCFLAGS #$CPPFLAGS #$CFLAGS #{opt} #{CONFTEST_C} #{outfile}",
- conf)
+ CONFIG.merge('hdrdir' => $hdrdir.quote, 'srcdir' => $srcdir.quote))
end
-def libpathflag(libpath=$LIBPATH)
+def libpathflag(libpath=$DEFLIBPATH|$LIBPATH)
libpath.map{|x|
- (x == "$(topdir)" ? LIBPATHFLAG : LIBPATHFLAG+RPATHFLAG) % x.quote
+ case x
+ when "$(topdir)", /\A\./
+ LIBPATHFLAG
+ else
+ LIBPATHFLAG+RPATHFLAG
+ end % x.quote
}.join
end
@@ -413,16 +416,16 @@ end
def try_func(func, libs, headers = nil, &b)
headers = cpp_include(headers)
try_link(<<"SRC", libs, &b) or try_link(<<"SRC", libs, &b)
+#{COMMON_HEADERS}
#{headers}
/*top*/
int main() { return 0; }
-int t() { #{func}(); return 0; }
+int t() { void ((*volatile p)()); p = (void ((*)()))#{func}; return 0; }
SRC
-#{COMMON_HEADERS}
#{headers}
/*top*/
int main() { return 0; }
-int t() { void ((*volatile p)()); p = (void ((*)()))#{func}; return 0; }
+int t() { #{func}(); return 0; }
SRC
end
@@ -433,7 +436,7 @@ def try_var(var, headers = nil, &b)
#{headers}
/*top*/
int main() { return 0; }
-int t() { const volatile void *volatile p; p = &(&#{var})[0]; return 0; }
+int t() { const volatile void *volatile p; p = (void *)&#{var}; return 0; }
SRC
end
@@ -538,7 +541,7 @@ end
def checking_for(m, fmt = nil)
f = caller[0][/in `(.*)'$/, 1] and f << ": " #` for vim
- m = "checking #{'for ' if /\Acheck/ !~ f}#{m}... "
+ m = "checking #{/\Acheck/ =~ f ? '' : 'for '}#{m}... "
message "%s", m
a = r = nil
Logging::postpone do
@@ -551,15 +554,27 @@ def checking_for(m, fmt = nil)
r
end
+def checking_message(target, place = nil, opt = nil)
+ [["in", place], ["with", opt]].inject("#{target}") do |msg, (pre, noun)|
+ if noun
+ [[:to_str], [:join, ","], [:to_s]].each do |meth, *args|
+ if noun.respond_to?(meth)
+ break noun = noun.send(meth, *args)
+ end
+ end
+ msg << " #{pre} #{noun}" unless noun.empty?
+ end
+ msg
+ end
+end
+
# Returns whether or not +macro+ is defined either in the common header
# files or within any +headers+ you provide.
#
# Any options you pass to +opt+ are passed along to the compiler.
#
def have_macro(macro, headers = nil, opt = "", &b)
- m = "#{macro}"
- m << " in #{headers.inspect}" if headers
- checking_for m do
+ checking_for checking_message(macro, headers, opt) do
macro_defined?(macro, cpp_include(headers), opt, &b)
end
end
@@ -578,7 +593,7 @@ end
def have_library(lib, func = nil, headers = nil, &b)
func = "main" if !func or func.empty?
lib = with_config(lib+'lib', lib)
- checking_for "#{func}() in #{LIBARG%lib}" do
+ checking_for checking_message("#{func}()", LIBARG%lib) do
if COMMON_LIBS.include?(lib)
true
else
@@ -631,7 +646,7 @@ end
# preprocessor macro would be passed to the compiler.
#
def have_func(func, headers = nil, &b)
- checking_for "#{func}()" do
+ checking_for checking_message("#{func}()", headers) do
if try_func(func, $libs, headers, &b)
$defs.push(format("-DHAVE_%s", func.upcase))
true
@@ -650,7 +665,7 @@ end
# preprocessor macro would be passed to the compiler.
#
def have_var(var, headers = nil, &b)
- checking_for "#{var}" do
+ checking_for checking_message(var, headers) do
if try_var(var, headers, &b)
$defs.push(format("-DHAVE_%s", var.upcase))
true
@@ -716,7 +731,7 @@ end
# HAVE_ST_BAR preprocessor macro would be passed to the compiler.
#
def have_struct_member(type, member, headers = nil, &b)
- checking_for "#{type}.#{member}" do
+ checking_for checking_message("#{type}.#{member}", headers) do
if try_compile(<<"SRC", &b)
#{COMMON_HEADERS}
#{cpp_include(headers)}
@@ -746,18 +761,14 @@ end
# preprocessor macro would be passed to the compiler.
#
def have_type(type, headers = nil, opt = "", &b)
- checking_for type do
+ checking_for checking_message(type, headers, opt) do
headers = cpp_include(headers)
- if try_compile(<<"SRC", opt, &b) or (/\A\w+\z/n =~ type && try_compile(<<"SRC", opt, &b))
+ if try_compile(<<"SRC", opt, &b)
#{COMMON_HEADERS}
#{headers}
/*top*/
-static #{type} t;
-SRC
-#{COMMON_HEADERS}
-#{headers}
-/*top*/
-static #{type} *t;
+typedef #{type} conftest_type;
+static conftest_type conftestval[sizeof(conftest_type)?1:-1];
SRC
$defs.push(format("-DHAVE_TYPE_%s", type.strip.upcase.tr_s("^A-Z0-9_", "_")))
true
@@ -783,7 +794,7 @@ def check_sizeof(type, headers = nil, &b)
def fmt.%(x)
x ? super : "failed"
end
- checking_for("size of #{type}", fmt) do
+ checking_for checking_message("size of #{type}", headers), fmt do
if size = try_constant(expr, headers, &b)
$defs.push(format("-DSIZEOF_%s=%d", type.upcase.tr_s("^A-Z0-9_", "_"), size))
size
@@ -820,12 +831,11 @@ def what_type?(type, member = nil, headers = nil, &b)
m << "." << member
name = "(((#{type} *)0)->#{member})"
end
- m << " in #{headers.inspect}" if headers
fmt = "seems %s"
def fmt.%(x)
x ? super : "unknown"
end
- checking_for m, fmt do
+ checking_for checking_message(m, headers), fmt do
if scalar_ptr_type?(type, member, headers, &b)
if try_static_assert("sizeof(*#{name}) == 1", headers)
"string"
@@ -850,7 +860,7 @@ def find_executable0(bin, path = nil)
ext = config_string('EXEEXT')
if File.expand_path(bin) == bin
return bin if File.executable?(bin)
- return file if ext and File.executable?(file = bin + ext)
+ ext and File.executable?(file = bin + ext) and return file
return nil
end
if path ||= ENV['PATH']
@@ -867,7 +877,7 @@ def find_executable0(bin, path = nil)
end
def find_executable(bin, path = nil)
- checking_for bin do
+ checking_for checking_message(bin, path) do
find_executable0(bin, path)
end
end
@@ -1042,6 +1052,9 @@ topdir = #{($extmk ? CONFIG["topdir"] : $topdir).quote}
hdrdir = #{$extmk ? CONFIG["hdrdir"].quote : '$(topdir)'}
VPATH = #{vpath.join(CONFIG['PATH_SEPARATOR'])}
}
+ if $extmk
+ mk << "RUBYLIB = -\nRUBYOPT = -rpurelib.rb\n"
+ end
if destdir = CONFIG["prefix"][$dest_prefix_pattern, 1]
mk << "\nDESTDIR = #{destdir}\n"
end
@@ -1069,7 +1082,7 @@ LIBRUBYARG_SHARED = #$LIBRUBYARG_SHARED
LIBRUBYARG_STATIC = #$LIBRUBYARG_STATIC
RUBY_EXTCONF_H = #{$extconf_h}
-CFLAGS = #{CONFIG['CCDLFLAGS'] unless $static} #$CFLAGS #$ARCH_FLAG
+CFLAGS = #{$static ? '' : CONFIG['CCDLFLAGS']} #$CFLAGS #$ARCH_FLAG
INCFLAGS = -I. #$INCFLAGS
CPPFLAGS = #{extconf_h}#{$CPPFLAGS}
CXXFLAGS = $(CFLAGS) #{CONFIG['CXXFLAGS']}
@@ -1094,7 +1107,7 @@ COPY = #{config_string('CP') || '@$(RUBY) -run -e cp -- -v'}
#### End of system configuration section. ####
-preload = #{$preload.join(" ") if $preload}
+preload = #{$preload ? $preload.join(' ') : ''}
}
if $nmake == ?b
mk.each do |x|
@@ -1137,7 +1150,7 @@ end
#
def create_makefile(target, srcprefix = nil)
$target = target
- libpath = $LIBPATH
+ libpath = $DEFLIBPATH|$LIBPATH
message "creating Makefile\n"
rm_f "conftest*"
if CONFIG["DLEXT"] == $OBJEXT
@@ -1167,6 +1180,7 @@ def create_makefile(target, srcprefix = nil)
elsif !(srcs = $srcs)
srcs = $objs.collect {|obj| obj.sub(/\.o\z/, '.c')}
end
+ $srcs = srcs
for i in $objs
i.sub!(/\.o\z/, ".#{$OBJEXT}")
end
@@ -1189,6 +1203,7 @@ def create_makefile(target, srcprefix = nil)
deffile = "$(TARGET)-$(arch).def"
end
end
+ origdef ||= ''
libpath = libpathflag(libpath)
@@ -1196,8 +1211,8 @@ def create_makefile(target, srcprefix = nil)
staticlib = target ? "$(TARGET).#$LIBEXT" : ""
mfile = open("Makefile", "wb")
mfile.print configuration(srcprefix)
- mfile.print %{
-libpath = #{$LIBPATH.join(" ")}
+ mfile.print "
+libpath = #{($DEFLIBPATH|$LIBPATH).join(" ")}
LIBPATH = #{libpath}
DEFFILE = #{deffile}
@@ -1215,18 +1230,18 @@ TARGET = #{target}
DLLIB = #{dllib}
EXTSTATIC = #{$static || ""}
STATIC_LIB = #{staticlib unless $static.nil?}
-
-}
+#{!$extout && defined?($installed_list) ? "INSTALLED_LIST = #{$installed_list}\n" : ""}
+"
install_dirs.each {|d| mfile.print("%-14s= %s\n" % d) if /^[[:upper:]]/ =~ d[0]}
n = ($extout ? '$(RUBYARCHDIR)/' : '') + '$(TARGET).'
- mfile.print %{
+ mfile.print "
TARGET_SO = #{($extout ? '$(RUBYARCHDIR)/' : '')}$(DLLIB)
CLEANLIBS = #{n}#{CONFIG['DLEXT']} #{n}il? #{n}tds #{n}map
CLEANOBJS = *.#{$OBJEXT} *.#{$LIBEXT} *.s[ol] *.pdb *.exp *.bak
all: #{$extout ? "install" : target ? "$(DLLIB)" : "Makefile"}
static: $(STATIC_LIB)#{$extout ? " install-rb" : ""}
-}
+"
mfile.print CLEANINGS
dirs = []
mfile.print "install: install-so install-rb\n\n"
@@ -1248,6 +1263,9 @@ static: $(STATIC_LIB)#{$extout ? " install-rb" : ""}
dir.gsub!(/(\$\{\w+)(\})/) {$1+sep+$2}
end
mfile.print "\t$(INSTALL_PROG) #{f} #{dir}\n"
+ if defined?($installed_list)
+ mfile.print "\t@echo #{dir}/#{File.basename(f)}>>$(INSTALLED_LIST)\n"
+ end
end
end
mfile.print("install-rb: pre-install-rb install-rb-default\n")
@@ -1275,6 +1293,9 @@ static: $(STATIC_LIB)#{$extout ? " install-rb" : ""}
sep = ""
end
mfile.print("#{f} $(@D#{sep})\n")
+ if defined?($installed_list) and !$extout
+ mfile.print("\t@echo #{dest}>>$(INSTALLED_LIST)\n")
+ end
end
end
end
@@ -1377,7 +1398,6 @@ site-install-rb: install-rb
unless suffixes.empty?
mfile.print ".SUFFIXES: .", suffixes.uniq.join(" ."), "\n\n"
end
- mfile.print "$(OBJS): $(RUBY_EXTCONF_H)\n\n" if $extconf_h
mfile.print depout
else
headers = %w[ruby.h defines.h]
@@ -1403,7 +1423,7 @@ def init_mkmf(config = CONFIG)
$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
+ $LDFLAGS = with_config("ldflags", arg_config("LDFLAGS", config["LDFLAGS"])).dup
$INCFLAGS = "-I$(topdir) -I$(hdrdir) -I$(srcdir)"
$DLDFLAGS = with_config("dldflags", arg_config("DLDFLAGS", config["DLDFLAGS"])).dup
$LIBEXT = config['LIBEXT'].dup
@@ -1412,7 +1432,9 @@ def init_mkmf(config = CONFIG)
$LIBRUBYARG = ""
$LIBRUBYARG_STATIC = config['LIBRUBYARG_STATIC']
$LIBRUBYARG_SHARED = config['LIBRUBYARG_SHARED']
- $LIBPATH = $extmk ? ["$(topdir)"] : CROSS_COMPILING ? [] : ["$(libdir)"]
+ $DEFLIBPATH = $extmk ? ["$(topdir)"] : CROSS_COMPILING ? [] : ["$(libdir)"]
+ $DEFLIBPATH.unshift(".")
+ $LIBPATH = []
$INSTALLFILES = nil
$objs = nil
@@ -1425,7 +1447,6 @@ def init_mkmf(config = CONFIG)
$LOCAL_LIBS = ""
$cleanfiles = config_string('CLEANFILES') {|s| Shellwords.shellwords(s)} || []
- $cleanfiles << "mkmf.log"
$distcleanfiles = config_string('DISTCLEANFILES') {|s| Shellwords.shellwords(s)} || []
$extout ||= nil
@@ -1445,7 +1466,7 @@ MESSAGE
def mkmf_failed(path)
unless $makefile_created or File.exist?("Makefile")
- opts = $arg_config.collect {|t, n| "\t#{t}#{"=#{n}" if n}\n"}
+ opts = $arg_config.collect {|t, n| "\t#{t}#{n ? "=#{n}" : ""}\n"}
abort "*** #{path} failed ***\n" + FailedMessage + opts.join
end
end
@@ -1483,15 +1504,14 @@ 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"
+ Shellwords.shellwords(s).each do |w|
+ hdr << "#define " + w.split(/=/, 2).join(" ")
end
end
config_string('COMMON_HEADERS') do |s|
Shellwords.shellwords(s).each {|s| hdr << "#include <#{s}>"}
end
-COMMON_HEADERS = (hdr.join("\n") unless hdr.empty?)
+COMMON_HEADERS = hdr.join("\n")
COMMON_LIBS = config_string('COMMON_LIBS', &split) || []
COMPILE_RULES = config_string('COMPILE_RULES', &split) || %w[.%s.%s:]
@@ -1505,8 +1525,8 @@ LINK_SO = config_string('LINK_SO') ||
if CONFIG["DLEXT"] == $OBJEXT
"ld $(DLDFLAGS) -r -o $@ $(OBJS)\n"
else
- "$(LDSHARED) $(DLDFLAGS) $(LIBPATH) #{OUTFLAG}$@ " \
- "$(OBJS) $(LOCAL_LIBS) $(LIBS)"
+ "$(LDSHARED) #{OUTFLAG}$@ $(OBJS) " \
+ "$(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)"
end
LIBPATHFLAG = config_string('LIBPATHFLAG') || ' -L"%s"'
RPATHFLAG = config_string('RPATHFLAG') || ''
diff --git a/lib/net/http.rb b/lib/net/http.rb
index d518f32cbb..46d95b27b4 100644
--- a/lib/net/http.rb
+++ b/lib/net/http.rb
@@ -22,7 +22,7 @@
# http://www.ruby-lang.org/ja/man/?cmd=view;name=net%2Fhttp.rb
#
#--
-# $Id: http.rb,v 1.100.2.14 2006/07/26 13:27:18 aamine Exp $
+# $Id$
#++
require 'net/protocol'
@@ -278,7 +278,7 @@ module Net #:nodoc:
class HTTP < Protocol
# :stopdoc:
- Revision = %q$Revision: 1.100.2.14 $.split[1]
+ Revision = %q$Revision$.split[1]
HTTPVersion = '1.1'
@newimpl = true
# :startdoc:
@@ -584,9 +584,6 @@ module Net #:nodoc:
HTTPResponse.read_new(@socket).value
end
s.connect
- if @ssl_context.verify_mode != OpenSSL::SSL::VERIFY_NONE
- s.post_connection_check(@address)
- end
end
on_connect
end
diff --git a/lib/net/https.rb b/lib/net/https.rb
index 1111e94590..e296dbbed4 100644
--- a/lib/net/https.rb
+++ b/lib/net/https.rb
@@ -1,6 +1,6 @@
=begin
-= $RCSfile: https.rb,v $ -- SSL/TLS enhancement for Net::HTTP.
+= $RCSfile$ -- SSL/TLS enhancement for Net::HTTP.
== Info
'OpenSSL for Ruby 2' project
@@ -16,7 +16,7 @@
You can get it from RAA or Ruby's CVS repository.
== Version
- $Id: https.rb,v 1.3.4.2 2006/02/05 09:56:34 aamine Exp $
+ $Id$
2001-11-06: Contiributed to Ruby/OpenSSL project.
2004-03-06: Some code is merged in to net/http.
diff --git a/lib/net/imap.rb b/lib/net/imap.rb
index 57e78ec135..59df778695 100644
--- a/lib/net/imap.rb
+++ b/lib/net/imap.rb
@@ -900,15 +900,14 @@ module Net
end
@sock = SSLSocket.new(@sock, context)
@sock.connect # start ssl session.
- @sock.post_connection_check(@host) if verify
else
@usessl = false
end
@responses = Hash.new([].freeze)
@tagged_responses = {}
@response_handlers = []
- @tagged_response_arrival = new_cond
- @continuation_request_arrival = new_cond
+ @response_arrival = new_cond
+ @continuation_request = nil
@logout_command_tag = nil
@debug_output_bol = true
@@ -939,7 +938,7 @@ module Net
case resp
when TaggedResponse
@tagged_responses[resp.tag] = resp
- @tagged_response_arrival.broadcast
+ @response_arrival.broadcast
if resp.tag == @logout_command_tag
return
end
@@ -954,7 +953,8 @@ module Net
raise ByeResponseError, resp.raw_data
end
when ContinuationRequest
- @continuation_request_arrival.signal
+ @continuation_request = resp
+ @response_arrival.broadcast
end
@response_handlers.each do |handler|
handler.call(resp)
@@ -966,10 +966,14 @@ module Net
end
end
- def get_tagged_response(tag, cmd)
+ def get_tagged_response(tag)
until @tagged_responses.key?(tag)
- @tagged_response_arrival.wait
+ @response_arrival.wait
end
+ return pick_up_tagged_response(tag)
+ end
+
+ def pick_up_tagged_response(tag)
resp = @tagged_responses.delete(tag)
case resp.name
when /\A(?:NO)\z/ni
@@ -1010,7 +1014,7 @@ module Net
def send_command(cmd, *args, &block)
synchronize do
- tag = generate_tag
+ tag = Thread.current[:net_imap_tag] = generate_tag
put_string(tag + " " + cmd)
args.each do |i|
put_string(" ")
@@ -1024,7 +1028,7 @@ module Net
add_response_handler(block)
end
begin
- return get_tagged_response(tag, cmd)
+ return get_tagged_response(tag)
ensure
if block
remove_response_handler(block)
@@ -1093,7 +1097,15 @@ module Net
def send_literal(str)
put_string("{" + str.length.to_s + "}" + CRLF)
- @continuation_request_arrival.wait
+ while @continuation_request.nil? &&
+ !@tagged_responses.key?(Thread.current[:net_imap_tag])
+ @response_arrival.wait
+ end
+ if @continuation_request.nil?
+ pick_up_tagged_response(Thread.current[:net_imap_tag])
+ raise ResponseError.new("expected continuation request")
+ end
+ @continuation_request = nil
put_string(str)
end
@@ -1888,7 +1900,7 @@ module Net
T_TEXT = :TEXT
BEG_REGEXP = /\G(?:\
-(?# 1: SPACE )( )|\
+(?# 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%*"\\\[\]+]+)|\
@@ -2740,7 +2752,7 @@ module Net
token = match(T_ATOM)
name = token.value.upcase
case name
- when /\A(?:ALERT|PARSE|READ-ONLY|READ-WRITE|TRYCREATE)\z/n
+ when /\A(?:ALERT|PARSE|READ-ONLY|READ-WRITE|TRYCREATE|NOMODSEQ)\z/n
result = ResponseCode.new(name, nil)
when /\A(?:PERMANENTFLAGS)\z/n
match(T_SPACE)
@@ -3047,7 +3059,7 @@ module Net
elsif $7
return Token.new(T_RPAR, $+)
else
- parse_error("[Net::IMAP BUG] DATA_REGEXP is invalid")
+ parse_error("[Net::IMAP BUG] BEG_REGEXP is invalid")
end
else
@str.index(/\S*/n, @pos)
@@ -3101,7 +3113,7 @@ module Net
$stderr.printf("@str: %s\n", @str.dump)
$stderr.printf("@pos: %d\n", @pos)
$stderr.printf("@lex_state: %s\n", @lex_state)
- if @token
+ if @token.symbol
$stderr.printf("@token.symbol: %s\n", @token.symbol)
$stderr.printf("@token.value: %s\n", @token.value.inspect)
end
diff --git a/lib/net/pop.rb b/lib/net/pop.rb
index 39d446f9e6..2ecbcbdf28 100644
--- a/lib/net/pop.rb
+++ b/lib/net/pop.rb
@@ -15,7 +15,7 @@
# NOTE: You can find Japanese version of this document in
# the doc/net directory of the standard ruby interpreter package.
#
-# $Id: pop.rb,v 1.62.2.4 2005/09/13 07:27:18 aamine Exp $
+# $Id$
#
# See Net::POP3 for documentation.
#
@@ -190,7 +190,7 @@ module Net
#
class POP3 < Protocol
- Revision = %q$Revision: 1.62.2.4 $.split[1]
+ Revision = %q$Revision$.split[1]
#
# Class Parameters
@@ -462,8 +462,6 @@ module Net
def do_finish
@mails = nil
- @n_mails = nil
- @n_bytes = nil
@command.quit if @command
ensure
@started = false
diff --git a/lib/net/protocol.rb b/lib/net/protocol.rb
index 0fee78c63a..d722fdcbd4 100644
--- a/lib/net/protocol.rb
+++ b/lib/net/protocol.rb
@@ -11,7 +11,7 @@
# modify this program under the same terms as Ruby itself,
# Ruby Distribute License or GNU General Public License.
#
-# $Id: protocol.rb,v 1.73.2.3 2005/09/13 07:27:18 aamine Exp $
+# $Id$
#++
#
# WARNING: This file is going to remove.
diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb
index 89929b1c6e..dda9dab072 100644
--- a/lib/net/smtp.rb
+++ b/lib/net/smtp.rb
@@ -15,7 +15,7 @@
# NOTE: You can find Japanese version of this document in
# the doc/net directory of the standard ruby interpreter package.
#
-# $Id: smtp.rb,v 1.69.2.3 2005/09/13 07:27:18 aamine Exp $
+# $Id$
#
# See Net::SMTP for documentation.
#
@@ -163,7 +163,7 @@ module Net
#
class SMTP
- Revision = %q$Revision: 1.69.2.3 $.split[1]
+ Revision = %q$Revision$.split[1]
# The default SMTP port, port 25.
def SMTP.default_port
diff --git a/lib/net/telnet.rb b/lib/net/telnet.rb
index c54401851c..c5f8b0429a 100644
--- a/lib/net/telnet.rb
+++ b/lib/net/telnet.rb
@@ -164,7 +164,7 @@ module Net
CR = "\015"
LF = "\012"
EOL = CR + LF
- REVISION = '$Id: telnet.rb,v 1.23.2.4 2005/09/14 15:21:31 matz Exp $'
+ REVISION = '$Id$'
# :startdoc:
#
@@ -705,7 +705,7 @@ module Net
# 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 = /[Pp]ass(?:word|phrase)[: ]*\z/n
+ password_prompt = /Password[: ]*\z/n
if options.kind_of?(Hash)
username = options["Name"]
password = options["Password"]
diff --git a/lib/open-uri.rb b/lib/open-uri.rb
index 0dae95b6e6..d69f7dbe41 100644
--- a/lib/open-uri.rb
+++ b/lib/open-uri.rb
@@ -240,6 +240,16 @@ module OpenURI
resp = nil
http.start {
+ if target.class == URI::HTTPS
+ # xxx: information hiding violation
+ sock = http.instance_variable_get(:@socket)
+ if sock.respond_to?(:io)
+ sock = sock.io # 1.9
+ else
+ sock = sock.instance_variable_get(:@socket) # 1.8
+ end
+ sock.post_connection_check(target_host)
+ end
req = Net::HTTP::Get.new(request_uri, header)
if options.include? :http_basic_authentication
user, pass = options[:http_basic_authentication]
diff --git a/lib/open3.rb b/lib/open3.rb
index f722252b1c..c4dacc9473 100644
--- a/lib/open3.rb
+++ b/lib/open3.rb
@@ -1,29 +1,48 @@
-# 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:
+# = open3.rb: Popen, but with stderr, too
#
-# require "open3"
-#
-# stdin, stdout, stderr = Open3.popen3('nroff -man')
+# Author:: Yukihiro Matsumoto
+# Documentation:: Konrad Meyer
+#
+# Open3 gives you access to stdin, stdout, and stderr when running other
+# programs.
+#
+
#
-# or:
+# Open3 grants you access to stdin, stdout, and stderr when running another
+# program. Example:
#
+# require "open3"
# include Open3
#
# stdin, stdout, stderr = popen3('nroff -man')
#
-# popen3 can also take a block which will receive stdin, stdout and stderr as
-# parameters. This ensures stdin, stdout and stderr are closed once the block
-# exits.
+# Open3.popen3 can also take a block which will receive stdin, stdout and
+# stderr as parameters. This ensures stdin, stdout and stderr are closed
+# once the block exits. Example:
#
-# Such as:
+# require "open3"
#
# Open3.popen3('nroff -man') { |stdin, stdout, stderr| ... }
+#
module Open3
- #[stdin, stdout, stderr] = popen3(command);
+ #
+ # Open stdin, stdout, and stderr streams and start external executable.
+ # Non-block form:
+ #
+ # require 'open3'
+ #
+ # [stdin, stdout, stderr] = Open3.popen3(cmd)
+ #
+ # Block form:
+ #
+ # require 'open3'
+ #
+ # Open3.popen3(cmd) { |stdin, stdout, stderr| ... }
+ #
+ # The parameter +cmd+ is passed directly to Kernel#exec.
+ #
def popen3(*cmd)
pw = IO::pipe # pipe[0] for read, pipe[1] for write
pr = IO::pipe
diff --git a/lib/optparse.rb b/lib/optparse.rb
index d5a759d084..2c91cd004f 100644
--- a/lib/optparse.rb
+++ b/lib/optparse.rb
@@ -203,7 +203,7 @@
#
class OptionParser
# :stopdoc:
- RCSID = %w$Id: optparse.rb,v 1.40.2.12 2006/08/04 22:00:21 drbrain Exp $[1..-1].each {|s| s.freeze}.freeze
+ 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]
@@ -346,16 +346,12 @@ class OptionParser
# exception.
#
def conv_arg(arg, val = nil)
- if block
- if conv
- val = conv.call(*val)
- else
- val = *val
- end
- return arg, block, val
+ if conv
+ val = conv.call(*val)
else
- return arg, nil
+ val = proc {|val| val}.call(*val)
end
+ return arg, block, val
end
private :conv_arg
@@ -383,7 +379,7 @@ class OptionParser
while s = lopts.shift
l = left[-1].length + s.length
l += arg.length if left.size == 1 && arg
- l < max or sopts.empty? or left << ''
+ l < max or left << ''
left[-1] << if left[-1].empty? then ' ' * 4 else ', ' end << s
end
@@ -394,7 +390,7 @@ class OptionParser
yield(indent + l)
end
- while (l = left.shift; r = right.shift; l or r)
+ while begin l = left.shift; r = right.shift; l or r end
l = l.to_s.ljust(width) + ' ' + r if r and !r.empty?
yield(indent + l)
end
@@ -402,6 +398,25 @@ class OptionParser
self
end
+ def add_banner(to) # :nodoc:
+ unless @short or @long
+ s = desc.join
+ to << " [" + s + "]..." unless s.empty?
+ end
+ to
+ end
+
+ def match_nonswitch?(str) # :nodoc:
+ @pattern =~ str unless @short or @long
+ end
+
+ #
+ # Main name of the switch.
+ #
+ def switch_name
+ (long.first || short.first).sub(/\A-+(?:\[no-\])?/, '')
+ end
+
#
# Switch that takes no arguments.
#
@@ -410,7 +425,7 @@ class OptionParser
#
# Raises an exception if any arguments given.
#
- def parse(arg, argv, &error)
+ def parse(arg, argv)
yield(NeedlessArgument, arg) if arg
conv_arg(arg)
end
@@ -588,8 +603,7 @@ class OptionParser
def search(id, key)
if list = __send__(id)
val = list.fetch(key) {return nil}
- return val unless block_given?
- yield(val)
+ block_given? ? yield(val) : val
end
end
@@ -604,6 +618,13 @@ class OptionParser
end
#
+ # Iterates over each option, passing the option to the +block+.
+ #
+ def each_option(&block)
+ list.each(&block)
+ end
+
+ #
# Creates the summary table, passing each line to the +block+ (without
# newline). The arguments +args+ are passed along to the summarize
# method which is called on every option.
@@ -612,13 +633,22 @@ class OptionParser
list.each do |opt|
if opt.respond_to?(:summarize) # perhaps OptionParser::Switch
opt.summarize(*args, &block)
- elsif opt.empty?
+ elsif !opt or opt.empty?
yield("")
else
opt.each(&block)
end
end
end
+
+ def add_banner(to) # :nodoc:
+ list.each do |opt|
+ if opt.respond_to?(:add_banner)
+ opt.add_banner(to)
+ end
+ end
+ to
+ end
end
#
@@ -757,7 +787,7 @@ class OptionParser
def add_officious # :nodoc:
list = base()
- Officious.each_pair do |opt, block|
+ Officious.each do |opt, block|
list.long[opt] ||= block.call(self)
end
end
@@ -828,7 +858,11 @@ class OptionParser
# Heading banner preceding summary.
#
def banner
- @banner ||= "Usage: #{program_name} [options]"
+ unless @banner
+ @banner = "Usage: #{program_name} [options]"
+ visit(:add_banner, @banner)
+ end
+ @banner
end
#
@@ -1020,7 +1054,7 @@ class OptionParser
# Handler for the parsed argument value. Either give a block or pass a
# Proc or Method as an argument.
#
- def make_switch(*opts, &block)
+ def make_switch(opts, block = nil)
short, long, nolong, style, pattern, conv, not_pattern, not_conv, not_style = [], [], []
ldesc, sdesc, desc, arg = [], [], []
default_style = Switch::NoArgument
@@ -1123,20 +1157,24 @@ class OptionParser
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,
+ if !(short.empty? and long.empty?)
+ s = (style || default_style).new(pattern || default_pattern,
conv, sdesc, ldesc, arg, desc, block)
- end
+ elsif !block
+ raise ArgumentError, "no switch given" if style or pattern
+ s = desc
+ else
+ short << pattern
+ s = (style || default_style).new(pattern,
+ conv, nil, nil, 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
def define(*opts, &block)
- top.append(*(sw = make_switch(*opts, &block)))
+ top.append(*(sw = make_switch(opts, block)))
sw[0]
end
@@ -1151,7 +1189,7 @@ class OptionParser
alias def_option define
def define_head(*opts, &block)
- top.prepend(*(sw = make_switch(*opts, &block)))
+ top.prepend(*(sw = make_switch(opts, block)))
sw[0]
end
@@ -1165,7 +1203,7 @@ class OptionParser
alias def_head_option define_head
def define_tail(*opts, &block)
- base.append(*(sw = make_switch(*opts, &block)))
+ base.append(*(sw = make_switch(opts, block)))
sw[0]
end
@@ -1200,6 +1238,10 @@ class OptionParser
# Same as #order, but removes switches destructively.
#
def order!(argv = default_argv, &nonopt)
+ parse_in_order(argv, &nonopt)
+ end
+
+ def parse_in_order(argv = default_argv, setter = nil, &nonopt) # :nodoc:
opt, arg, sw, val, rest = nil
nonopt ||= proc {|arg| throw :terminate, arg}
argv.unshift(arg) if arg = catch(:terminate) {
@@ -1214,8 +1256,9 @@ class OptionParser
raise $!.set_option(arg, true)
end
begin
- opt, sw, val = sw.parse(rest, argv) {|*exc| raise(*exc)}
- sw.call(val) if sw
+ opt, cb, val = sw.parse(rest, argv) {|*exc| raise(*exc)}
+ val = cb.call(val) if cb
+ setter.call(sw.switch_name, val) if setter
rescue ParseError
raise $!.set_option(arg, rest)
end
@@ -1224,7 +1267,8 @@ class OptionParser
when /\A-(.)((=).*|.+)?/nm
opt, has_arg, eq, val, rest = $1, $3, $3, $2, $2
begin
- unless sw = search(:short, opt)
+ sw, = search(:short, opt)
+ unless sw
begin
sw, = complete(:short, opt)
# short option matched.
@@ -1241,25 +1285,34 @@ class OptionParser
raise $!.set_option(arg, true)
end
begin
- opt, sw, val = sw.parse(val, argv) {|*exc| raise(*exc) if eq}
+ opt, cb, 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
+ val = cb.call(val) if cb
+ setter.call(sw.switch_name, val) if setter
rescue ParseError
raise $!.set_option(arg, arg.length > 2)
end
# non-option argument
else
- nonopt.call(arg)
+ catch(:prune) do
+ visit(:each_option) do |sw|
+ sw.block.call(arg) if Switch === sw and sw.match_nonswitch?(arg)
+ end
+ nonopt.call(arg)
+ end
end
end
nil
}
+ visit(:search, :short, nil) {|sw| sw.block.call(*argv) if !sw.pattern}
+
argv
end
+ private :parse_in_order
#
# Parses command line arguments +argv+ in permutation mode and returns
@@ -1304,16 +1357,25 @@ class OptionParser
#
# Wrapper method for getopts.rb.
#
- def getopts(argv, single_options, *long_options)
+ # params = ARGV.getopts("ab:", "foo", "bar:")
+ # # params[:a] = true # -a
+ # # params[:b] = "1" # -b1
+ # # params[:foo] = "1" # --foo
+ # # params[:bar] = "x" # --bar x
+ #
+ def getopts(*args)
+ argv = Array === args.first ? args.shift : default_argv
+ single_options, *long_options = *args
+
result = {}
single_options.scan(/(.)(:)?/) do |opt, val|
if val
result[opt] = nil
- define("-#{opt} VAL") {|val| result[opt] = val}
+ define("-#{opt} VAL")
else
result[opt] = false
- define("-#{opt}") {result[opt] = true}
+ define("-#{opt}")
end
end if single_options
@@ -1321,14 +1383,14 @@ class OptionParser
opt, val = arg.split(':', 2)
if val
result[opt] = val.empty? ? nil : val
- define("--#{opt} VAL") {|val| result[opt] = val}
+ define("--#{opt} VAL")
else
result[opt] = false
- define("--#{opt}") {result[opt] = true}
+ define("--#{opt}")
end
end
- order!(argv)
+ parse_in_order(argv, result.method(:[]=))
result
end
@@ -1353,12 +1415,12 @@ class OptionParser
private :visit
#
- # Searches key +k+ in @stack for +id+ hash and returns or yields the result.
+ # Searches +key+ in @stack for +id+ hash and returns or yields the result.
#
- def search(id, k)
- visit(:search, id, k) do |k|
- return k unless block_given?
- return yield(k)
+ def search(id, key)
+ block_given = block_given?
+ visit(:search, id, key) do |k|
+ return block_given ? yield(k) : k
end
end
private :search
@@ -1570,7 +1632,6 @@ class OptionParser
end
alias to_s message
- alias to_str message
end
#
@@ -1723,5 +1784,5 @@ if $0 == __FILE__
Version = OptionParser::Version
ARGV.options {|q|
q.parse!.empty? or puts "what's #{ARGV.join(' ')}?"
- } or exit 1
+ } or abort(ARGV.options.to_s)
end
diff --git a/lib/parsearg.rb b/lib/parsearg.rb
index b7e18c3afd..cab2dba789 100644
--- a/lib/parsearg.rb
+++ b/lib/parsearg.rb
@@ -1,8 +1,8 @@
#
# parsearg.rb - parse arguments
# $Release Version: $
-# $Revision: 1.2.2.2 $
-# $Date: 2006/08/04 22:00:21 $
+# $Revision$
+# $Date$
# by Yasuo OHBA(SHL Japan Inc. Technology Dept.)
#
# --
@@ -12,7 +12,7 @@
warn "Warning:#{caller[0].sub(/:in `.*'\z/, '')}: parsearg is deprecated after Ruby 1.8.1; use optparse instead"
-$RCS_ID=%q$Header: /src/ruby/lib/parsearg.rb,v 1.2.2.2 2006/08/04 22:00:21 drbrain Exp $
+$RCS_ID=%q$Header$
require "getopts"
diff --git a/lib/parsedate.rb b/lib/parsedate.rb
index 405ab46907..b52a79ba47 100644
--- a/lib/parsedate.rb
+++ b/lib/parsedate.rb
@@ -1,10 +1,48 @@
-# parsedate.rb: Written by Tadayoshi Funaba 2001, 2002
-# $Id: parsedate.rb,v 2.6 2002-05-14 07:43:18+09 tadf Exp $
+#
+# = parsedate.rb: Parses dates
+#
+# Author:: Tadayoshi Funaba
+# Documentation:: Konrad Meyer
+#
+# ParseDate munches on a date and turns it into an array of values.
+#
+
+#
+# ParseDate converts a date into an array of values.
+# For example:
+#
+# require 'parsedate'
+#
+# ParseDate.parsedate "Tuesday, July 6th, 2007, 18:35:20 UTC"
+# # => [2007, 7, 6, 18, 35, 20, "UTC", 2]
+#
+# The order is of the form [year, month, day of month, hour, minute, second,
+# timezone, day of the week].
require 'date/format'
module ParseDate
-
+ #
+ # Parse a string representation of a date into values.
+ # For example:
+ #
+ # require 'parsedate'
+ #
+ # ParseDate.parsedate "Tuesday, July 5th, 2007, 18:35:20 UTC"
+ # # => [2007, 7, 5, 18, 35, 20, "UTC", 2]
+ #
+ # The order is of the form [year, month, day of month, hour, minute,
+ # second, timezone, day of week].
+ #
+ # ParseDate.parsedate can also take a second argument, +comp+, which
+ # is a boolean telling the method to compensate for dates with years
+ # expressed as two digits. Example:
+ #
+ # require 'parsedate'
+ #
+ # ParseDate.parsedate "Mon Dec 25 00 06:53:24 UTC", true
+ # # => [2000, 12, 25, 6, 53, 24, "UTC", 1]
+ #
def parsedate(str, comp=false)
Date._parse(str, comp).
values_at(:year, :mon, :mday, :hour, :min, :sec, :zone, :wday)
diff --git a/lib/ping.rb b/lib/ping.rb
index 7728ece979..c2966b619c 100644
--- a/lib/ping.rb
+++ b/lib/ping.rb
@@ -1,35 +1,46 @@
#
-# ping.rb -- check a host for upness
+# = ping.rb: Check a host for upness
+#
+# Author:: Yukihiro Matsumoto
+# Documentation:: Konrad Meyer
+#
+# Performs the function of the basic network testing tool, ping.
+# See: Ping.
#
require 'timeout'
require "socket"
-#= SYNOPSIS
-#
-# require 'ping'
-#
-# puts "'jimmy' is alive and kicking" if Ping.pingecho('jimmy', 10)
-#
-#= DESCRIPTION
+#
+# Ping contains routines to test for the reachability of remote hosts.
+# Currently the only routine implemented is pingecho().
#
-# This module contains routines to test for the reachability of remote hosts.
-# Currently the only routine implemented is pingecho().
-#
-# pingecho() uses a TCP echo (_not_ an ICMP echo) to determine if the
+# Ping.pingecho uses a TCP echo (not an ICMP echo) to determine if the
# remote host is reachable. This is usually adequate to tell that a remote
-# host is available to rsh(1), ftp(1), or telnet(1) to.
+# host is available to telnet, ftp, or ssh to.
+#
+# Warning: Ping.pingecho may block for a long time if DNS resolution is
+# slow. Requiring 'resolv-replace' allows non-blocking name resolution.
#
-#= WARNING
+# Usage:
+#
+# require 'ping'
#
-# pingecho() may block for a long period if name resolution is slow. Require
-# 'resolv-replace' to use non-blocking name resolution.
+# puts "'jimmy' is alive and kicking" if Ping.pingecho('jimmy', 10)
#
module Ping
- # return true if we can open a connection to the hostname or IP address
- # +host+ on port +service+ (which defaults to the "echo" port) waiting up to
- # +timeout+ seconds.
+ #
+ # Return true if we can open a connection to the hostname or IP address
+ # +host+ on port +service+ (which defaults to the "echo" port) waiting up
+ # to +timeout+ seconds.
+ #
+ # Example:
+ #
+ # require 'ping'
+ #
+ # Ping.pingecho "google.com", 10, 80
+ #
def pingecho(host, timeout=5, service="echo")
begin
timeout(timeout) do
diff --git a/lib/prettyprint.rb b/lib/prettyprint.rb
index 507a05e65c..315c422e9e 100644
--- a/lib/prettyprint.rb
+++ b/lib/prettyprint.rb
@@ -381,7 +381,7 @@ end
if __FILE__ == $0
require 'test/unit'
- class WadlerExample < Test::Unit::TestCase
+ class WadlerExample < Test::Unit::TestCase # :nodoc:
def setup
@tree = Tree.new("aaaa", Tree.new("bbbbb", Tree.new("ccc"),
Tree.new("dd")),
@@ -561,7 +561,7 @@ End
assert_equal(expected, tree_alt(50))
end
- class Tree
+ class Tree # :nodoc:
def initialize(string, *children)
@string = string
@children = children
@@ -618,7 +618,7 @@ End
end
end
- class StrictPrettyExample < Test::Unit::TestCase
+ class StrictPrettyExample < Test::Unit::TestCase # :nodoc:
def prog(width)
PrettyPrint.format('', width) {|q|
q.group {
@@ -763,7 +763,7 @@ End
end
- class TailGroup < Test::Unit::TestCase
+ class TailGroup < Test::Unit::TestCase # :nodoc:
def test_1
out = PrettyPrint.format('', 10) {|q|
q.group {
@@ -783,7 +783,7 @@ End
end
end
- class NonString < Test::Unit::TestCase
+ class NonString < Test::Unit::TestCase # :nodoc:
def format(width)
PrettyPrint.format([], width, 'newline', lambda {|n| "#{n} spaces"}) {|q|
q.text(3, 3)
@@ -802,7 +802,7 @@ End
end
- class Fill < Test::Unit::TestCase
+ class Fill < Test::Unit::TestCase # :nodoc:
def format(width)
PrettyPrint.format('', width) {|q|
q.group {
diff --git a/lib/pstore.rb b/lib/pstore.rb
index 46123bf0a7..6df64474ab 100644
--- a/lib/pstore.rb
+++ b/lib/pstore.rb
@@ -78,6 +78,11 @@ require "digest/md5"
# end
#
class PStore
+ binmode = defined?(File::BINARY) ? File::BINARY : 0
+ RDWR_ACCESS = File::RDWR | File::CREAT | binmode
+ RD_ACCESS = File::RDONLY | binmode
+ WR_ACCESS = File::WRONLY | File::CREAT | File::TRUNC | binmode
+
# The error type thrown by all PStore methods.
class Error < StandardError
end
@@ -287,17 +292,15 @@ class PStore
content = nil
unless read_only
- file = File.open(@filename, File::RDWR | File::CREAT)
- file.binmode
+ file = File.open(@filename, RDWR_ACCESS)
file.flock(File::LOCK_EX)
commit_new(file) if FileTest.exist?(new_file)
content = file.read()
else
begin
- file = File.open(@filename, File::RDONLY)
- file.binmode
+ file = File.open(@filename, RD_ACCESS)
file.flock(File::LOCK_SH)
- content = (File.read(new_file) rescue file.read())
+ content = (File.open(new_file, RD_ACCESS) {|n| n.read} rescue file.read())
rescue Errno::ENOENT
content = ""
end
@@ -326,10 +329,7 @@ class PStore
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.open(tmp_file, WR_ACCESS) {|t| t.write(content)}
File.rename(tmp_file, new_file)
commit_new(file)
end
@@ -365,8 +365,7 @@ class PStore
f.truncate(0)
f.rewind
new_file = @filename + ".new"
- File.open(new_file) do |nf|
- nf.binmode
+ File.open(new_file, RD_ACCESS) do |nf|
FileUtils.copy_stream(nf, f)
end
File.unlink(new_file)
diff --git a/lib/rdoc/generators/ri_generator.rb b/lib/rdoc/generators/ri_generator.rb
index c4b4a7e17c..c7d0bbd8f0 100644
--- a/lib/rdoc/generators/ri_generator.rb
+++ b/lib/rdoc/generators/ri_generator.rb
@@ -69,7 +69,7 @@ module Generators
def initialize(options) #:not-new:
@options = options
- @ri_writer = RI::RiWriter.new(options.op_dir)
+ @ri_writer = RI::RiWriter.new(".")
@markup = SM::SimpleMarkup.new
@to_flow = SM::ToFlow.new
end
diff --git a/lib/rdoc/options.rb b/lib/rdoc/options.rb
index 31441793c4..4dfe45169c 100644
--- a/lib/rdoc/options.rb
+++ b/lib/rdoc/options.rb
@@ -91,6 +91,9 @@ class Options
# multiple files
attr_reader :promiscuous
+ # scan newer sources than the flag file if true.
+ attr_reader :force_update
+
module OptionList
OPTION_LIST = [
@@ -134,6 +137,10 @@ class Options
"Silently discarded if --diagram is not given\n" +
"Experimental." ],
+ [ "--force-update", "-U", nil,
+ "forces to scan all sources even if newer than\n" +
+ "the flag file." ],
+
[ "--fmt", "-f", "format name",
"set the output formatter (see below)" ],
@@ -363,6 +370,7 @@ class Options
@include_line_numbers = false
@extra_accessor_flags = {}
@promiscuous = false
+ @force_update = false
@css = nil
@webcvs = nil
@@ -462,6 +470,9 @@ class Options
OptionList.error("Unknown extension .#{old} to -E")
end
+ when "--force-update"
+ @force_update = true
+
when "--version"
puts VERSION_STRING
exit
@@ -539,12 +550,12 @@ class Options
ver = nil
IO.popen("dot -V 2>&1") do |io|
ver = io.read
- if ver =~ /dot.+version(?:\s+gviz)?\s+(\d+)\.(\d+)/
+ 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/
+ 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,
diff --git a/lib/rdoc/parsers/parse_c.rb b/lib/rdoc/parsers/parse_c.rb
index fdec9c6b23..1311c5087d 100644
--- a/lib/rdoc/parsers/parse_c.rb
+++ b/lib/rdoc/parsers/parse_c.rb
@@ -1,3 +1,78 @@
+# 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"
+require "rdoc/options"
+require "rdoc/rdoc"
+
+module RDoc
+
+ ##
+ # Ruby's built-in classes.
+
+ 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"
+ }
+
+ ##
# 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
@@ -52,8 +127,8 @@
# 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
+ # This comment documents the named method. Use when RDoc cannot
+ # automatically 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,
@@ -89,85 +164,12 @@
# */
#
-
- # 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
+ attr_accessor :progress
extend ParserFactory
- parse_files_matching(/\.(?:([CcHh])\1?|c([+xp])\2|y)\z/)
+ parse_files_matching(/\.(c|cc|cpp|CC)$/)
@@known_bodies = {}
@@ -217,8 +219,9 @@ module RDoc
comment.sub!(/\/?\*--.*/m, '')
end
- # remove lines that are commented out that might otherwise get
- # picked up when scanning for classes and methods
+ ##
+ # removes 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_}, '//')
@@ -260,9 +263,32 @@ module RDoc
@classes[var_name] = cm
@known_classes[var_name] = cm.full_name
end
-
- ############################################################
+ ##
+ # Look for class or module documentation above Init_+class_name+(void),
+ # in a Document-class +class_name+ (or module) comment or above an
+ # rb_define_class (or module). If a comment is supplied above a matching
+ # Init_ and a rb_define_class the Init_ comment is used.
+ #
+ # /*
+ # * This is a comment for Foo
+ # */
+ # Init_Foo(void) {
+ # VALUE cFoo = rb_define_class("Foo", rb_cObject);
+ # }
+ #
+ # /*
+ # * Document-class: Foo
+ # * This is a comment for Foo
+ # */
+ # Init_foo(void) {
+ # VALUE cFoo = rb_define_class("Foo", rb_cObject);
+ # }
+ #
+ # /*
+ # * This is a comment for Foo
+ # */
+ # VALUE cFoo = rb_define_class("Foo", rb_cObject);
def find_class_comment(class_name, class_meth)
comment = nil
@@ -271,6 +297,18 @@ module RDoc
comment = $1
elsif @body =~ %r{Document-(class|module):\s#{class_name}\s*?\n((?>.*?\*/))}m
comment = $2
+ else
+ if @body =~ /rb_define_(class|module)/m then
+ class_name = class_name.split("::").last
+ comments = []
+ @body.split(/(\/\*.*?\*\/)\s*?\n/m).each_with_index do |chunk, index|
+ comments[index] = chunk
+ if chunk =~ /rb_define_(class|module).*?"(#{class_name})"/m then
+ comment = comments[index-1]
+ break
+ end
+ end
+ end
end
class_meth.comment = mangle_comment(comment) if comment
end
@@ -425,7 +463,16 @@ module RDoc
end
end
- ############################################################
+ ##
+ # Adds constant comments. By providing some_value: at the start ofthe
+ # comment you can override the C value of the comment to give a friendly
+ # definition.
+ #
+ # /* 300: The perfect score in bowling */
+ # rb_define_const(cFoo, "PERFECT", INT2FIX(300);
+ #
+ # Will override +INT2FIX(300)+ with the value +300+ in the output RDoc.
+ # Values may include quotes and escaped colons (\:).
def handle_constants(type, var_name, const_name, definition)
#@stats.num_constants += 1
@@ -442,14 +489,39 @@ module RDoc
comment = find_const_comment(type, const_name)
- con = Constant.new(const_name, definition, mangle_comment(comment))
+ # In the case of rb_define_const, the definition and comment are in
+ # "/* definition: comment */" form. The literal ':' and '\' characters
+ # can be escaped with a backslash.
+ if type.downcase == 'const' then
+ elements = mangle_comment(comment).split(':')
+ if elements.nil? or elements.empty? then
+ con = Constant.new(const_name, definition, mangle_comment(comment))
+ else
+ new_definition = elements[0..-2].join(':')
+ if new_definition.empty? then # Default to literal C definition
+ new_definition = definition
+ else
+ new_definition.gsub!("\:", ":")
+ new_definition.gsub!("\\", '\\')
+ end
+ new_definition.sub!(/\A(\s+)/, '')
+ new_comment = $1.nil? ? elements.last : "#{$1}#{elements.last.lstrip}"
+ con = Constant.new(const_name, new_definition,
+ mangle_comment(new_comment))
+ end
+ else
+ con = Constant.new(const_name, definition, mangle_comment(comment))
+ end
+
class_obj.add_constant(con)
end
- ###########################################################
+ ##
+ # Finds a comment matching +type+ and +const_name+ either above the
+ # comment or in the matching Document- section.
def find_const_comment(type, const_name)
- if @body =~ %r{((?>/\*.*?\*/\s+))
+ if @body =~ %r{((?>^\s*/\*.*?\*/\s+))
rb_define_#{type}\((?:\s*(\w+),)?\s*"#{const_name}"\s*,.*?\)\s*;}xmi
$1
elsif @body =~ %r{Document-(?:const|global|variable):\s#{const_name}\s*?\n((?>.*?\*/))}m
@@ -610,13 +682,15 @@ module RDoc
end
- ##################################################
- #
- # If the comment block contains a section that looks like
+ ##
+ # If the comment block contains a section that looks like:
+ #
# call-seq:
# Array.new
# Array.new(10)
- # use it for the parameters
+ #
+ # use it for the parameters.
+
def find_modifiers(comment, meth_obj)
if comment.sub!(/:nodoc:\s*^\s*\*?\s*$/m, '') or
comment.sub!(/\A\/\*\s*:nodoc:\s*\*\/\Z/, '')
@@ -639,10 +713,11 @@ module RDoc
end
end
- ############################################################
-
- # Look for includes of the form
+ ##
+ # Look for includes of the form:
+ #
# rb_include_module(rb_cArray, rb_mEnumerable);
+
def do_includes
@body.scan(/rb_include_module\s*\(\s*(\w+?),\s*(\w+?)\s*\)/) do |c,m|
if cls = @classes[c]
@@ -652,8 +727,7 @@ module RDoc
end
end
- ############################################################
-
+ ##
# Remove the /*'s and leading asterisks from C comments
def mangle_comment(comment)
@@ -686,7 +760,8 @@ module RDoc
end
end
- # Remove #ifdefs that would otherwise confuse us
+ ##
+ # Removes #ifdefs that would otherwise confuse us
def handle_ifdefs_in(body)
body.gsub(/^#ifdef HAVE_PROTOTYPES.*?#else.*?\n(.*?)#endif.*?\n/m) { $1 }
@@ -695,3 +770,4 @@ module RDoc
end
end
+
diff --git a/lib/rdoc/parsers/parse_rb.rb b/lib/rdoc/parsers/parse_rb.rb
index dde017be7d..58ba06084e 100644
--- a/lib/rdoc/parsers/parse_rb.rb
+++ b/lib/rdoc/parsers/parse_rb.rb
@@ -1485,7 +1485,7 @@ module RDoc
obj.pop_token
end if @token_listeners
else
- warn("':' not followed by identified or operator")
+ warn("':' not followed by identifier or operator")
tk = tk1
end
end
diff --git a/lib/rdoc/rdoc.rb b/lib/rdoc/rdoc.rb
index cb5d6501d8..91f5611196 100644
--- a/lib/rdoc/rdoc.rb
+++ b/lib/rdoc/rdoc.rb
@@ -16,6 +16,7 @@ require 'rdoc/diagram'
require 'find'
require 'ftools'
+require 'time'
# We put rdoc stuff in the RDoc module to avoid namespace
# clutter.
@@ -106,25 +107,38 @@ module RDoc
# 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")
+ def setup_output_dir(op_dir, force)
+ flag_file = output_flag_file(op_dir)
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)
+ begin
+ created = File.read(flag_file)
+ rescue SystemCallError
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"
+ else
+ last = (Time.parse(created) unless force rescue nil)
end
else
File.makedirs(op_dir)
end
- File.open(flag_file, "w") {|f| f.puts Time.now }
+ last
+ end
+
+ # Update the flag file in an output directory.
+ def update_output_dir(op_dir, time)
+ File.open(output_flag_file(op_dir), "w") {|f| f.puts time.rfc2822 }
+ end
+
+ # Return the path name of the flag file in an output directory.
+ def output_flag_file(op_dir)
+ File.join(op_dir, "created.rid")
end
-
# The .document file contains a list of file and directory name
# patterns, representing candidates for documentation. It may
@@ -160,8 +174,10 @@ module RDoc
relative_files.each do |rel_file_name|
next if exclude_pattern && exclude_pattern =~ rel_file_name
- case type = File.stat(rel_file_name).ftype
+ stat = File.stat(rel_file_name)
+ case type = stat.ftype
when "file"
+ next if @last_created and stat.mtime < @last_created
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"
@@ -238,22 +254,25 @@ module RDoc
options = Options.instance
options.parse(argv, GENERATORS)
-
+
+ @last_created = nil
unless options.all_one_file
- setup_output_dir(options.op_dir)
+ @last_created = setup_output_dir(options.op_dir, options.force_update)
end
+ start_time = Time.now
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?
+ if file_info.empty?
+ $stderr.puts "\nNo newer files." unless options.quiet
+ else
+ gen = options.generator
+
+ $stderr.puts "\nGenerating #{gen.key.upcase}..." unless options.quiet
+
+ require gen.file_name
+
+ gen_class = Generators.const_get(gen.class_name)
gen = gen_class.for(options)
pwd = Dir.pwd
@@ -263,6 +282,7 @@ module RDoc
begin
Diagram.new(file_info, options).draw if options.diagram
gen.generate(file_info)
+ update_output_dir(".", start_time)
ensure
Dir.chdir(pwd)
end
diff --git a/lib/rdoc/ri/ri_formatter.rb b/lib/rdoc/ri/ri_formatter.rb
index 56a1fb4665..34eb561ca3 100644
--- a/lib/rdoc/ri/ri_formatter.rb
+++ b/lib/rdoc/ri/ri_formatter.rb
@@ -554,9 +554,7 @@ module RI
def display_verbatim_flow_item(item, prefix=@indent)
print("<pre>")
- item.body.split(/\n/).each do |line|
- puts conv_html(line)
- end
+ puts item.body
puts("</pre>")
end
diff --git a/lib/resolv.rb b/lib/resolv.rb
index 1792fd8178..49e40bdf07 100644
--- a/lib/resolv.rb
+++ b/lib/resolv.rb
@@ -278,7 +278,7 @@ class Resolv
end
class Hosts
- if /mswin32|mingw|bccwin/ =~ RUBY_PLATFORM
+ if /mswin32|cygwin|mingw|bccwin/ =~ RUBY_PLATFORM
require 'win32/resolv'
DefaultFileName = Win32::Resolv.get_hosts_path
else
@@ -759,7 +759,6 @@ class Resolv
config_hash = Config.parse_resolv_conf(filename)
else
if /mswin32|cygwin|mingw|bccwin/ =~ RUBY_PLATFORM
- require 'win32/resolv'
search, nameserver = Win32::Resolv.get_resolv_info
config_hash = {}
config_hash[:nameserver] = nameserver if nameserver
diff --git a/lib/rexml/comment.rb b/lib/rexml/comment.rb
index cb91d47f8c..a4fcb58c8d 100644
--- a/lib/rexml/comment.rb
+++ b/lib/rexml/comment.rb
@@ -35,31 +35,19 @@ module REXML
end
# output::
- # Where to write the string
+ # 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.
+ # 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.
+ # Ignored by this class. The contents of comments are never modified.
# 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.
- #
+ # Needed for conformity to the child API, but not used by this class.
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
diff --git a/lib/rexml/dtd/dtd.rb b/lib/rexml/dtd/dtd.rb
index 4f735d4812..81119cfa9b 100644
--- a/lib/rexml/dtd/dtd.rb
+++ b/lib/rexml/dtd/dtd.rb
@@ -25,7 +25,7 @@ module REXML
when ElementDecl.PATTERN_RE
match = $&
source = $'
- contents << ElementDecl.new( match )
+ contents << EleemntDecl.new( match )
when AttlistDecl.PATTERN_RE
matchdata = $~
source = $'
diff --git a/lib/rexml/element.rb b/lib/rexml/element.rb
index 80463d95b7..11e2039609 100644
--- a/lib/rexml/element.rb
+++ b/lib/rexml/element.rb
@@ -94,7 +94,7 @@ module REXML
# new_a = d.root.clone
# puts new_a # => "<a/>"
def clone
- Element.new self
+ self.class.new self
end
# Evaluates to the root node of the document that this element
@@ -200,9 +200,9 @@ module REXML
end
def namespaces
- namespaces = []
+ namespaces = {}
namespaces = parent.namespaces if parent
- namespaces |= attributes.namespaces
+ namespaces = namespaces.merge( attributes.namespaces )
return namespaces
end
@@ -494,13 +494,12 @@ module REXML
# 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 )
+ 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?
@@ -557,13 +556,9 @@ module REXML
#################################################
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}" )
+ prefix = nil
+ prefix = namespaces.index(namespace) if namespace
+ attributes.get_attribute( "#{prefix ? prefix + ':' : ''}#{name}" )
end
# Evaluates to +true+ if this element has any attributes set, false
@@ -938,6 +933,29 @@ module REXML
def each( xpath=nil, &block)
XPath::each( @element, xpath ) {|e| yield e if e.kind_of? Element }
end
+
+ def collect( xpath=nil, &block )
+ collection = []
+ XPath::each( @element, xpath ) {|e|
+ collection << yield(e) if e.kind_of?(Element)
+ }
+ collection
+ end
+
+ def inject( xpath=nil, initial=nil, &block )
+ first = true
+ XPath::each( @element, xpath ) {|e|
+ if (e.kind_of? Element)
+ if (first and initial == nil)
+ initial = e
+ first = false
+ else
+ initial = yield( initial, e ) if e.kind_of? Element
+ end
+ end
+ }
+ initial
+ end
# Returns the number of +Element+ children of the parent object.
# doc = Document.new '<a>sean<b/>elliott<b/>russell<b/></a>'
@@ -1149,16 +1167,16 @@ module REXML
end
def namespaces
- namespaces = []
+ namespaces = {}
each_attribute do |attribute|
- namespaces << attribute.value if attribute.prefix == 'xmlns' or attribute.name == 'xmlns'
+ namespaces[attribute.name] = 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'
+ namespaces[attribute.name] = attribute.value if attribute.prefix == 'xmlns' or attribute.name == 'xmlns'
}
end
namespaces
diff --git a/lib/rexml/encoding.rb b/lib/rexml/encoding.rb
index 644957439e..e35c3acf7c 100644
--- a/lib/rexml/encoding.rb
+++ b/lib/rexml/encoding.rb
@@ -24,21 +24,22 @@ module REXML
old_verbosity = $VERBOSE
begin
$VERBOSE = false
- return if defined? @encoding and enc == @encoding
+ enc = enc.nil? ? nil : enc.upcase
+ return false if defined? @encoding and enc == @encoding
if enc and enc != UTF_8
- @encoding = enc.upcase
+ @encoding = enc
+ raise ArgumentError, "Bad encoding name #@encoding" unless @encoding =~ /^[\w-]+$/
+ @encoding.untaint
begin
require 'rexml/encodings/ICONV.rb'
Encoding.apply(self, "ICONV")
- rescue LoadError, Exception => err
- raise ArgumentError, "Bad encoding name #@encoding" unless @encoding =~ /^[\w-]+$/
- @encoding.untaint
- enc_file = File.join( "rexml", "encodings", "#@encoding.rb" )
+ rescue LoadError, Exception
begin
+ enc_file = File.join( "rexml", "encodings", "#@encoding.rb" )
require enc_file
Encoding.apply(self, @encoding)
- rescue LoadError
- puts $!.message
+ rescue LoadError => err
+ puts err.message
raise ArgumentError, "No decoder found for encoding #@encoding. Please install iconv."
end
end
@@ -50,13 +51,14 @@ module REXML
ensure
$VERBOSE = old_verbosity
end
+ true
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 UTF_16 if /\A\xfe\xff/n =~ str
+ return UNILE if /\A\xff\xfe/n =~ str
+ str =~ /^\s*<?xml\s*version\s*=\s*(['"]).*?\2\s*encoding\s*=\s*(["'])(.*?)\2/um
return $1.upcase if $1
return UTF_8
end
diff --git a/lib/rexml/encodings/CP-1252.rb b/lib/rexml/encodings/CP-1252.rb
index 950ec4b57b..51179f119f 100644
--- a/lib/rexml/encodings/CP-1252.rb
+++ b/lib/rexml/encodings/CP-1252.rb
@@ -11,35 +11,35 @@ module REXML
array_utf8.each do |num|
case num
# shortcut first bunch basic characters
- when 0..0xFF; array_enc << num
+ 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
+ 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
@@ -60,33 +60,33 @@ module REXML
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
+ 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
diff --git a/lib/rexml/encodings/ISO-8859-15.rb b/lib/rexml/encodings/ISO-8859-15.rb
index 8c7d84c90e..ce565e7dd5 100644
--- a/lib/rexml/encodings/ISO-8859-15.rb
+++ b/lib/rexml/encodings/ISO-8859-15.rb
@@ -11,25 +11,25 @@ module REXML
array_utf8.each do |num|
case num
# shortcut first bunch basic characters
- when 0..0xA3; array_enc << num
+ 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;'
+ 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
+ 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
@@ -50,14 +50,14 @@ module REXML
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
+ 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
diff --git a/lib/rexml/encodings/SHIFT-JIS.rb b/lib/rexml/encodings/SHIFT-JIS.rb
index 9e0f4af20e..93c7877afd 100644
--- a/lib/rexml/encodings/SHIFT-JIS.rb
+++ b/lib/rexml/encodings/SHIFT-JIS.rb
@@ -13,8 +13,8 @@ module REXML
rescue LoadError
require 'nkf'
- SJISTOU8 = '-Swm0x'
- U8TOSJIS = '-Wsm0x'
+ SJISTOU8 = '-Swm0'
+ U8TOSJIS = '-Wsm0'
def decode_sjis(str)
NKF.nkf(SJISTOU8, str)
diff --git a/lib/rexml/encodings/UNILE.rb b/lib/rexml/encodings/UNILE.rb
index 0560a08361..d054140c40 100644
--- a/lib/rexml/encodings/UNILE.rb
+++ b/lib/rexml/encodings/UNILE.rb
@@ -18,7 +18,7 @@ module REXML
def decode_unile(str)
array_enc=str.unpack('C*')
array_utf8 = []
- 2.step(array_enc.size-1, 2){|i|
+ 0.step(array_enc.size-1, 2){|i|
array_utf8 << (array_enc.at(i) + array_enc.at(i+1)*0x100)
}
array_utf8.pack('U*')
diff --git a/lib/rexml/encodings/UTF-16.rb b/lib/rexml/encodings/UTF-16.rb
index 972169755e..792adfd44d 100644
--- a/lib/rexml/encodings/UTF-16.rb
+++ b/lib/rexml/encodings/UTF-16.rb
@@ -16,9 +16,10 @@ module REXML
end
def decode_utf16(str)
+ str = str[2..-1] if /^\376\377/ =~ str
array_enc=str.unpack('C*')
array_utf8 = []
- 2.step(array_enc.size-1, 2){|i|
+ 0.step(array_enc.size-1, 2){|i|
array_utf8 << (array_enc.at(i+1) + array_enc.at(i)*0x100)
}
array_utf8.pack('U*')
diff --git a/lib/rexml/functions.rb b/lib/rexml/functions.rb
index c09ffdeae7..cad4f6a8c9 100644
--- a/lib/rexml/functions.rb
+++ b/lib/rexml/functions.rb
@@ -117,16 +117,30 @@ module REXML
elsif defined? object.node_type
if object.node_type == :attribute
object.value
- elsif object.node_type == :element
- object.text
+ elsif object.node_type == :element || object.node_type == :document
+ string_value(object)
else
object.to_s
end
+ elsif object.nil?
+ return ""
else
object.to_s
end
end
+ def Functions::string_value( o )
+ rv = ""
+ o.children.each { |e|
+ if e.node_type == :text
+ rv << e.to_s
+ elsif e.node_type == :element
+ rv << string_value( e )
+ end
+ }
+ rv
+ end
+
# UNTESTED
def Functions::concat( *objects )
objects.join
@@ -139,7 +153,7 @@ module REXML
# Fixed by Mike Stok
def Functions::contains( string, test )
- string(string).include? string(test)
+ string(string).include?(string(test))
end
# Kouhei fixed this
@@ -326,8 +340,10 @@ module REXML
else
str = string( object )
#puts "STRING OF #{object.inspect} = #{str}"
- if str =~ /^\d+/
- object.to_s.to_f
+ # If XPath ever gets scientific notation...
+ #if str =~ /^\s*-?(\d*\.?\d+|\d+\.)([Ee]\d*)?\s*$/
+ if str =~ /^\s*-?(\d*\.?\d+|\d+\.)\s*$/
+ str.to_f
else
(0.0 / 0.0)
end
diff --git a/lib/rexml/node.rb b/lib/rexml/node.rb
index e5dec72a9d..7226e5be6c 100644
--- a/lib/rexml/node.rb
+++ b/lib/rexml/node.rb
@@ -55,10 +55,8 @@ module REXML
return nil
end
- # Returns the index that +self+ has in its parent's elements array, so that
- # the following equation holds true:
- #
- # node == node.parent.elements[node.index_in_parent]
+ # Returns the position that +self+ holds in its parent's array, indexed
+ # from 1.
def index_in_parent
parent.index(self)+1
end
diff --git a/lib/rexml/parsers/baseparser.rb b/lib/rexml/parsers/baseparser.rb
index bce4ba4c20..fecd801d6f 100644
--- a/lib/rexml/parsers/baseparser.rb
+++ b/lib/rexml/parsers/baseparser.rb
@@ -49,8 +49,8 @@ module REXML
CLOSE_MATCH = /^\s*<\/(#{NAME_STR})\s*>/um
VERSION = /\bversion\s*=\s*["'](.*?)['"]/um
- ENCODING = /\bencoding=["'](.*?)['"]/um
- STANDALONE = /\bstandalone=["'](.*?)['"]/um
+ ENCODING = /\bencoding\s*=\s*["'](.*?)['"]/um
+ STANDALONE = /\bstandalone\s*=\s["'](.*?)['"]/um
ENTITY_START = /^\s*<!ENTITY/
IDENTITY = /^([!\*\w\-]+)(\s+#{NCNAME_STR})?(\s+["'].*?['"])?(\s+['"].*?["'])?/u
@@ -96,6 +96,13 @@ module REXML
"apos" => [/&apos;/, "&apos;", "'", /'/]
}
+
+ ######################################################################
+ # These are patterns to identify common markup errors, to make the
+ # error messages more informative.
+ ######################################################################
+ MISSING_ATTRIBUTE_QUOTES = /^<#{NAME_STR}\s+#{NAME_STR}\s*=\s*[^"']/um
+
def initialize( source )
self.stream = source
end
@@ -139,8 +146,6 @@ module REXML
# Returns true if there are no more events
def empty?
- #STDERR.puts "@source.empty? = #{@source.empty?}"
- #STDERR.puts "@stack.empty? = #{@stack.empty?}"
return (@source.empty? and @stack.empty?)
end
@@ -335,7 +340,11 @@ module REXML
else
# Get the next tag
md = @source.match(TAG_MATCH, true)
- raise REXML::ParseException.new("malformed XML: missing tag start", @source) unless md
+ unless md
+ # Check for missing attribute quotes
+ raise REXML::ParseException.new("missing attribute quote", @source) if @source.match(MISSING_ATTRIBUTE_QUOTES )
+ raise REXML::ParseException.new("malformed XML: missing tag start", @source)
+ end
attrs = []
if md[2].size > 0
attrs = md[2].scan( ATTRIBUTE_PATTERN )
@@ -354,8 +363,6 @@ module REXML
else
md = @source.match( TEXT_PATTERN, true )
if md[0].length == 0
- puts "EMPTY = #{empty?}"
- puts "BUFFER = \"#{@source.buffer}\""
@source.match( /(\s+)/, true )
end
#STDERR.puts "GOT #{md[1].inspect}" unless md[0].length == 0
diff --git a/lib/rexml/parsers/sax2parser.rb b/lib/rexml/parsers/sax2parser.rb
index 61a216cec1..6c7fbe000a 100644
--- a/lib/rexml/parsers/sax2parser.rb
+++ b/lib/rexml/parsers/sax2parser.rb
@@ -16,6 +16,10 @@ module REXML
@tag_stack = []
@entities = {}
end
+
+ def source
+ @parser.source
+ end
def add_listener( listener )
@parser.add_listener( listener )
diff --git a/lib/rexml/parsers/treeparser.rb b/lib/rexml/parsers/treeparser.rb
index 500a53f426..a53fa41925 100644
--- a/lib/rexml/parsers/treeparser.rb
+++ b/lib/rexml/parsers/treeparser.rb
@@ -23,7 +23,8 @@ module REXML
case event[0]
when :end_document
unless tag_stack.empty?
- raise ParseException.new("No close tag for #{tag_stack.inspect}")
+ #raise ParseException.new("No close tag for #{tag_stack.inspect}")
+ raise ParseException.new("No close tag for #{@build_context.xpath}")
end
return
when :start_element
diff --git a/lib/rexml/parsers/xpathparser.rb b/lib/rexml/parsers/xpathparser.rb
index 6bac852d6b..6f5b21cd93 100644
--- a/lib/rexml/parsers/xpathparser.rb
+++ b/lib/rexml/parsers/xpathparser.rb
@@ -596,7 +596,13 @@ module REXML
parsed << :function
parsed << fname
path = FunctionCall(path, parsed)
- when LITERAL, NUMBER
+ when NUMBER
+ #puts "LITERAL or NUMBER: #$1"
+ varname = $1.nil? ? $2 : $1
+ path = $'
+ parsed << :literal
+ parsed << (varname.include?('.') ? varname.to_f : varname.to_i)
+ when LITERAL
#puts "LITERAL or NUMBER: #$1"
varname = $1.nil? ? $2 : $1
path = $'
diff --git a/lib/rexml/rexml.rb b/lib/rexml/rexml.rb
index ca154443b5..bff1cd9815 100644
--- a/lib/rexml/rexml.rb
+++ b/lib/rexml/rexml.rb
@@ -10,8 +10,8 @@
#
# Main page:: http://www.germane-software.com/software/rexml
# Author:: Sean Russell <serATgermaneHYPHENsoftwareDOTcom>
-# Version:: 3.1.4
-# Date:: 2006/104
+# Version:: 3.1.6
+# Date:: 2006/335
#
# This API documentation can be downloaded from the REXML home page, or can
# be accessed online[http://www.germane-software.com/software/rexml_doc]
@@ -21,8 +21,8 @@
# online[http://www.germane-software.com/software/rexml/docs/tutorial.html]
module REXML
COPYRIGHT = "Copyright © 2001-2006 Sean Russell <ser@germane-software.com>"
- DATE = "2006/104"
- VERSION = "3.1.4"
+ DATE = "2006/335"
+ VERSION = "3.1.6"
Copyright = COPYRIGHT
Version = VERSION
diff --git a/lib/rexml/sax2listener.rb b/lib/rexml/sax2listener.rb
index 9a992917e6..8db1389d06 100644
--- a/lib/rexml/sax2listener.rb
+++ b/lib/rexml/sax2listener.rb
@@ -70,7 +70,7 @@ module REXML
# ["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
+ def entitydecl name, decl
end
# <!NOTATION ...>
def notationdecl content
diff --git a/lib/rexml/source.rb b/lib/rexml/source.rb
index dfe6c19f07..2fee99c0e9 100644
--- a/lib/rexml/source.rb
+++ b/lib/rexml/source.rb
@@ -6,7 +6,7 @@ module REXML
# 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
+ def SourceFactory::create_from(arg)
if arg.kind_of? String
Source.new(arg)
elsif arg.respond_to? :read and
@@ -17,7 +17,7 @@ module REXML
elsif arg.kind_of? Source
arg
else
- raise "#{arg.class} is not a valid input stream. It must walk \n"+
+ raise "#{source.class} is not a valid input stream. It must walk \n"+
"like either a String, IO, or Source."
end
end
@@ -35,16 +35,23 @@ module REXML
# Constructor
# @param arg must be a String, and should be a valid XML document
- def initialize(arg)
+ # @param encoding if non-null, sets the encoding of the source to this
+ # value, overriding all encoding detection
+ def initialize(arg, encoding=nil)
@orig = @buffer = arg
- self.encoding = check_encoding( @buffer )
+ if encoding
+ self.encoding = encoding
+ else
+ self.encoding = check_encoding( @buffer )
+ end
@line = 0
end
+
# Inherited from Encoding
# Overridden to support optimized en/decoding
def encoding=(enc)
- super
+ return unless super
@line_break = encode( '>' )
if enc != UTF_8
@buffer = decode(@buffer)
@@ -124,7 +131,7 @@ module REXML
#attr_reader :block_size
# block_size has been deprecated
- def initialize(arg, block_size=500)
+ def initialize(arg, block_size=500, encoding=nil)
@er_source = @source = arg
@to_utf = false
# Determining the encoding is a deceptively difficult issue to resolve.
@@ -134,15 +141,17 @@ module REXML
# 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.
+ @buffer = ""
str = @source.read( 2 )
- if (str[0] == 254 && str[1] == 255) || (str[0] == 255 && str[1] == 254)
- @encoding = check_encoding( str )
- @line_break = encode( '>' )
+ if encoding
+ self.encoding = encoding
+ elsif /\A(?:\xfe\xff|\xff\xfe)/n =~ str
+ self.encoding = check_encoding( str )
else
@line_break = '>'
end
super str+@source.readline( @line_break )
- end
+ end
def scan(pattern, cons=false)
rv = super
@@ -159,6 +168,8 @@ module REXML
str = @source.readline(@line_break)
str = decode(str) if @to_utf and str
@buffer << str
+ rescue Iconv::IllegalSequence
+ raise
rescue
@source = nil
end
diff --git a/lib/rexml/text.rb b/lib/rexml/text.rb
index 55bc9f50f8..3de9170623 100644
--- a/lib/rexml/text.rb
+++ b/lib/rexml/text.rb
@@ -42,6 +42,7 @@ module REXML
# Use this field if you have entities defined for some text, and you don't
# want REXML to escape that text in output.
# Text.new( "<&", false, nil, false ) #-> "&lt;&amp;"
+ # Text.new( "&lt;&amp;", false, nil, false ) #-> "&amp;lt;&amp;amp;"
# Text.new( "<&", false, nil, true ) #-> Parse exception
# Text.new( "&lt;&amp;", false, nil, true ) #-> "&lt;&amp;"
# # Assume that the entity "s" is defined to be "sean"
@@ -172,17 +173,6 @@ module REXML
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.
@@ -198,17 +188,28 @@ module REXML
@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
+ 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
+
+ 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()
@@ -286,9 +287,10 @@ module REXML
def Text::normalize( input, doctype=nil, entity_filter=nil )
copy = input
# Doing it like this rather than in a loop improves the speed
+ #copy = copy.gsub( EREFERENCE, '&amp;' )
+ copy = copy.gsub( "&", "&amp;" )
if doctype
# Replace all ampersands that aren't part of an entity
- copy = copy.gsub( EREFERENCE, '&amp;' )
doctype.entities.each_value do |entity|
copy = copy.gsub( entity.value,
"&#{entity.name};" ) if entity.value and
@@ -296,7 +298,6 @@ module REXML
end
else
# Replace all ampersands that aren't part of an entity
- copy = copy.gsub( EREFERENCE, '&amp;' )
DocType::DEFAULT_ENTITIES.each_value do |entity|
copy = copy.gsub(entity.value, "&#{entity.name};" )
end
diff --git a/lib/rexml/xpath.rb b/lib/rexml/xpath.rb
index 1ed440868b..939399e283 100644
--- a/lib/rexml/xpath.rb
+++ b/lib/rexml/xpath.rb
@@ -19,9 +19,9 @@ module REXML
# XPath.first( node )
# XPath.first( doc, "//b"} )
# XPath.first( node, "a/x:b", { "x"=>"http://doofus" } )
- def XPath::first element, path=nil, namespaces={}, variables={}
- raise "The namespaces argument, if supplied, must be a hash object." unless namespaces.kind_of? Hash
- raise "The variables argument, if supplied, must be a hash object." unless variables.kind_of? Hash
+ def XPath::first element, path=nil, namespaces=nil, variables={}
+ raise "The namespaces argument, if supplied, must be a hash object." unless namespaces.nil? or namespaces.kind_of?(Hash)
+ raise "The variables argument, if supplied, must be a hash object." unless variables.kind_of?(Hash)
parser = XPathParser.new
parser.namespaces = namespaces
parser.variables = variables
@@ -42,9 +42,9 @@ module REXML
# XPath.each( node ) { |el| ... }
# XPath.each( node, '/*[@attr='v']' ) { |el| ... }
# XPath.each( node, 'ancestor::x' ) { |el| ... }
- def XPath::each element, path=nil, namespaces={}, variables={}, &block
- raise "The namespaces argument, if supplied, must be a hash object." unless namespaces.kind_of? Hash
- raise "The variables argument, if supplied, must be a hash object." unless variables.kind_of? Hash
+ def XPath::each element, path=nil, namespaces=nil, variables={}, &block
+ raise "The namespaces argument, if supplied, must be a hash object." unless namespaces.nil? or namespaces.kind_of?(Hash)
+ raise "The variables argument, if supplied, must be a hash object." unless variables.kind_of?(Hash)
parser = XPathParser.new
parser.namespaces = namespaces
parser.variables = variables
@@ -54,7 +54,7 @@ module REXML
end
# Returns an array of nodes matching a given XPath.
- def XPath::match element, path=nil, namespaces={}, variables={}
+ def XPath::match element, path=nil, namespaces=nil, variables={}
parser = XPathParser.new
parser.namespaces = namespaces
parser.variables = variables
diff --git a/lib/rexml/xpath_parser.rb b/lib/rexml/xpath_parser.rb
index 98ed70cc10..3393113d6a 100644
--- a/lib/rexml/xpath_parser.rb
+++ b/lib/rexml/xpath_parser.rb
@@ -10,9 +10,13 @@ class Object
end
end
class Symbol
- def dclone
- self
- end
+ def dclone ; self ; end
+end
+class Fixnum
+ def dclone ; self ; end
+end
+class Float
+ def dclone ; self ; end
end
class Array
def dclone
@@ -34,7 +38,7 @@ module REXML
def initialize( )
@parser = REXML::Parsers::XPathParser.new
- @namespaces = {}
+ @namespaces = nil
@variables = {}
end
@@ -130,6 +134,21 @@ module REXML
private
+ # Returns a String namespace for a node, given a prefix
+ # The rules are:
+ #
+ # 1. Use the supplied namespace mapping first.
+ # 2. If no mapping was supplied, use the context node to look up the namespace
+ def get_namespace( node, prefix )
+ if @namespaces
+ return @namespaces[prefix] || ''
+ else
+ return node.namespace( prefix ) if node.node_type == :element
+ return ''
+ end
+ end
+
+
# Expr takes a stack of path elements and a set of nodes (either a Parent
# or an Array and returns an Array of matching nodes
ALL = [ :attribute, :element, :text, :processing_instruction, :comment ]
@@ -143,6 +162,10 @@ module REXML
while path_stack.length > 0
#puts "Path stack = #{path_stack.inspect}"
#puts "Nodeset is #{nodeset.inspect}"
+ if nodeset.length == 0
+ path_stack.clear
+ return []
+ end
case (op = path_stack.shift)
when :document
nodeset = [ nodeset[0].root_node ]
@@ -152,12 +175,9 @@ module REXML
#puts "IN QNAME"
prefix = path_stack.shift
name = path_stack.shift
- default_ns = @namespaces[prefix]
- default_ns = default_ns ? default_ns : ''
nodeset.delete_if do |node|
- ns = default_ns
# FIXME: This DOUBLES the time XPath searches take
- ns = node.namespace( prefix ) if node.node_type == :element and ns == ''
+ ns = get_namespace( node, prefix )
#puts "NS = #{ns.inspect}"
#puts "node.node_type == :element => #{node.node_type == :element}"
if node.node_type == :element
@@ -209,11 +229,7 @@ module REXML
node_types = ELEMENTS
when :literal
- literal = path_stack.shift
- if literal =~ /^\d+(\.\d+)?$/
- return ($1 ? literal.to_f : literal.to_i)
- end
- return literal
+ return path_stack.shift
when :attribute
new_nodeset = []
@@ -223,9 +239,11 @@ module REXML
name = path_stack.shift
for element in nodeset
if element.node_type == :element
- #puts element.name
- attr = element.attribute( name, @namespaces[prefix] )
- new_nodeset << attr if attr
+ #puts "Element name = #{element.name}"
+ #puts "get_namespace( #{element.inspect}, #{prefix} ) = #{get_namespace(element, prefix)}"
+ attrib = element.attribute( name, get_namespace(element, prefix) )
+ #puts "attrib = #{attrib.inspect}"
+ new_nodeset << attrib if attrib
end
end
when :any
@@ -287,8 +305,10 @@ module REXML
#puts "Adding node #{node.inspect}" if result == (index+1)
new_nodeset << node if result == (index+1)
elsif result.instance_of? Array
- #puts "Adding node #{node.inspect}" if result.size > 0
- new_nodeset << node if result.size > 0
+ if result.size > 0 and result.inject(false) {|k,s| s or k}
+ #puts "Adding node #{node.inspect}" if result.size > 0
+ new_nodeset << node if result.size > 0
+ end
else
#puts "Adding node #{node.inspect}" if result
new_nodeset << node if result
@@ -369,9 +389,19 @@ module REXML
node_types = ELEMENTS
when :namespace
- new_set = []
+ new_nodeset = []
+ prefix = path_stack.shift
for node in nodeset
- new_nodeset << node.namespace if node.node_type == :element or node.node_type == :attribute
+ if (node.node_type == :element or node.node_type == :attribute)
+ if (node.node_type == :element)
+ namespaces = node.namespaces
+ else
+ namespaces = node.element.namesapces
+ end
+ if (node.namespace == namespaces[prefix])
+ new_nodeset << node
+ end
+ end
end
nodeset = new_nodeset
@@ -392,6 +422,18 @@ module REXML
#puts "RES => #{res.inspect}"
return res
+ when :and
+ left = expr( path_stack.shift, nodeset.dup, context )
+ #puts "LEFT => #{left.inspect} (#{left.class.name})"
+ if left == false || left.nil? || !left.inject(false) {|a,b| a | b}
+ return []
+ end
+ right = expr( path_stack.shift, nodeset.dup, context )
+ #puts "RIGHT => #{right.inspect} (#{right.class.name})"
+ res = equality_relational_compare( left, op, right )
+ #puts "RES => #{res.inspect}"
+ return res
+
when :div
left = Functions::number(expr(path_stack.shift, nodeset, context)).to_f
right = Functions::number(expr(path_stack.shift, nodeset, context)).to_f
@@ -465,7 +507,7 @@ module REXML
# The next two methods are BAD MOJO!
# This is my achilles heel. If anybody thinks of a better
# way of doing this, be my guest. This really sucks, but
- # it took me three days to get it to work at all.
+ # it is a wonder it works at all.
# ########################################################
def descendant_or_self( path_stack, nodeset )
diff --git a/lib/rinda/tuplespace.rb b/lib/rinda/tuplespace.rb
index 6d58a0fd15..73e79bb401 100644
--- a/lib/rinda/tuplespace.rb
+++ b/lib/rinda/tuplespace.rb
@@ -404,6 +404,7 @@ module Rinda
def write(tuple, sec=nil)
entry = TupleEntry.new(tuple, sec)
+ start_keeper
synchronize do
if entry.expired?
@read_waiter.find_all_template(entry).each do |template|
@@ -413,7 +414,6 @@ module Rinda
notify_event('delete', entry.value)
else
@bag.push(entry)
- start_keeper if entry.expires
@read_waiter.find_all_template(entry).each do |template|
template.read(tuple)
end
@@ -439,6 +439,7 @@ module Rinda
def move(port, tuple, sec=nil)
template = WaitTemplateEntry.new(self, tuple, sec)
yield(template) if block_given?
+ start_keeper
synchronize do
entry = @bag.find(template)
if entry
@@ -451,7 +452,6 @@ module Rinda
begin
@take_waiter.push(template)
- start_keeper if template.expires
while true
raise RequestCanceledError if template.canceled?
raise RequestExpiredError if template.expired?
@@ -476,6 +476,7 @@ module Rinda
def read(tuple, sec=nil)
template = WaitTemplateEntry.new(self, tuple, sec)
yield(template) if block_given?
+ start_keeper
synchronize do
entry = @bag.find(template)
return entry.value if entry
@@ -483,7 +484,6 @@ module Rinda
begin
@read_waiter.push(template)
- start_keeper if template.expires
template.wait
raise RequestCanceledError if template.canceled?
raise RequestExpiredError if template.expired?
@@ -566,11 +566,8 @@ module Rinda
def start_keeper
return if @keeper && @keeper.alive?
@keeper = Thread.new do
- while true
- synchronize do
- break unless need_keeper?
- keep_clean
- end
+ while need_keeper?
+ keep_clean
sleep(@period)
end
end
diff --git a/lib/rss/0.9.rb b/lib/rss/0.9.rb
index eb2d828102..69e01ddd57 100644
--- a/lib/rss/0.9.rb
+++ b/lib/rss/0.9.rb
@@ -17,7 +17,6 @@ module RSS
include RSS09
include RootElementMixin
- include XMLStyleSheetMixin
%w(channel).each do |name|
install_have_child_element(name, "", nil)
diff --git a/lib/scanf.rb b/lib/scanf.rb
index 1e63051654..2972bf9d60 100644
--- a/lib/scanf.rb
+++ b/lib/scanf.rb
@@ -1,9 +1,9 @@
# scanf for Ruby
#
-# $Revision: 1.2.2.1 $
-# $Id: scanf.rb,v 1.2.2.1 2004/03/20 11:57:10 dblack Exp $
-# $Author: dblack $
-# $Date: 2004/03/20 11:57:10 $
+# $Revision$
+# $Id$
+# $Author$
+# $Date$
#
# A product of the Austin Ruby Codefest (Austin, Texas, August 2002)
diff --git a/lib/set.rb b/lib/set.rb
index 36e718eaf7..5a9287ba89 100644
--- a/lib/set.rb
+++ b/lib/set.rb
@@ -9,7 +9,7 @@
# All rights reserved. You can redistribute and/or modify it under the same
# terms as Ruby.
#
-# $Id: set.rb,v 1.20.2.7 2005/06/30 06:16:13 matz Exp $
+# $Id$
#
# == Overview
#
@@ -286,7 +286,7 @@ class Set
end
alias difference - ##
- # Returns a new array containing elements common to the set and the
+ # Returns a new set containing elements common to the set and the
# given enumerable object.
def &(enum)
enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable"
@@ -296,13 +296,13 @@ class Set
end
alias intersection & ##
- # Returns a new array containing elements exclusive between the set
+ # Returns a new set containing elements exclusive between the set
# and the given enumerable object. (set ^ enum) is equivalent to
# ((set | enum) - (set & enum)).
def ^(enum)
enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable"
- n = dup
- enum.each { |o| if n.include?(o) then n.delete(o) else n.add(o) end }
+ n = Set.new(enum)
+ each { |o| if n.include?(o) then n.delete(o) else n.add(o) end }
n
end
@@ -1049,6 +1049,13 @@ class TC_Set < Test::Unit::TestCase
assert_equal(Set[2,4], ret)
end
+ def test_xor
+ set = Set[1,2,3,4]
+ ret = set ^ [2,4,5,5]
+ assert_not_same(set, ret)
+ assert_equal(Set[1,3,5], ret)
+ end
+
def test_eq
set1 = Set[2,3,1]
set2 = Set[1,2,3]
diff --git a/lib/shell/builtin-command.rb b/lib/shell/builtin-command.rb
index 02025c5d42..db1adfa48b 100644
--- a/lib/shell/builtin-command.rb
+++ b/lib/shell/builtin-command.rb
@@ -1,8 +1,8 @@
#
# shell/builtin-command.rb -
# $Release Version: 0.6.0 $
-# $Revision: 1.1 $
-# $Date: 2001/05/17 10:02:48 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
#
# --
diff --git a/lib/shell/command-processor.rb b/lib/shell/command-processor.rb
index f08440e457..ecf6c7d5eb 100644
--- a/lib/shell/command-processor.rb
+++ b/lib/shell/command-processor.rb
@@ -1,8 +1,8 @@
#
# shell/command-controller.rb -
# $Release Version: 0.6.0 $
-# $Revision: 1.8.2.2 $
-# $Date: 2004/04/18 23:20:33 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(Nippon Rational Inc.)
#
# --
diff --git a/lib/shell/error.rb b/lib/shell/error.rb
index 2f176862a8..d338b1c5d1 100644
--- a/lib/shell/error.rb
+++ b/lib/shell/error.rb
@@ -1,8 +1,8 @@
#
# shell/error.rb -
# $Release Version: 0.6.0 $
-# $Revision: 1.2 $
-# $Date: 2003/02/07 19:00:21 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
#
# --
diff --git a/lib/shell/filter.rb b/lib/shell/filter.rb
index 12cc5206f8..27c5534695 100644
--- a/lib/shell/filter.rb
+++ b/lib/shell/filter.rb
@@ -1,8 +1,8 @@
#
# shell/filter.rb -
# $Release Version: 0.6.0 $
-# $Revision: 1.3.2.1 $
-# $Date: 2004/03/21 12:21:11 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
#
# --
diff --git a/lib/shell/process-controller.rb b/lib/shell/process-controller.rb
index 573edb6829..8929805506 100644
--- a/lib/shell/process-controller.rb
+++ b/lib/shell/process-controller.rb
@@ -1,8 +1,8 @@
#
# shell/process-controller.rb -
# $Release Version: 0.6.0 $
-# $Revision: 1.3 $
-# $Date: 2003/10/16 17:47:19 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
#
# --
diff --git a/lib/shell/system-command.rb b/lib/shell/system-command.rb
index 8b1cba98c8..f87ba890ea 100644
--- a/lib/shell/system-command.rb
+++ b/lib/shell/system-command.rb
@@ -1,8 +1,8 @@
#
# shell/system-command.rb -
# $Release Version: 0.6.0 $
-# $Revision: 1.2.2.1 $
-# $Date: 2004/03/21 12:21:11 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
#
# --
diff --git a/lib/shell/version.rb b/lib/shell/version.rb
index 46b3425afa..6694c804d8 100644
--- a/lib/shell/version.rb
+++ b/lib/shell/version.rb
@@ -1,8 +1,8 @@
#
# version.rb - shell version definition file
# $Release Version: 0.6.0$
-# $Revision: 1.1 $
-# $Date: 2001/05/17 10:02:48 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
#
# --
diff --git a/lib/sync.rb b/lib/sync.rb
index 03b161c274..79522ed885 100644
--- a/lib/sync.rb
+++ b/lib/sync.rb
@@ -1,8 +1,8 @@
#
# sync.rb - 2 phase lock with counter
# $Release Version: 1.0$
-# $Revision: 1.4 $
-# $Date: 2001/06/06 14:19:33 $
+# $Revision$
+# $Date$
# by Keiju ISHITSUKA(keiju@ishitsuka.com)
#
# --
@@ -44,7 +44,7 @@ unless defined? Thread
end
module Sync_m
- RCS_ID='-$Header: /src/ruby/lib/sync.rb,v 1.4 2001/06/06 14:19:33 keiju Exp $-'
+ RCS_ID='-$Header$-'
# lock mode
UN = :UN
diff --git a/lib/tempfile.rb b/lib/tempfile.rb
index a18c19446a..b885444b15 100644
--- a/lib/tempfile.rb
+++ b/lib/tempfile.rb
@@ -1,7 +1,7 @@
#
# tempfile - manipulates temporary files
#
-# $Id: tempfile.rb,v 1.19.2.5 2006/06/10 23:27:38 matz Exp $
+# $Id$
#
require 'delegate'
diff --git a/lib/test/unit/autorunner.rb b/lib/test/unit/autorunner.rb
index d9720daa49..86c9b12940 100644
--- a/lib/test/unit/autorunner.rb
+++ b/lib/test/unit/autorunner.rb
@@ -7,9 +7,8 @@ module Test
class AutoRunner
def self.run(force_standalone=false, default_dir=nil, argv=ARGV, &block)
r = new(force_standalone || standalone?, &block)
- if((!r.process_args(argv)) && default_dir)
- r.to_run << default_dir
- end
+ r.base = default_dir
+ r.process_args(argv)
r.run
end
@@ -64,12 +63,14 @@ module Test
c.filter = r.filters
c.pattern.concat(r.pattern) if(r.pattern)
c.exclude.concat(r.exclude) if(r.exclude)
+ c.base = r.base
+ $:.push(r.base) if r.base
c.collect(*(r.to_run.empty? ? ['.'] : r.to_run))
end,
}
attr_reader :suite
- attr_accessor :output_level, :filters, :to_run, :pattern, :exclude
+ attr_accessor :output_level, :filters, :to_run, :pattern, :exclude, :base, :workdir
attr_writer :runner, :collector
def initialize(standalone)
@@ -80,6 +81,7 @@ module Test
@filters = []
@to_run = []
@output_level = UI::NORMAL
+ @workdir = nil
yield(self) if(block_given?)
end
@@ -110,6 +112,14 @@ module Test
end
if(@standalone)
+ o.on('-b', '--basedir=DIR', "Base directory of test suites.") do |b|
+ @base = b
+ end
+
+ o.on('-w', '--workdir=DIR', "Working directory to run tests.") do |w|
+ @workdir = w
+ end
+
o.on('-a', '--add=TORUN', Array,
"Add TORUN to the list of things to run;",
"can be a file or a directory.") do |a|
@@ -153,6 +163,11 @@ module Test
end
end
+ o.on('-I', "--load-path=DIR[#{File::PATH_SEPARATOR}DIR...]",
+ "Appends directory list to $LOAD_PATH.") do |dirs|
+ $LOAD_PATH.concat(dirs.split(File::PATH_SEPARATOR))
+ end
+
o.on('-v', '--verbose=[LEVEL]', OUTPUT_LEVELS,
"Set the output level (default is verbose).",
"(" + keyword_display(OUTPUT_LEVELS) + ")") do |l|
@@ -197,6 +212,7 @@ module Test
def run
@suite = @collector[self]
result = @runner[self] or return false
+ Dir.chdir(@workdir) if @workdir
result.run(@suite, @output_level).passed?
end
end
diff --git a/lib/test/unit/collector/dir.rb b/lib/test/unit/collector/dir.rb
index 1395cdf4e5..97c8d28481 100644
--- a/lib/test/unit/collector/dir.rb
+++ b/lib/test/unit/collector/dir.rb
@@ -8,6 +8,7 @@ module Test
include Collector
attr_reader :pattern, :exclude
+ attr_accessor :base
def initialize(dir=::Dir, file=::File, object_space=::ObjectSpace, req=nil)
super()
@@ -20,6 +21,8 @@ module Test
end
def collect(*from)
+ basedir = @base
+ $:.push(basedir) if basedir
if(from.empty?)
recursive_collect('.', find_test_cases)
elsif(from.size == 1)
@@ -34,6 +37,8 @@ module Test
sort(suites).each{|s| suite << s}
suite
end
+ ensure
+ $:.delete_at($:.rindex(basedir)) if basedir
end
def find_test_cases(ignore=[])
@@ -47,11 +52,13 @@ module Test
def recursive_collect(name, already_gathered)
sub_suites = []
- if(@file.directory?(name))
- @dir.entries(name).each do |e|
+ path = realdir(name)
+ if @file.directory?(path)
+ dir_name = name unless name == '.'
+ @dir.entries(path).each do |e|
next if(e == '.' || e == '..')
- e_name = @file.join(name, e)
- if(@file.directory?(e_name))
+ e_name = dir_name ? @file.join(dir_name, e) : e
+ if @file.directory?(realdir(e_name))
next if /\ACVS\z/ =~ e
sub_suite = recursive_collect(e_name, already_gathered)
sub_suites << sub_suite unless(sub_suite.empty?)
@@ -75,7 +82,7 @@ module Test
end
def collect_file(name, suites, already_gathered)
- dir = File.dirname(File.expand_path(name))
+ dir = @file.dirname(@file.expand_path(name, @base))
$:.unshift(dir)
if(@req)
@req.require(name)
@@ -86,6 +93,14 @@ module Test
ensure
$:.delete_at($:.rindex(dir)) if(dir)
end
+
+ def realdir(path)
+ if @base
+ @file.join(@base, path)
+ else
+ path
+ end
+ end
end
end
end
diff --git a/lib/test/unit/testcase.rb b/lib/test/unit/testcase.rb
index b6bb420f96..f53b460c5d 100644
--- a/lib/test/unit/testcase.rb
+++ b/lib/test/unit/testcase.rb
@@ -28,6 +28,12 @@ module Test
STARTED = name + "::STARTED"
FINISHED = name + "::FINISHED"
+ ##
+ # These exceptions are not caught by #run.
+
+ PASSTHROUGH_EXCEPTIONS = [NoMemoryError, SignalException, Interrupt,
+ SystemExit]
+
# Creates a new instance of the fixture for running the
# test represented by test_method_name.
def initialize(test_method_name)
@@ -55,7 +61,7 @@ module Test
end
if (suite.empty?)
catch(:invalid_test) do
- suite << new(:default_test)
+ suite << new("default_test")
end
end
return suite
@@ -72,14 +78,16 @@ module Test
__send__(@method_name)
rescue AssertionFailedError => e
add_failure(e.message, e.backtrace)
- rescue StandardError, ScriptError
+ rescue Exception
+ raise if PASSTHROUGH_EXCEPTIONS.include? $!.class
add_error($!)
ensure
begin
teardown
rescue AssertionFailedError => e
add_failure(e.message, e.backtrace)
- rescue StandardError, ScriptError
+ rescue Exception
+ raise if PASSTHROUGH_EXCEPTIONS.include? $!.class
add_error($!)
end
end
diff --git a/lib/thread.rb b/lib/thread.rb
index 640bea5111..7df6a140f5 100644
--- a/lib/thread.rb
+++ b/lib/thread.rb
@@ -1,6 +1,10 @@
#
+# NOTE:
+# This file is overwritten by ext/thread/lib/thread.rb unless ruby
+# is configured with --disable-fastthread.
+#
# thread.rb - thread support classes
-# $Date: 2005/06/07 09:41:17 $
+# $Date$
# by Yukihiro Matsumoto <matz@netlab.co.jp>
#
# Copyright (C) 2001 Yukihiro Matsumoto
@@ -12,15 +16,6 @@ unless defined? Thread
fail "Thread not available for this ruby interpreter"
end
-unless defined? ThreadError
- class ThreadError<StandardError
- end
-end
-
-if $DEBUG
- Thread.abort_on_exception = true
-end
-
class Thread
#
# Wraps a block in Thread.critical, restoring the original value upon exit
diff --git a/lib/time.rb b/lib/time.rb
index 3b4ee9e72a..dbc25f4193 100644
--- a/lib/time.rb
+++ b/lib/time.rb
@@ -181,7 +181,7 @@ class Time
t.localtime if !zone_utc?(zone)
t
else
- Time.local(year, mon, day, hour, min, sec, usec)
+ self.local(year, mon, day, hour, min, sec, usec)
end
end
private :make_time
@@ -289,7 +289,7 @@ class Time
year, mon, day, hour, min, sec =
apply_offset(year, mon, day, hour, min, sec, zone_offset(zone))
- t = Time.utc(year, mon, day, hour, min, sec)
+ t = self.utc(year, mon, day, hour, min, sec)
t.localtime if !zone_utc?(zone)
t
else
@@ -316,14 +316,14 @@ class Time
(\d{2}):(\d{2}):(\d{2})\x20
GMT
\s*\z/ix =~ date
- Time.rfc2822(date)
+ self.rfc2822(date)
elsif /\A\s*
(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday),\x20
(\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d)\x20
(\d\d):(\d\d):(\d\d)\x20
GMT
\s*\z/ix =~ date
- Time.parse(date)
+ self.parse(date)
elsif /\A\s*
(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)\x20
(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\x20
@@ -331,7 +331,7 @@ class Time
(\d\d):(\d\d):(\d\d)\x20
(\d{4})
\s*\z/ix =~ date
- Time.utc($6.to_i, MonthValue[$1.upcase], $2.to_i,
+ self.utc($6.to_i, MonthValue[$1.upcase], $2.to_i,
$3.to_i, $4.to_i, $5.to_i)
else
raise ArgumentError.new("not RFC 2616 compliant date: #{date.inspect}")
diff --git a/lib/timeout.rb b/lib/timeout.rb
index 5a99c28092..dc92964c0b 100644
--- a/lib/timeout.rb
+++ b/lib/timeout.rb
@@ -32,13 +32,8 @@ module Timeout
##
# Raised by Timeout#timeout when the block times out.
- class Error < Interrupt
+ class Error<Interrupt
end
- class ExitException < ::Exception # :nodoc:
- end
-
- THIS_FILE = /\A#{Regexp.quote(__FILE__)}:/o
- CALLER_OFFSET = ((c = caller[0]) && THIS_FILE =~ c) ? 1 : 0
##
# Executes the method's block. If the block execution terminates before +sec+
@@ -49,10 +44,9 @@ module Timeout
# Timeout' into your classes so they have a #timeout method, as well as a
# module method, so you can call it directly as Timeout.timeout().
- def timeout(sec, klass = nil)
+ def timeout(sec, exception=Error)
return yield if sec == nil or sec.zero?
raise ThreadError, "timeout within critical session" if Thread.critical
- exception = klass || Class.new(ExitException)
begin
x = Thread.current
y = Thread.start {
@@ -61,17 +55,6 @@ module Timeout
}
yield sec
# return true
- rescue exception => e
- rej = /\A#{Regexp.quote(__FILE__)}:#{__LINE__-4}\z/o
- (bt = e.backtrace).reject! {|m| rej =~ m}
- level = -caller(CALLER_OFFSET).size
- while THIS_FILE =~ bt[level]
- bt.delete_at(level)
- level += 1
- end
- raise if klass # if exception class is specified, it
- # would be expected outside.
- raise Error, e.message, e.backtrace
ensure
y.kill if y and y.alive?
end
@@ -89,7 +72,7 @@ end
# Defined for backwards compatibility with earlier versions of timeout.rb, see
# Timeout#timeout.
-def timeout(n, e = nil, &block) # :nodoc:
+def timeout(n, e=Timeout::Error, &block) # :nodoc:
Timeout::timeout(n, e, &block)
end
diff --git a/lib/tmpdir.rb b/lib/tmpdir.rb
index bfc214b6b9..434d1bf053 100644
--- a/lib/tmpdir.rb
+++ b/lib/tmpdir.rb
@@ -1,7 +1,7 @@
#
# tmpdir - retrieve temporary directory path
#
-# $Id: tmpdir.rb,v 1.5.2.1 2005/12/15 15:57:05 matz Exp $
+# $Id$
#
class Dir
@@ -17,8 +17,8 @@ class Dir
rescue RuntimeError
getdir = Win32API.new('kernel32', 'GetWindowsDirectory', 'PL', 'L')
end
- getdir.call(windir, windir.size)
- windir = File.expand_path(windir.rstrip.untaint)
+ len = getdir.call(windir, windir.size)
+ windir = File.expand_path(windir[0, len])
temp = File.join(windir, 'temp')
@@systmpdir = temp if File.directory?(temp) and File.writable?(temp)
rescue LoadError
diff --git a/lib/uri.rb b/lib/uri.rb
index fab3b94d16..09c4f5fbcf 100644
--- a/lib/uri.rb
+++ b/lib/uri.rb
@@ -6,7 +6,7 @@
# License::
# Copyright (c) 2001 akira yamada <akira@ruby-lang.org>
# You can redistribute it and/or modify it under the same term as Ruby.
-# Revision:: $Id: uri.rb,v 1.8.2.2 2004/07/17 13:07:46 akira Exp $
+# Revision:: $Id$
#
# See URI for documentation
#
diff --git a/lib/uri/common.rb b/lib/uri/common.rb
index 9f58cdf918..f74f0eb2e1 100644
--- a/lib/uri/common.rb
+++ b/lib/uri/common.rb
@@ -1,7 +1,7 @@
# = uri/common.rb
#
# Author:: Akira Yamada <akira@ruby-lang.org>
-# Revision:: $Id: common.rb,v 1.11.2.7 2005/06/24 04:15:20 akira Exp $
+# Revision:: $Id$
# License::
# You can redistribute it and/or modify it under the same term as Ruby.
#
@@ -110,7 +110,7 @@ module URI
SERVER = "(?:#{USERINFO}@)?#{HOSTPORT}"
# reg_name = 1*( unreserved | escaped | "$" | "," |
# ";" | ":" | "@" | "&" | "=" | "+" )
- REG_NAME = "(?:[#{UNRESERVED}$,;:@&=+]|#{ESCAPED})+"
+ REG_NAME = "(?:[#{UNRESERVED}$,;+@&=+]|#{ESCAPED})+"
# authority = server | reg_name
AUTHORITY = "(?:#{SERVER}|#{REG_NAME})"
@@ -261,6 +261,7 @@ module URI
# +unsafe+::
# Regexp that matches all symbols that must be replaced with codes.
# By default uses <tt>REGEXP::UNSAFE</tt>.
+ # When this argument is a String, it represents a character set.
#
# == Description
#
@@ -277,10 +278,13 @@ module URI
# p URI.unescape(enc_uri)
# # => "http://example.com/?a=\t\r"
#
+ # p URI.escape("@?@!", "!?")
+ # # => "@%3F@%21"
+ #
def escape(str, unsafe = UNSAFE)
unless unsafe.kind_of?(Regexp)
# perhaps unsafe is String object
- unsafe = Regexp.new(Regexp.quote(unsafe), false, 'N')
+ unsafe = Regexp.new("[#{Regexp.quote(unsafe)}]", false, 'N')
end
str.gsub(unsafe) do |us|
tmp = ''
@@ -542,7 +546,7 @@ module URI
# require "uri"
#
# URI.extract("text here http://foo.example.org/bla and here mailto:test@example.com and here also.")
- # # => ["http://foo.example.org/bla", "mailto:test@example.com"]
+ # # => ["http://foo.example.com/bla", "mailto:test@example.com"]
#
def self.extract(str, schemes = nil, &block)
if block_given?
diff --git a/lib/uri/ftp.rb b/lib/uri/ftp.rb
index 08f128f23f..26109e4d27 100644
--- a/lib/uri/ftp.rb
+++ b/lib/uri/ftp.rb
@@ -3,7 +3,7 @@
#
# Author:: Akira Yamada <akira@ruby-lang.org>
# License:: You can redistribute it and/or modify it under the same term as Ruby.
-# Revision:: $Id: ftp.rb,v 1.3.2.1 2004/03/24 12:20:32 gsinclair Exp $
+# Revision:: $Id$
#
require 'uri/generic'
diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb
index 1bc90cb890..2b66adeb93 100644
--- a/lib/uri/generic.rb
+++ b/lib/uri/generic.rb
@@ -3,7 +3,7 @@
#
# Author:: Akira Yamada <akira@ruby-lang.org>
# License:: You can redistribute it and/or modify it under the same term as Ruby.
-# Revision:: $Id: generic.rb,v 1.13.2.5 2005/06/24 04:15:20 akira Exp $
+# Revision:: $Id$
#
require 'uri/common'
@@ -12,6 +12,7 @@ module URI
#
# Base class for all URI classes.
+ # Implements generic URI syntax as per RFC 2396.
#
class Generic
include URI
@@ -303,19 +304,19 @@ module URI
end
check_userinfo(*userinfo)
set_userinfo(*userinfo)
- userinfo
+ # returns userinfo
end
def user=(user)
check_user(user)
set_user(user)
- user
+ # returns user
end
def password=(password)
check_password(password)
set_password(password)
- password
+ # returns password
end
def set_userinfo(user, password = nil)
@@ -336,8 +337,8 @@ module URI
protected :set_user
def set_password(v)
- set_userinfo(@user, v)
- v
+ @password = v
+ # returns v
end
protected :set_password
@@ -355,7 +356,9 @@ module URI
private :escape_userpass
def userinfo
- if !@password
+ if @user.nil?
+ nil
+ elsif @password.nil?
@user
else
@user + ':' + @password
@@ -1100,9 +1103,8 @@ module URI
end
end
- @@to_s = Kernel.instance_method(:to_s)
def inspect
- @@to_s.bind(self).call.sub!(/>\z/) {" URL:#{self}>"}
+ sprintf("#<%s:%#0x URL:%s>", self.class.to_s, self.object_id, self.to_s)
end
def coerce(oth)
diff --git a/lib/uri/http.rb b/lib/uri/http.rb
index 651658b918..87eb8893f2 100644
--- a/lib/uri/http.rb
+++ b/lib/uri/http.rb
@@ -3,7 +3,7 @@
#
# Author:: Akira Yamada <akira@ruby-lang.org>
# License:: You can redistribute it and/or modify it under the same term as Ruby.
-# Revision:: $Id: http.rb,v 1.2.2.1 2004/03/24 12:20:32 gsinclair Exp $
+# Revision:: $Id$
#
require 'uri/generic'
@@ -11,7 +11,12 @@ require 'uri/generic'
module URI
#
- # RFC1738 section 3.3.
+ # The syntax of HTTP URIs is defined in RFC1738 section 3.3.
+ #
+ # Note that the Ruby URI library allows HTTP URLs containing usernames and
+ # passwords. This is not legal as per the RFC, but used to be
+ # supported in Internet Explorer 5 and 6, before the MS04-004 security
+ # update. See <URL:http://support.microsoft.com/kb/834489>.
#
class HTTP < Generic
DEFAULT_PORT = 80
@@ -27,9 +32,27 @@ module URI
#
# == Description
#
- # Create a new URI::HTTP object from components of URI::HTTP with
- # check. It is scheme, userinfo, host, port, path, query and
- # fragment. It provided by an Array of a Hash.
+ # Create a new URI::HTTP object from components, with syntax checking.
+ #
+ # The components accepted are userinfo, host, port, path, query and
+ # fragment.
+ #
+ # The components should be provided either as an Array, or as a Hash
+ # with keys formed by preceding the component names with a colon.
+ #
+ # If an Array is used, the components must be passed in the order
+ # [userinfo, host, port, path, query, fragment].
+ #
+ # Example:
+ #
+ # newuri = URI::HTTP.build({:host => 'www.example.com',
+ # :path> => '/foo/bar'})
+ #
+ # newuri = URI::HTTP.build([nil, "www.example.com", nil, "/path",
+ # "query", 'fragment'])
+ #
+ # Currently, if passed userinfo components this method generates
+ # invalid HTTP URIs as per RFC 1738.
#
def self.build(args)
tmp = Util::make_components_hash(self, args)
@@ -39,8 +62,17 @@ module URI
#
# == Description
#
- # Create a new URI::HTTP object from ``generic'' components with no
- # check.
+ # Create a new URI::HTTP object from generic URI components as per
+ # RFC 2396. No HTTP-specific syntax checking (as per RFC 1738) is
+ # performed.
+ #
+ # Arguments are +scheme+, +userinfo+, +host+, +port+, +registry+, +path+,
+ # +opaque+, +query+ and +fragment+, in that order.
+ #
+ # Example:
+ #
+ # uri = URI::HTTP.new(['http', nil, "www.example.com", nil, "/path",
+ # "query", 'fragment'])
#
def initialize(*arg)
super(*arg)
@@ -49,7 +81,10 @@ module URI
#
# == Description
#
- # Returns: path + '?' + query
+ # Returns the full path for an HTTP request, as required by Net::HTTP::Get.
+ #
+ # If the URI contains a query, the full path is URI#path + '?' + URI#query.
+ # Otherwise, the path is simply URI#path.
#
def request_uri
r = path_query
diff --git a/lib/uri/https.rb b/lib/uri/https.rb
index 1ee1e67a24..9761636304 100644
--- a/lib/uri/https.rb
+++ b/lib/uri/https.rb
@@ -3,12 +3,16 @@
#
# Author:: Akira Yamada <akira@ruby-lang.org>
# License:: You can redistribute it and/or modify it under the same term as Ruby.
-# Revision:: $Id: https.rb,v 1.2.2.1 2004/03/24 12:20:32 gsinclair Exp $
+# Revision:: $Id$
#
require 'uri/http'
module URI
+
+ # The default port for HTTPS URIs is 443, and the scheme is 'https:' rather
+ # than 'http:'. Other than that, HTTPS URIs are identical to HTTP URIs;
+ # see URI::HTTP.
class HTTPS < HTTP
DEFAULT_PORT = 443
end
diff --git a/lib/uri/ldap.rb b/lib/uri/ldap.rb
index f033b2c307..163d2cda24 100644
--- a/lib/uri/ldap.rb
+++ b/lib/uri/ldap.rb
@@ -7,7 +7,7 @@
# License::
# URI::LDAP is copyrighted free software by Takaaki Tateishi and Akira Yamada.
# You can redistribute it and/or modify it under the same term as Ruby.
-# Revision:: $Id: ldap.rb,v 1.3.2.2 2004/07/17 13:07:46 akira Exp $
+# Revision:: $Id$
#
require 'uri/generic'
diff --git a/lib/uri/mailto.rb b/lib/uri/mailto.rb
index f4f9d02736..44f04f2dd5 100644
--- a/lib/uri/mailto.rb
+++ b/lib/uri/mailto.rb
@@ -3,7 +3,7 @@
#
# Author:: Akira Yamada <akira@ruby-lang.org>
# License:: You can redistribute it and/or modify it under the same term as Ruby.
-# Revision:: $Id: mailto.rb,v 1.6.2.2 2004/05/13 04:03:33 akira Exp $
+# Revision:: $Id$
#
require 'uri/generic'
@@ -61,11 +61,29 @@ module URI
#
# == Description
#
- # Creates a new URI::MailTo object from components of URI::MailTo
- # with check. It is to and headers. It provided by an Array of a
- # Hash. You can provide headers as String like
- # "subject=subscribe&cc=addr" or Array like [["subject",
- # "subscribe"], ["cc", "addr"]]
+ # Creates a new URI::MailTo object from components, with syntax checking.
+ #
+ # Components can be provided as an Array or Hash. If an Array is used,
+ # the components must be supplied as [to, headers].
+ #
+ # If a Hash is used, the keys are the component names preceded by colons.
+ #
+ # The headers can be supplied as a pre-encoded string, such as
+ # "subject=subscribe&cc=address", or as an Array of Arrays like
+ # [['subject', 'subscribe'], ['cc', 'address']]
+ #
+ # Examples:
+ #
+ # require 'uri'
+ #
+ # m1 = URI::MailTo.build(['joe@example.com', 'subject=Ruby'])
+ # puts m1.to_s -> mailto:joe@example.com?subject=Ruby
+ #
+ # m2 = URI::MailTo.build(['john@example.com', [['Subject', 'Ruby'], ['Cc', 'jack@example.com']]])
+ # puts m2.to_s -> mailto:john@example.com?Subject=Ruby&Cc=jack@example.com
+ #
+ # m3 = URI::MailTo.build({:to => 'listman@example.com', :headers => [['subject', 'subscribe']]})
+ # puts m3.to_s -> mailto:listman@example.com?subject=subscribe
#
def self.build(args)
tmp = Util::make_components_hash(self, args)
@@ -104,9 +122,11 @@ module URI
#
# == Description
#
- # Creates a new URI::MailTo object from ``generic'' components with
- # no check. Because, this method is usually called from URI::parse
- # and the method checks validity of each components.
+ # Creates a new URI::MailTo object from generic URL components with
+ # no syntax checking.
+ #
+ # This method is usually called from URI::parse, which checks
+ # the validity of each component.
#
def initialize(*arg)
super(*arg)
@@ -128,7 +148,11 @@ module URI
"unrecognised opaque part for mailtoURL: #{@opaque}"
end
end
+
+ # The primary e-mail address of the URL, as a String
attr_reader :to
+
+ # E-mail headers set by the URL, as an Array of Arrays
attr_reader :headers
def check_to(v)
@@ -203,8 +227,11 @@ module URI
''
end
end
+
+ # Returns the RFC822 e-mail text equivalent of the URL, as a String.
+ #
+ # Example:
#
- # == Usage
# require 'uri'
#
# uri = URI.parse("mailto:ruby-list@ruby-lang.org?Subject=subscribe&cc=myaddr")
diff --git a/lib/weakref.rb b/lib/weakref.rb
index 7d43f71264..591819c948 100644
--- a/lib/weakref.rb
+++ b/lib/weakref.rb
@@ -48,18 +48,7 @@ class WeakRef<Delegator
# Create a new WeakRef from +orig+.
def initialize(orig)
super
- @__id = orig.__id__
- ObjectSpace.define_finalizer orig, @@final
- ObjectSpace.define_finalizer self, @@final
- __old_status = Thread.critical
- begin
- Thread.critical = true
- @@id_map[@__id] = [] unless @@id_map[@__id]
- ensure
- Thread.critical = __old_status
- end
- @@id_map[@__id].push self.__id__
- @@id_rev_map[self.__id__] = @__id
+ __setobj__(orig)
end
# Return the object this WeakRef references. Raises RefError if the object
@@ -76,6 +65,23 @@ class WeakRef<Delegator
end
end
+ def __setobj__(obj)
+ @__id = obj.__id__
+ __old_status = Thread.critical
+ begin
+ Thread.critical = true
+ unless @@id_rev_map.key?(self)
+ ObjectSpace.define_finalizer obj, @@final
+ ObjectSpace.define_finalizer self, @@final
+ end
+ @@id_map[@__id] = [] unless @@id_map[@__id]
+ ensure
+ Thread.critical = __old_status
+ end
+ @@id_map[@__id].push self.__id__
+ @@id_rev_map[self.__id__] = @__id
+ end
+
# Returns true if the referenced object still exists, and false if it has
# been garbage collected.
def weakref_alive?
diff --git a/lib/webrick/cgi.rb b/lib/webrick/cgi.rb
index c6d5acea31..ff5f7a6102 100644
--- a/lib/webrick/cgi.rb
+++ b/lib/webrick/cgi.rb
@@ -5,7 +5,7 @@
# Copyright (c) 2003 Internet Programming with Ruby writers. All rights
# reserved.
#
-# $Id: cgi.rb,v 1.4.2.9 2005/09/28 06:16:59 gotoyuzo Exp $
+# $Id$
require "webrick/httprequest"
require "webrick/httpresponse"
diff --git a/lib/webrick/cookie.rb b/lib/webrick/cookie.rb
index b9663dc791..814e6645a3 100644
--- a/lib/webrick/cookie.rb
+++ b/lib/webrick/cookie.rb
@@ -100,5 +100,11 @@ module WEBrick
}
return cookie
end
+
+ def self.parse_set_cookies(str)
+ return str.split(/,(?=[^;,]*=)|,$/).collect{|c|
+ parse_set_cookie(c)
+ }
+ end
end
end
diff --git a/lib/webrick/httpservlet/abstract.rb b/lib/webrick/httpservlet/abstract.rb
index 5375c4622d..03861e8fc7 100644
--- a/lib/webrick/httpservlet/abstract.rb
+++ b/lib/webrick/httpservlet/abstract.rb
@@ -58,7 +58,7 @@ module WEBrick
def redirect_to_directory_uri(req, res)
if req.path[-1] != ?/
- location = WEBrick::HTTPUtils.escape_path(req.path + "/")
+ location = req.path + "/"
if req.query_string && req.query_string.size > 0
location << "?" << req.query_string
end
diff --git a/lib/webrick/httpservlet/cgi_runner.rb b/lib/webrick/httpservlet/cgi_runner.rb
index 006abd458e..1069a68d58 100644
--- a/lib/webrick/httpservlet/cgi_runner.rb
+++ b/lib/webrick/httpservlet/cgi_runner.rb
@@ -39,9 +39,7 @@ dir = File::dirname(ENV["SCRIPT_FILENAME"])
Dir::chdir dir
if interpreter = ARGV[0]
- argv = ARGV.dup
- argv << ENV["SCRIPT_FILENAME"]
- exec(*argv)
+ exec(interpreter, ENV["SCRIPT_FILENAME"])
# NOTREACHED
end
exec ENV["SCRIPT_FILENAME"]
diff --git a/lib/webrick/httpservlet/filehandler.rb b/lib/webrick/httpservlet/filehandler.rb
index 24f59d7142..410cc6f9a9 100644
--- a/lib/webrick/httpservlet/filehandler.rb
+++ b/lib/webrick/httpservlet/filehandler.rb
@@ -163,7 +163,6 @@ module WEBrick
end
end
end
- prevent_directory_traversal(req, res)
super(req, res)
end
@@ -199,38 +198,10 @@ module WEBrick
private
- def trailing_pathsep?(path)
- # check for trailing path separator:
- # File.dirname("/aaaa/bbbb/") #=> "/aaaa")
- # File.dirname("/aaaa/bbbb/x") #=> "/aaaa/bbbb")
- # File.dirname("/aaaa/bbbb") #=> "/aaaa")
- # File.dirname("/aaaa/bbbbx") #=> "/aaaa")
- return File.dirname(path) != File.dirname(path+"x")
- end
-
- def prevent_directory_traversal(req, res)
- # Preventing directory traversal on Windows platforms;
- # Backslashes (0x5c) in path_info are not interpreted as special
- # character in URI notation. So the value of path_info should be
- # normalize before accessing to the filesystem.
-
- if trailing_pathsep?(req.path_info)
- # File.expand_path removes the trailing path separator.
- # Adding a character is a workaround to save it.
- # File.expand_path("/aaa/") #=> "/aaa"
- # File.expand_path("/aaa/" + "x") #=> "/aaa/x"
- expanded = File.expand_path(req.path_info + "x")
- expanded.chop! # remove trailing "x"
- else
- expanded = File.expand_path(req.path_info)
- end
- req.path_info = expanded
- end
-
def exec_handler(req, res)
raise HTTPStatus::NotFound, "`#{req.path}' not found" unless @root
if set_filename(req, res)
- handler = get_handler(req, res)
+ handler = get_handler(req)
call_callback(:HandlerCallback, req, res)
h = handler.get_instance(@config, res.filename)
h.service(req, res)
@@ -240,13 +211,9 @@ module WEBrick
return false
end
- def get_handler(req, res)
- suffix1 = (/\.(\w+)\z/ =~ res.filename) && $1.downcase
- if /\.(\w+)\.([\w\-]+)\z/ =~ res.filename
- if @options[:AcceptableLanguages].include?($2.downcase)
- suffix2 = $1.downcase
- end
- end
+ def get_handler(req)
+ suffix1 = (/\.(\w+)$/ =~ req.script_name) && $1.downcase
+ suffix2 = (/\.(\w+)\.[\w\-]+$/ =~ req.script_name) && $1.downcase
handler_table = @options[:HandlerTable]
return handler_table[suffix1] || handler_table[suffix2] ||
HandlerTable[suffix1] || HandlerTable[suffix2] ||
@@ -259,13 +226,15 @@ module WEBrick
path_info.unshift("") # dummy for checking @root dir
while base = path_info.first
+ check_filename(req, res, base)
break if base == "/"
- break unless File.directory?(File.expand_path(res.filename + base))
+ break unless File.directory?(res.filename + base)
shift_path_info(req, res, path_info)
call_callback(:DirectoryCallback, req, res)
end
if base = path_info.first
+ check_filename(req, res, base)
if base == "/"
if file = search_index_file(req, res)
shift_path_info(req, res, path_info, file)
@@ -286,10 +255,12 @@ module WEBrick
end
def check_filename(req, res, name)
- if nondisclosure_name?(name) || windows_ambiguous_name?(name)
- @logger.warn("the request refers nondisclosure name `#{name}'.")
- raise HTTPStatus::NotFound, "`#{req.path}' not found."
- end
+ @options[:NondisclosureName].each{|pattern|
+ if File.fnmatch("/#{pattern}", name)
+ @logger.warn("the request refers nondisclosure name `#{name}'.")
+ raise HTTPStatus::NotFound, "`#{req.path}' not found."
+ end
+ }
end
def shift_path_info(req, res, path_info, base=nil)
@@ -297,8 +268,7 @@ module WEBrick
base = base || tmp
req.path_info = path_info.join
req.script_name << base
- res.filename = File.expand_path(res.filename + base)
- check_filename(req, res, File.basename(res.filename))
+ res.filename << base
end
def search_index_file(req, res)
@@ -338,15 +308,9 @@ module WEBrick
end
end
- def windows_ambiguous_name?(name)
- return true if /[. ]+\z/ =~ name
- return true if /::\$DATA\z/ =~ name
- return false
- end
-
def nondisclosure_name?(name)
@options[:NondisclosureName].each{|pattern|
- if File.fnmatch(pattern, name, File::FNM_CASEFOLD)
+ if File.fnmatch(pattern, name)
return true
end
}
@@ -362,8 +326,7 @@ module WEBrick
list = Dir::entries(local_path).collect{|name|
next if name == "." || name == ".."
next if nondisclosure_name?(name)
- next if windows_ambiguous_name?(name)
- st = (File::stat(File.join(local_path, name)) rescue nil)
+ st = (File::stat(local_path + name) rescue nil)
if st.nil?
[ name, nil, -1 ]
elsif st.directory?
@@ -403,7 +366,7 @@ module WEBrick
res.body << "<A HREF=\"?S=#{d1}\">Size</A>\n"
res.body << "<HR>\n"
- list.unshift [ "..", File::mtime(local_path+"/.."), -1 ]
+ list.unshift [ "..", File::mtime(local_path+".."), -1 ]
list.each{ |name, time, size|
if name == ".."
dname = "Parent Directory"
diff --git a/lib/webrick/ssl.rb b/lib/webrick/ssl.rb
index d9c032f6c9..03bfdf4aa0 100644
--- a/lib/webrick/ssl.rb
+++ b/lib/webrick/ssl.rb
@@ -3,7 +3,7 @@
#
# Copyright (c) 2003 GOTOU Yuuzou All rights reserved.
#
-# $Id: ssl.rb,v 1.2.2.1 2005/01/18 06:03:43 gotoyuzo Exp $
+# $Id$
require 'webrick'
require 'openssl'
diff --git a/lib/xmlrpc/base64.rb b/lib/xmlrpc/base64.rb
index a0050d895c..f9a21c703a 100644
--- a/lib/xmlrpc/base64.rb
+++ b/lib/xmlrpc/base64.rb
@@ -77,5 +77,5 @@ end # module XMLRPC
=begin
= History
- $Id: base64.rb,v 1.1 2003/07/19 10:05:54 matz Exp $
+ $Id$
=end
diff --git a/lib/xmlrpc/client.rb b/lib/xmlrpc/client.rb
index b3682f6b09..10f547b632 100644
--- a/lib/xmlrpc/client.rb
+++ b/lib/xmlrpc/client.rb
@@ -268,7 +268,7 @@ Note: Inherited methods from class (({Object})) cannot be used as XML-RPC names,
= History
- $Id: client.rb,v 1.2.2.2 2005/09/20 08:51:02 matz Exp $
+ $Id$
=end
@@ -530,9 +530,6 @@ module XMLRPC
}
else
# reuse the HTTP object for each call => connection alive is possible
- # we must start connection explicitely first time so that http.request
- # does not assume that we don't want keepalive
- @http.start if not @http.started?
# post request
resp = @http.post2(@path, request, header)
@@ -552,16 +549,16 @@ module XMLRPC
ct = parse_content_type(resp["Content-Type"]).first
if ct != "text/xml"
if ct == "text/html"
- raise "Wrong content-type (received '#{ct}' but expected 'text/xml'): \n#{data}"
+ raise "Wrong content-type: \n#{data}"
else
- raise "Wrong content-type (received '#{ct}' but expected 'text/xml')"
+ raise "Wrong content-type"
end
end
expected = resp["Content-Length"] || "<unknown>"
if data.nil? or data.size == 0
raise "Wrong size. Was #{data.size}, should be #{expected}"
- elsif expected.to_i != data.size and resp["Transfer-Encoding"].nil?
+ elsif expected != "<unknown>" and expected.to_i != data.size and resp["Transfer-Encoding"].nil?
raise "Wrong size. Was #{data.size}, should be #{expected}"
end
diff --git a/lib/xmlrpc/config.rb b/lib/xmlrpc/config.rb
index 230fe14a7c..c4d2c41aac 100644
--- a/lib/xmlrpc/config.rb
+++ b/lib/xmlrpc/config.rb
@@ -1,5 +1,5 @@
#
-# $Id: config.rb,v 1.1 2003/07/19 10:05:54 matz Exp $
+# $Id$
# Configuration file for XML-RPC for Ruby
#
diff --git a/lib/xmlrpc/create.rb b/lib/xmlrpc/create.rb
index ce7a401fa5..b5c94254a4 100644
--- a/lib/xmlrpc/create.rb
+++ b/lib/xmlrpc/create.rb
@@ -3,7 +3,7 @@
#
# Copyright (C) 2001, 2002, 2003 by Michael Neumann (mneumann@ntecs.de)
#
-# $Id: create.rb,v 1.1.2.2 2006/06/20 23:43:42 matz Exp $
+# $Id$
#
require "date"
@@ -241,7 +241,7 @@ module XMLRPC
@writer.ele("data", *a)
)
- when Time, Date
+ when Time, Date, ::DateTime
@writer.tag("dateTime.iso8601", param.strftime("%Y%m%dT%H:%M:%S"))
when XMLRPC::DateTime
diff --git a/lib/xmlrpc/datetime.rb b/lib/xmlrpc/datetime.rb
index 198b2cda1e..298263fe8a 100644
--- a/lib/xmlrpc/datetime.rb
+++ b/lib/xmlrpc/datetime.rb
@@ -138,5 +138,5 @@ end # module XMLRPC
=begin
= History
- $Id: datetime.rb,v 1.1.2.1 2005/06/24 20:27:42 mneumann Exp $
+ $Id$
=end
diff --git a/lib/xmlrpc/httpserver.rb b/lib/xmlrpc/httpserver.rb
index e4aa99f46a..9afb5fd5ec 100644
--- a/lib/xmlrpc/httpserver.rb
+++ b/lib/xmlrpc/httpserver.rb
@@ -4,7 +4,7 @@
#
# Copyright (C) 2001, 2002, 2003 by Michael Neumann (mneumann@ntecs.de)
#
-# $Id: httpserver.rb,v 1.1 2003/07/19 10:05:54 matz Exp $
+# $Id$
#
diff --git a/lib/xmlrpc/marshal.rb b/lib/xmlrpc/marshal.rb
index a4aa620da1..26510124c2 100644
--- a/lib/xmlrpc/marshal.rb
+++ b/lib/xmlrpc/marshal.rb
@@ -3,7 +3,7 @@
#
# Copyright (C) 2001, 2002, 2003 by Michael Neumann (mneumann@ntecs.de)
#
-# $Id: marshal.rb,v 1.1 2003/07/19 10:05:54 matz Exp $
+# $Id$
#
require "xmlrpc/parser"
diff --git a/lib/xmlrpc/parser.rb b/lib/xmlrpc/parser.rb
index 7490f34e84..d27d7c3827 100644
--- a/lib/xmlrpc/parser.rb
+++ b/lib/xmlrpc/parser.rb
@@ -3,7 +3,7 @@
#
# Copyright (C) 2001, 2002, 2003 by Michael Neumann (mneumann@ntecs.de)
#
-# $Id: parser.rb,v 1.3.2.3 2005/06/24 20:27:42 mneumann Exp $
+# $Id$
#
@@ -92,7 +92,7 @@ module XMLRPC
if $7
ofs = $8.to_i*3600 + $9.to_i*60
ofs = -ofs if $7=='+'
- utc = Time.utc(*a) + ofs
+ utc = Time.utc(a.reverse) + ofs
a = [ utc.year, utc.month, utc.day, utc.hour, utc.min, utc.sec ]
end
XMLRPC::DateTime.new(*a)
@@ -106,7 +106,7 @@ module XMLRPC
if $7
ofs = $8.to_i*3600 + $9.to_i*60
ofs = -ofs if $7=='+'
- utc = Time.utc(*a) + ofs
+ utc = Time.utc(a.reverse) + ofs
a = [ utc.year, utc.month, utc.day, utc.hour, utc.min, utc.sec ]
end
XMLRPC::DateTime.new(*a)
diff --git a/lib/xmlrpc/server.rb b/lib/xmlrpc/server.rb
index 5166d7619f..59a5869408 100644
--- a/lib/xmlrpc/server.rb
+++ b/lib/xmlrpc/server.rb
@@ -639,11 +639,11 @@ class Server < WEBrickServlet
def serve
if RUBY_PLATFORM =~ /mingw|mswin32/
- signals = [1]
+ signal = 1
else
- signals = %w[INT TERM HUP]
+ signal = "HUP"
end
- signals.each { |signal| trap(signal) { @server.shutdown } }
+ trap(signal) { @server.shutdown }
@server.start
end
@@ -775,6 +775,6 @@ end # module XMLRPC
=begin
= History
- $Id: server.rb,v 1.2.2.6 2005/10/04 19:46:35 gotoyuzo Exp $
+ $Id$
=end
diff --git a/lib/xmlrpc/utils.rb b/lib/xmlrpc/utils.rb
index 2b51083c78..85c6bba372 100644
--- a/lib/xmlrpc/utils.rb
+++ b/lib/xmlrpc/utils.rb
@@ -6,7 +6,7 @@
#
# Copyright (C) 2001, 2002, 2003 by Michael Neumann (mneumann@ntecs.de)
#
-# $Id: utils.rb,v 1.2.2.1 2005/06/24 20:27:42 mneumann Exp $
+# $Id$
#
module XMLRPC
@@ -157,7 +157,7 @@ module XMLRPC
module ParseContentType
def parse_content_type(str)
a, *b = str.split(";")
- return a.strip.downcase, *b
+ return a.strip, *b
end
end
diff --git a/lib/yaml.rb b/lib/yaml.rb
index ce3aced1e6..fe8335c8f0 100644
--- a/lib/yaml.rb
+++ b/lib/yaml.rb
@@ -1,5 +1,5 @@
# -*- mode: ruby; ruby-indent-level: 4; tab-width: 4 -*- vim: sw=4 ts=4
-# $Id: yaml.rb,v 1.9.2.12 2005/12/26 08:18:31 matz Exp $
+# $Id$
#
# = yaml.rb: top-level module with methods for loading and parsing YAML documents
#
diff --git a/lib/yaml/basenode.rb b/lib/yaml/basenode.rb
index 5439903f42..d24f6172e9 100644
--- a/lib/yaml/basenode.rb
+++ b/lib/yaml/basenode.rb
@@ -184,7 +184,7 @@ module YAML
#
def []( *key )
if Hash === @value
- v = @value.detect { |k,| k.transform == key.first }
+ v = @value.detect { |k,v| k.transform == key.first }
v[1] if v
elsif Array === @value
@value.[]( *key )
diff --git a/lib/yaml/tag.rb b/lib/yaml/tag.rb
index 098aca5cfd..0fb6bef9a0 100644
--- a/lib/yaml/tag.rb
+++ b/lib/yaml/tag.rb
@@ -1,5 +1,5 @@
# -*- mode: ruby; ruby-indent-level: 4; tab-width: 4 -*- vim: sw=4 ts=4
-# $Id: tag.rb,v 1.1.2.3 2006/08/22 09:43:47 matz Exp $
+# $Id$
#
# = yaml/tag.rb: methods for associating a taguri to a class.
#
diff --git a/lib/yaml/types.rb b/lib/yaml/types.rb
index 7897db48e0..05113f216d 100644
--- a/lib/yaml/types.rb
+++ b/lib/yaml/types.rb
@@ -10,6 +10,7 @@ module YAML
#
class PrivateType
def self.tag_subclasses?; false; end
+ attr_accessor :type_id, :value
verbose, $VERBOSE = $VERBOSE, nil
def initialize( type, val )
@type_id = type; @value = val
@@ -27,6 +28,7 @@ module YAML
#
class DomainType
def self.tag_subclasses?; false; end
+ attr_accessor :domain, :type_id, :value
verbose, $VERBOSE = $VERBOSE, nil
def initialize( domain, type, val )
@domain = domain; @type_id = type; @value = val
diff --git a/main.c b/main.c
index 0ec86ed79b..bee9a4b15b 100644
--- a/main.c
+++ b/main.c
@@ -2,8 +2,8 @@
main.c -
- $Author: eban $
- $Date: 2004/10/31 16:06:57 $
+ $Author$
+ $Date$
created at: Fri Aug 19 13:19:58 JST 1994
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -41,8 +41,11 @@ main(argc, argv, envp)
argc = ccommand(&argv);
#endif
- ruby_init();
- ruby_options(argc, argv);
- ruby_run();
+ {
+ RUBY_INIT_STACK
+ ruby_init();
+ ruby_options(argc, argv);
+ ruby_run();
+ }
return 0;
}
diff --git a/marshal.c b/marshal.c
index 39f9cc7478..51771fdf52 100644
--- a/marshal.c
+++ b/marshal.c
@@ -2,8 +2,8 @@
marshal.c -
- $Author: akr $
- $Date: 2005/12/14 03:04:14 $
+ $Author$
+ $Date$
created at: Thu Apr 27 16:30:01 JST 1995
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -373,8 +373,8 @@ w_extended(klass, arg, check)
{
char *path;
- if (check && FL_TEST(klass, FL_SINGLETON)) {
- if (RCLASS(klass)->m_tbl->num_entries ||
+ if (FL_TEST(klass, FL_SINGLETON)) {
+ if (check && RCLASS(klass)->m_tbl->num_entries ||
(RCLASS(klass)->iv_tbl && RCLASS(klass)->iv_tbl->num_entries > 1)) {
rb_raise(rb_eTypeError, "singleton can't be dumped");
}
@@ -468,7 +468,7 @@ w_object(obj, arg, limit)
return;
}
- if ((ivtbl = rb_generic_ivar_table(obj)) != 0) {
+ if (ivtbl = rb_generic_ivar_table(obj)) {
w_byte(TYPE_IVAR, arg);
}
if (obj == Qnil) {
@@ -502,7 +502,7 @@ w_object(obj, arg, limit)
st_add_direct(arg->data, obj, arg->data->num_entries);
if (rb_respond_to(obj, s_mdump)) {
- volatile VALUE v;
+ VALUE v;
v = rb_funcall(obj, s_mdump, 0, 0);
w_class(TYPE_USRMARSHAL, obj, arg, Qfalse);
@@ -652,13 +652,13 @@ w_object(obj, arg, limit)
{
VALUE v;
+ w_class(TYPE_DATA, obj, arg, Qtrue);
if (!rb_respond_to(obj, s_dump_data)) {
rb_raise(rb_eTypeError,
"no marshal_dump is defined for class %s",
rb_obj_classname(obj));
}
v = rb_funcall(obj, s_dump_data, 0);
- w_class(TYPE_DATA, obj, arg, Qtrue);
w_object(v, arg, limit);
}
break;
@@ -873,7 +873,7 @@ r_bytes0(len, arg)
if (len == 0) return rb_str_new(0, 0);
if (TYPE(arg->src) == T_STRING) {
- if (RSTRING(arg->src)->len - arg->offset >= len) {
+ if (RSTRING(arg->src)->len > arg->offset) {
str = rb_str_new(RSTRING(arg->src)->ptr+arg->offset, len);
arg->offset += len;
}
diff --git a/math.c b/math.c
index d145549c69..60dd0b7204 100644
--- a/math.c
+++ b/math.c
@@ -2,8 +2,8 @@
math.c -
- $Author: matz $
- $Date: 2006/07/27 16:14:03 $
+ $Author$
+ $Date$
created at: Tue Jan 25 14:12:56 JST 1994
Copyright (C) 1993-2003 Yukihiro Matsumoto
diff --git a/mdoc2man.rb b/mdoc2man.rb
index 1b291bc53a..910b2e5745 100755
--- a/mdoc2man.rb
+++ b/mdoc2man.rb
@@ -39,7 +39,7 @@
### OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
### SUCH DAMAGE.
###
-### $Id: mdoc2man.rb,v 1.4 2003/01/20 12:10:40 knu Exp $
+### $Id$
###
class Mdoc2Man
diff --git a/misc/inf-ruby.el b/misc/inf-ruby.el
index 632c80ce5b..0a7eb76bda 100644
--- a/misc/inf-ruby.el
+++ b/misc/inf-ruby.el
@@ -1,8 +1,8 @@
;;; -*-Emacs-Lisp-*-
;;;
-;;; $Id: inf-ruby.el,v 1.6.2.1 2004/07/27 07:51:28 matz Exp $
-;;; $Author: matz $
-;;; $Date: 2004/07/27 07:51:28 $
+;;; $Id$
+;;; $Author$
+;;; $Date$
;;;
;;; Inferior Ruby Mode - ruby process in a buffer.
;;; adapted from cmuscheme.el
@@ -34,7 +34,7 @@
;;;
;;; HISTORY
;;; senda - 8 Apr 1998: Created.
-;;; $Log: inf-ruby.el,v $
+;;; $Log$
;;; Revision 1.7 2004/07/27 08:11:36 matz
;;; * eval.c (rb_eval): copy on write for argument local variable
;;; assignment.
@@ -46,7 +46,7 @@
;;;
;;; * object.c (Init_Object): "===" calls rb_obj_equal() directly.
;;; [ruby-list:39937]
-;;;
+;;;
;;; Revision 1.6 2002/09/07 14:35:46 nobu
;;; * misc/inf-ruby.el (inferior-ruby-error-regexp-alist): regexp
;;; alist for error message from ruby.
diff --git a/misc/ruby-mode.el b/misc/ruby-mode.el
index 3fe99017d9..25c6b3008d 100644
--- a/misc/ruby-mode.el
+++ b/misc/ruby-mode.el
@@ -1,12 +1,12 @@
;;;
;;; ruby-mode.el -
;;;
-;;; $Author: matz $
-;;; $Date: 2007/01/24 14:46:10 $
+;;; $Author$
+;;; $Date$
;;; created at: Fri Feb 4 14:49:13 JST 1994
;;;
-(defconst ruby-mode-revision "$Revision: 1.74.2.14.2.1 $")
+(defconst ruby-mode-revision "$Revision$")
(defconst ruby-mode-version
(progn
@@ -255,7 +255,7 @@ The variable ruby-indent-level controls the amount of indentation.
(make-local-variable 'add-log-current-defun-function)
(setq add-log-current-defun-function 'ruby-add-log-current-method)
- (run-mode-hooks 'ruby-mode-hook))
+ (run-hooks 'ruby-mode-hook))
(defun ruby-current-indentation ()
(save-excursion
@@ -383,6 +383,8 @@ The variable ruby-indent-level controls the amount of indentation.
(t
(setq in-string (point))
(goto-char end))))
+ ((looking-at "/=")
+ (goto-char pnt))
((looking-at "/")
(cond
((and (not (eobp)) (ruby-expr-beg 'expr-re))
@@ -523,7 +525,7 @@ The variable ruby-indent-level controls the amount of indentation.
((looking-at "<<")
(cond
((and (ruby-expr-beg 'heredoc)
- (looking-at "<<\\(-\\)?\\(\\([\"'`]\\)\\([^\n]+?\\)\\3\\|\\sw+\\)"))
+ (looking-at "<<\\(-\\)?\\(\\([\"'`]\\)\\([^\n]+?\\)\\3\\|\\(?:\\sw\\|\\s_\\)+\\)"))
(setq re (regexp-quote (or (match-string 4) (match-string 2))))
(if (match-beginning 1) (setq re (concat "\\s *" re)))
(let* ((id-end (goto-char (match-end 0)))
diff --git a/missing.h b/missing.h
index 340cb0762e..3f56078259 100644
--- a/missing.h
+++ b/missing.h
@@ -3,8 +3,8 @@
missing.h - prototype for *.c in ./missing, and
for missing timeval struct
- $Author: nobu $