summaryrefslogtreecommitdiff
path: root/test/ruby/test_object.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2022-02-17 20:12:38 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2022-02-17 20:12:38 +0900
commitc8b414b3345564d975445b25d9bcb9e2604f636d (patch)
tree69745c50c58664cfb80d26070e92f3ed077d8378 /test/ruby/test_object.rb
parentdfe7faa6b60464c184fede59f227341f6c57cc97 (diff)
Reuse `-v` option result as `target_platform`
Backticks method invokes `/bin/sh` when the command contains quotes, and `sh` clears some environment variables set in runruby.rb to search the built shared library.
Diffstat (limited to 'test/ruby/test_object.rb')
0 files changed, 0 insertions, 0 deletions
ass='mode'>-rw-r--r--README.EXT97
-rw-r--r--README.EXT.ja6
-rw-r--r--README.ja6
-rw-r--r--array.c1174
-rw-r--r--bcc32/Makefile.sub87
-rwxr-xr-xbcc32/configure.bat92
-rw-r--r--[-rwxr-xr-x]bcc32/mkexports.rb2
-rw-r--r--bcc32/setup.mak78
-rw-r--r--bignum.c413
-rw-r--r--bin/irb4
-rw-r--r--bin/rdoc2
-rw-r--r--class.c15
-rw-r--r--common.mk261
-rw-r--r--compar.c4
-rw-r--r--configure.in393
-rw-r--r--defines.h32
-rw-r--r--dir.c1346
-rw-r--r--dln.c49
-rw-r--r--dln.h4
-rw-r--r--doc/NEWS (renamed from doc/NEWS-1.8.0)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.c1250
-rw-r--r--enumerator.c450
-rw-r--r--env.h4
-rw-r--r--error.c35
-rw-r--r--eval.c1496
-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/bigdecimal/bigdecimal.c123
-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.rb4
-rw-r--r--ext/curses/curses.c3
-rw-r--r--ext/dbm/dbm.c6
-rw-r--r--ext/dbm/extconf.rb60
-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.c698
-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.rb50
-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.c18
-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/ptr.c4
-rw-r--r--ext/dl/sym.c3
-rw-r--r--ext/enumerator/.cvsignore (renamed from ext/digest/bubblebabble/.cvsignore)1
-rw-r--r--ext/enumerator/enumerator.c298
-rw-r--r--ext/enumerator/enumerator.txt102
-rw-r--r--ext/enumerator/extconf.rb2
-rw-r--r--ext/etc/etc.c6
-rw-r--r--ext/extmk.rb99
-rw-r--r--ext/fcntl/fcntl.c2
-rw-r--r--ext/gdbm/gdbm.c444
-rw-r--r--ext/iconv/iconv.c68
-rw-r--r--ext/io/wait/extconf.rb2
-rw-r--r--ext/io/wait/wait.c8
-rw-r--r--ext/nkf/lib/kconv.rb10
-rw-r--r--ext/nkf/nkf-utf8/nkf.c1109
-rw-r--r--ext/nkf/nkf-utf8/utf8tbl.c2
-rw-r--r--ext/nkf/nkf.c14
-rw-r--r--ext/openssl/extconf.rb11
-rw-r--r--ext/openssl/lib/net/ftptls.rb4
-rw-r--r--ext/openssl/lib/net/telnets.rb4
-rw-r--r--ext/openssl/lib/openssl.rb5
-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.rb37
-rw-r--r--ext/openssl/lib/openssl/digest.rb18
-rw-r--r--ext/openssl/lib/openssl/pkcs7.rb25
-rw-r--r--ext/openssl/lib/openssl/ssl.rb94
-rw-r--r--ext/openssl/lib/openssl/x509.rb4
-rw-r--r--ext/openssl/openssl_missing.c14
-rw-r--r--ext/openssl/openssl_missing.h62
-rw-r--r--ext/openssl/ossl.c34
-rw-r--r--ext/openssl/ossl.h43
-rw-r--r--ext/openssl/ossl_asn1.c66
-rw-r--r--ext/openssl/ossl_asn1.h2
-rw-r--r--ext/openssl/ossl_bio.c25
-rw-r--r--ext/openssl/ossl_bio.h2
-rw-r--r--ext/openssl/ossl_bn.c169
-rw-r--r--ext/openssl/ossl_bn.h7
-rw-r--r--ext/openssl/ossl_cipher.c251
-rw-r--r--ext/openssl/ossl_cipher.h3
-rw-r--r--ext/openssl/ossl_config.c14
-rw-r--r--ext/openssl/ossl_config.h2
-rw-r--r--ext/openssl/ossl_digest.c201
-rw-r--r--ext/openssl/ossl_digest.h3
-rw-r--r--ext/openssl/ossl_engine.c12
-rw-r--r--ext/openssl/ossl_engine.h2
-rw-r--r--ext/openssl/ossl_hmac.c74
-rw-r--r--ext/openssl/ossl_hmac.h2
-rw-r--r--ext/openssl/ossl_ns_spki.c15
-rw-r--r--ext/openssl/ossl_ns_spki.h2
-rw-r--r--ext/openssl/ossl_ocsp.c28
-rw-r--r--ext/openssl/ossl_ocsp.h2
-rw-r--r--ext/openssl/ossl_pkcs12.c78
-rw-r--r--ext/openssl/ossl_pkcs12.h3
-rw-r--r--ext/openssl/ossl_pkcs5.c96
-rw-r--r--ext/openssl/ossl_pkcs7.c66
-rw-r--r--ext/openssl/ossl_pkcs7.h3
-rw-r--r--ext/openssl/ossl_pkey.c30
-rw-r--r--ext/openssl/ossl_pkey.h23
-rw-r--r--ext/openssl/ossl_pkey_dh.c108
-rw-r--r--ext/openssl/ossl_pkey_dsa.c99
-rw-r--r--ext/openssl/ossl_pkey_ec.c1582
-rw-r--r--ext/openssl/ossl_pkey_rsa.c126
-rw-r--r--ext/openssl/ossl_rand.c94
-rw-r--r--ext/openssl/ossl_rand.h2
-rw-r--r--ext/openssl/ossl_ssl.c651
-rw-r--r--ext/openssl/ossl_ssl.h17
-rw-r--r--ext/openssl/ossl_ssl_session.c298
-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.c38
-rw-r--r--ext/openssl/ossl_x509cert.c111
-rw-r--r--ext/openssl/ossl_x509crl.c18
-rw-r--r--ext/openssl/ossl_x509ext.c26
-rw-r--r--ext/openssl/ossl_x509name.c44
-rw-r--r--ext/openssl/ossl_x509req.c12
-rw-r--r--ext/openssl/ossl_x509revoked.c10
-rw-r--r--ext/openssl/ossl_x509store.c19
-rw-r--r--ext/openssl/ruby_missing.h29
-rw-r--r--ext/pty/expect_sample.rb15
-rw-r--r--ext/pty/pty.c98
-rw-r--r--ext/purelib.rb10
-rw-r--r--ext/racc/cparse/cparse.c4
-rw-r--r--ext/racc/cparse/extconf.rb2
-rw-r--r--ext/readline/readline.c6
-rw-r--r--ext/sdbm/_sdbm.c4
-rw-r--r--ext/sdbm/init.c4
-rw-r--r--ext/socket/addrinfo.h5
-rw-r--r--ext/socket/extconf.rb8
-rw-r--r--ext/socket/socket.c171
-rw-r--r--ext/socket/sockport.h4
-rw-r--r--ext/stringio/README4
-rw-r--r--ext/stringio/stringio.c92
-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.c19
-rw-r--r--ext/syck/syck.c4
-rw-r--r--ext/syck/syck.h4
-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.c5
-rw-r--r--ext/syslog/syslog.txt7
-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.c1182
-rw-r--r--ext/tk/ChangeLog.tkextlib66
-rw-r--r--ext/tk/MANUAL_tcltklib.eng24
-rw-r--r--ext/tk/MANUAL_tcltklib.eucj22
-rw-r--r--ext/tk/README.1st13
-rw-r--r--ext/tk/README.tcltklib25
-rw-r--r--ext/tk/extconf.rb167
-rw-r--r--ext/tk/lib/multi-tk.rb200
-rw-r--r--ext/tk/lib/tcltk.rb2
-rw-r--r--ext/tk/lib/tk.rb1230
-rw-r--r--ext/tk/lib/tk/after.rb2
-rw-r--r--ext/tk/lib/tk/autoload.rb358
-rw-r--r--ext/tk/lib/tk/bindtag.rb83
-rw-r--r--ext/tk/lib/tk/button.rb5
-rw-r--r--ext/tk/lib/tk/canvas.rb60
-rw-r--r--ext/tk/lib/tk/canvastag.rb117
-rw-r--r--ext/tk/lib/tk/checkbutton.rb9
-rw-r--r--ext/tk/lib/tk/composite.rb70
-rw-r--r--ext/tk/lib/tk/encodedstr.rb84
-rw-r--r--ext/tk/lib/tk/entry.rb6
-rw-r--r--ext/tk/lib/tk/event.rb62
-rw-r--r--ext/tk/lib/tk/font.rb742
-rw-r--r--ext/tk/lib/tk/frame.rb5
-rw-r--r--ext/tk/lib/tk/grid.rb49
-rw-r--r--ext/tk/lib/tk/image.rb62
-rw-r--r--ext/tk/lib/tk/itemconfig.rb177
-rw-r--r--ext/tk/lib/tk/itemfont.rb33
-rw-r--r--ext/tk/lib/tk/label.rb5
-rw-r--r--ext/tk/lib/tk/labelframe.rb8
-rw-r--r--ext/tk/lib/tk/listbox.rb5
-rw-r--r--ext/tk/lib/tk/macpkg.rb9
-rw-r--r--ext/tk/lib/tk/menu.rb91
-rw-r--r--ext/tk/lib/tk/menubar.rb2
-rw-r--r--ext/tk/lib/tk/menuspec.rb26
-rw-r--r--ext/tk/lib/tk/message.rb5
-rw-r--r--ext/tk/lib/tk/msgcat.rb6
-rw-r--r--ext/tk/lib/tk/namespace.rb149
-rw-r--r--ext/tk/lib/tk/optiondb.rb16
-rw-r--r--ext/tk/lib/tk/pack.rb17
-rw-r--r--ext/tk/lib/tk/package.rb4
-rw-r--r--ext/tk/lib/tk/palette.rb2
-rw-r--r--ext/tk/lib/tk/panedwindow.rb32
-rw-r--r--ext/tk/lib/tk/radiobutton.rb9
-rw-r--r--ext/tk/lib/tk/root.rb37
-rw-r--r--ext/tk/lib/tk/scale.rb33
-rw-r--r--ext/tk/lib/tk/scrollable.rb11
-rw-r--r--ext/tk/lib/tk/scrollbar.rb65
-rw-r--r--ext/tk/lib/tk/scrollbox.rb7
-rw-r--r--ext/tk/lib/tk/spinbox.rb24
-rw-r--r--ext/tk/lib/tk/text.rb178
-rw-r--r--ext/tk/lib/tk/textimage.rb14
-rw-r--r--ext/tk/lib/tk/textmark.rb102
-rw-r--r--ext/tk/lib/tk/texttag.rb113
-rw-r--r--ext/tk/lib/tk/textwindow.rb13
-rw-r--r--ext/tk/lib/tk/timer.rb57
-rw-r--r--ext/tk/lib/tk/toplevel.rb13
-rw-r--r--ext/tk/lib/tk/ttk_selector.rb76
-rw-r--r--ext/tk/lib/tk/txtwin_abst.rb2
-rw-r--r--ext/tk/lib/tk/validation.rb25
-rw-r--r--ext/tk/lib/tk/variable.rb488
-rw-r--r--ext/tk/lib/tk/virtevent.rb77
-rw-r--r--ext/tk/lib/tk/winpkg.rb18
-rw-r--r--ext/tk/lib/tk/wm.rb476
-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.rb8
-rw-r--r--ext/tk/lib/tkextlib/blt/bitmap.rb21
-rw-r--r--ext/tk/lib/tkextlib/blt/busy.rb2
-rw-r--r--ext/tk/lib/tkextlib/blt/component.rb452
-rw-r--r--ext/tk/lib/tkextlib/blt/container.rb20
-rw-r--r--ext/tk/lib/tkextlib/blt/dragdrop.rb54
-rw-r--r--ext/tk/lib/tkextlib/blt/eps.rb2
-rw-r--r--ext/tk/lib/tkextlib/blt/htext.rb1
-rw-r--r--ext/tk/lib/tkextlib/blt/table.rb119
-rw-r--r--ext/tk/lib/tkextlib/blt/tabset.rb81
-rw-r--r--ext/tk/lib/tkextlib/blt/ted.rb9
-rw-r--r--ext/tk/lib/tkextlib/blt/tile/button.rb2
-rw-r--r--ext/tk/lib/tkextlib/blt/tile/checkbutton.rb4
-rw-r--r--ext/tk/lib/tkextlib/blt/tile/frame.rb2
-rw-r--r--ext/tk/lib/tkextlib/blt/tile/label.rb2
-rw-r--r--ext/tk/lib/tkextlib/blt/tile/radiobutton.rb4
-rw-r--r--ext/tk/lib/tkextlib/blt/tile/scrollbar.rb2
-rw-r--r--ext/tk/lib/tkextlib/blt/tile/toplevel.rb2
-rw-r--r--ext/tk/lib/tkextlib/blt/tree.rb341
-rw-r--r--ext/tk/lib/tkextlib/blt/treeview.rb228
-rw-r--r--ext/tk/lib/tkextlib/blt/unix_dnd.rb16
-rw-r--r--ext/tk/lib/tkextlib/blt/vector.rb49
-rw-r--r--ext/tk/lib/tkextlib/blt/watch.rb47
-rw-r--r--ext/tk/lib/tkextlib/bwidget/button.rb2
-rw-r--r--ext/tk/lib/tkextlib/bwidget/buttonbox.rb20
-rw-r--r--ext/tk/lib/tkextlib/bwidget/combobox.rb8
-rw-r--r--ext/tk/lib/tkextlib/bwidget/dialog.rb33
-rw-r--r--ext/tk/lib/tkextlib/bwidget/dynamichelp.rb7
-rw-r--r--ext/tk/lib/tkextlib/bwidget/entry.rb2
-rw-r--r--ext/tk/lib/tkextlib/bwidget/label.rb2
-rw-r--r--ext/tk/lib/tkextlib/bwidget/labelentry.rb2
-rw-r--r--ext/tk/lib/tkextlib/bwidget/labelframe.rb8
-rw-r--r--ext/tk/lib/tkextlib/bwidget/listbox.rb37
-rw-r--r--ext/tk/lib/tkextlib/bwidget/mainframe.rb48
-rw-r--r--ext/tk/lib/tkextlib/bwidget/messagedlg.rb16
-rw-r--r--ext/tk/lib/tkextlib/bwidget/notebook.rb24
-rw-r--r--ext/tk/lib/tkextlib/bwidget/pagesmanager.rb16
-rw-r--r--ext/tk/lib/tkextlib/bwidget/panedwindow.rb8
-rw-r--r--ext/tk/lib/tkextlib/bwidget/panelframe.rb8
-rw-r--r--ext/tk/lib/tkextlib/bwidget/progressdlg.rb4
-rw-r--r--ext/tk/lib/tkextlib/bwidget/scrollableframe.rb8
-rw-r--r--ext/tk/lib/tkextlib/bwidget/scrolledwindow.rb8
-rw-r--r--ext/tk/lib/tkextlib/bwidget/selectcolor.rb28
-rw-r--r--ext/tk/lib/tkextlib/bwidget/selectfont.rb7
-rw-r--r--ext/tk/lib/tkextlib/bwidget/spinbox.rb2
-rw-r--r--ext/tk/lib/tkextlib/bwidget/statusbar.rb8
-rw-r--r--ext/tk/lib/tkextlib/bwidget/titleframe.rb8
-rw-r--r--ext/tk/lib/tkextlib/bwidget/tree.rb37
-rw-r--r--ext/tk/lib/tkextlib/bwidget/widget.rb20
-rw-r--r--ext/tk/lib/tkextlib/itcl/incr_tcl.rb12
-rw-r--r--ext/tk/lib/tkextlib/itk/incr_tk.rb44
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/buttonbox.rb5
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/calendar.rb19
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/checkbox.rb23
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/dialogshell.rb5
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/entryfield.rb19
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/hierarchy.rb58
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/menubar.rb5
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/messagebox.rb5
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/notebook.rb16
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/panedwindow.rb5
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/radiobox.rb16
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb12
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb2
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb30
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/selectionbox.rb2
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb2
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/spinner.rb19
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb21
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/tabset.rb49
-rw-r--r--ext/tk/lib/tkextlib/tcllib/autoscroll.rb2
-rw-r--r--ext/tk/lib/tkextlib/tcllib/ctext.rb2
-rw-r--r--ext/tk/lib/tkextlib/tcllib/datefield.rb2
-rw-r--r--ext/tk/lib/tkextlib/tcllib/getstring.rb5
-rw-r--r--ext/tk/lib/tkextlib/tcllib/ico.rb6
-rw-r--r--ext/tk/lib/tkextlib/tcllib/ip_entry.rb2
-rw-r--r--ext/tk/lib/tkextlib/tcllib/plotchart.rb77
-rw-r--r--ext/tk/lib/tkextlib/tcllib/swaplist.rb5
-rw-r--r--ext/tk/lib/tkextlib/tcllib/tablelist.rb2
-rw-r--r--ext/tk/lib/tkextlib/tcllib/tablelist_core.rb16
-rw-r--r--ext/tk/lib/tkextlib/tcllib/tkpiechart.rb14
-rw-r--r--ext/tk/lib/tkextlib/tile.rb260
-rw-r--r--ext/tk/lib/tkextlib/tile/dialog.rb16
-rw-r--r--ext/tk/lib/tkextlib/tile/sizegrip.rb29
-rw-r--r--ext/tk/lib/tkextlib/tile/style.rb241
-rw-r--r--ext/tk/lib/tkextlib/tile/tbutton.rb7
-rw-r--r--ext/tk/lib/tkextlib/tile/tcheckbutton.rb8
-rw-r--r--ext/tk/lib/tkextlib/tile/tcombobox.rb9
-rw-r--r--ext/tk/lib/tkextlib/tile/tentry.rb12
-rw-r--r--ext/tk/lib/tkextlib/tile/tframe.rb7
-rw-r--r--ext/tk/lib/tkextlib/tile/tlabel.rb7
-rw-r--r--ext/tk/lib/tkextlib/tile/tlabelframe.rb8
-rw-r--r--ext/tk/lib/tkextlib/tile/tmenubutton.rb12
-rw-r--r--ext/tk/lib/tkextlib/tile/tnotebook.rb41
-rw-r--r--ext/tk/lib/tkextlib/tile/tpaned.rb55
-rw-r--r--ext/tk/lib/tkextlib/tile/tprogressbar.rb3
-rw-r--r--ext/tk/lib/tkextlib/tile/tradiobutton.rb8
-rw-r--r--ext/tk/lib/tkextlib/tile/treeview.rb1212
-rw-r--r--ext/tk/lib/tkextlib/tile/tscale.rb7
-rw-r--r--ext/tk/lib/tkextlib/tile/tscrollbar.rb28
-rw-r--r--ext/tk/lib/tkextlib/tile/tseparator.rb3
-rw-r--r--ext/tk/lib/tkextlib/tkDND/shape.rb32
-rw-r--r--ext/tk/lib/tkextlib/tkDND/tkdnd.rb18
-rw-r--r--ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb17
-rw-r--r--ext/tk/lib/tkextlib/tktable/tktable.rb188
-rw-r--r--ext/tk/lib/tkextlib/tktrans/tktrans.rb4
-rw-r--r--ext/tk/lib/tkextlib/treectrl/tktreectrl.rb300
-rw-r--r--ext/tk/lib/tkextlib/version.rb6
-rw-r--r--ext/tk/lib/tkextlib/vu/pie.rb77
-rw-r--r--ext/tk/lib/tkextlib/vu/spinbox.rb2
-rw-r--r--ext/tk/lib/tkextlib/winico/winico.rb57
-rw-r--r--ext/tk/sample/binstr_usage.rb12
-rw-r--r--ext/tk/sample/demos-en/anilabel.rb10
-rw-r--r--ext/tk/sample/demos-en/aniwave.rb9
-rw-r--r--ext/tk/sample/demos-en/arrow.rb26
-rw-r--r--ext/tk/sample/demos-en/bind.rb33
-rw-r--r--ext/tk/sample/demos-en/bitmap.rb10
-rw-r--r--ext/tk/sample/demos-en/button.rb2
-rw-r--r--ext/tk/sample/demos-en/check.rb14
-rw-r--r--ext/tk/sample/demos-en/check2.rb14
-rw-r--r--ext/tk/sample/demos-en/clrpick.rb22
-rw-r--r--ext/tk/sample/demos-en/colors.rb18
-rw-r--r--ext/tk/sample/demos-en/combo.rb96
-rw-r--r--ext/tk/sample/demos-en/cscroll.rb14
-rw-r--r--ext/tk/sample/demos-en/ctext.rb53
-rw-r--r--ext/tk/sample/demos-en/entry1.rb12
-rw-r--r--ext/tk/sample/demos-en/entry2.rb8
-rw-r--r--ext/tk/sample/demos-en/entry3.rb50
-rw-r--r--ext/tk/sample/demos-en/filebox.rb17
-rw-r--r--ext/tk/sample/demos-en/floor.rb14
-rw-r--r--ext/tk/sample/demos-en/floor2.rb14
-rw-r--r--ext/tk/sample/demos-en/form.rb8
-rw-r--r--ext/tk/sample/demos-en/goldberg.rb23
-rw-r--r--ext/tk/sample/demos-en/hello6
-rw-r--r--ext/tk/sample/demos-en/hscale.rb29
-rw-r--r--ext/tk/sample/demos-en/icon.rb20
-rw-r--r--ext/tk/sample/demos-en/image1.rb13
-rw-r--r--ext/tk/sample/demos-en/image2.rb22
-rw-r--r--ext/tk/sample/demos-en/image3.rb29
-rw-r--r--ext/tk/sample/demos-en/items.rb17
-rw-r--r--ext/tk/sample/demos-en/knightstour.rb271
-rw-r--r--ext/tk/sample/demos-en/label.rb13
-rw-r--r--ext/tk/sample/demos-en/labelframe.rb8
-rw-r--r--ext/tk/sample/demos-en/mclist.rb117
-rw-r--r--ext/tk/sample/demos-en/menu.rb12
-rw-r--r--ext/tk/sample/demos-en/menu84.rb8
-rw-r--r--ext/tk/sample/demos-en/menubu.rb10
-rw-r--r--ext/tk/sample/demos-en/msgbox.rb10
-rw-r--r--ext/tk/sample/demos-en/msgbox2.rb91
-rw-r--r--ext/tk/sample/demos-en/paned1.rb14
-rw-r--r--ext/tk/sample/demos-en/paned2.rb8
-rw-r--r--ext/tk/sample/demos-en/patch_1.1c193
-rw-r--r--ext/tk/sample/demos-en/pendulum.rb43
-rw-r--r--ext/tk/sample/demos-en/plot.rb8
-rw-r--r--ext/tk/sample/demos-en/puzzle.rb32
-rw-r--r--ext/tk/sample/demos-en/radio.rb12
-rw-r--r--ext/tk/sample/demos-en/radio2.rb17
-rw-r--r--ext/tk/sample/demos-en/radio3.rb19
-rw-r--r--ext/tk/sample/demos-en/rolodex-j323
-rw-r--r--ext/tk/sample/demos-en/ruler.rb8
-rw-r--r--ext/tk/sample/demos-en/sayings.rb8
-rw-r--r--ext/tk/sample/demos-en/search.rb19
-rw-r--r--ext/tk/sample/demos-en/spin.rb12
-rw-r--r--ext/tk/sample/demos-en/states.rb8
-rw-r--r--ext/tk/sample/demos-en/style.rb42
-rw-r--r--ext/tk/sample/demos-en/text.rb8
-rw-r--r--ext/tk/sample/demos-en/textpeer.rb76
-rw-r--r--ext/tk/sample/demos-en/toolbar.rb130
-rw-r--r--ext/tk/sample/demos-en/tree.rb119
-rw-r--r--ext/tk/sample/demos-en/ttkbut.rb139
-rw-r--r--ext/tk/sample/demos-en/ttkmenu.rb85
-rw-r--r--ext/tk/sample/demos-en/ttknote.rb89
-rw-r--r--ext/tk/sample/demos-en/ttkpane.rb213
-rw-r--r--ext/tk/sample/demos-en/ttkprogress.rb66
-rw-r--r--ext/tk/sample/demos-en/twind.rb14
-rw-r--r--ext/tk/sample/demos-en/twind2.rb6
-rw-r--r--ext/tk/sample/demos-en/unicodeout.rb14
-rw-r--r--ext/tk/sample/demos-en/vscale.rb29
-rw-r--r--ext/tk/sample/demos-en/widget232
-rw-r--r--ext/tk/sample/demos-jp/anilabel.rb11
-rw-r--r--ext/tk/sample/demos-jp/aniwave.rb10
-rw-r--r--ext/tk/sample/demos-jp/arrow.rb27
-rw-r--r--ext/tk/sample/demos-jp/bind.rb34
-rw-r--r--ext/tk/sample/demos-jp/bitmap.rb11
-rw-r--r--ext/tk/sample/demos-jp/button.rb4
-rw-r--r--ext/tk/sample/demos-jp/check.rb15
-rw-r--r--ext/tk/sample/demos-jp/check2.rb15
-rw-r--r--ext/tk/sample/demos-jp/clrpick.rb21
-rw-r--r--ext/tk/sample/demos-jp/colors.rb19
-rw-r--r--ext/tk/sample/demos-jp/combo.rb98
-rw-r--r--ext/tk/sample/demos-jp/cscroll.rb15
-rw-r--r--ext/tk/sample/demos-jp/ctext.rb54
-rw-r--r--ext/tk/sample/demos-jp/dialog1.rb1
-rw-r--r--ext/tk/sample/demos-jp/dialog2.rb1
-rw-r--r--ext/tk/sample/demos-jp/entry1.rb13
-rw-r--r--ext/tk/sample/demos-jp/entry2.rb9
-rw-r--r--ext/tk/sample/demos-jp/entry3.rb49
-rw-r--r--ext/tk/sample/demos-jp/filebox.rb18
-rw-r--r--ext/tk/sample/demos-jp/floor.rb15
-rw-r--r--ext/tk/sample/demos-jp/floor2.rb15
-rw-r--r--ext/tk/sample/demos-jp/form.rb9
-rw-r--r--ext/tk/sample/demos-jp/goldberg.rb24
-rw-r--r--ext/tk/sample/demos-jp/hello1
-rw-r--r--ext/tk/sample/demos-jp/hscale.rb29
-rw-r--r--ext/tk/sample/demos-jp/icon.rb21
-rw-r--r--ext/tk/sample/demos-jp/image1.rb14
-rw-r--r--ext/tk/sample/demos-jp/image2.rb24
-rw-r--r--ext/tk/sample/demos-jp/image3.rb18
-rw-r--r--ext/tk/sample/demos-jp/items.rb18
-rw-r--r--ext/tk/sample/demos-jp/ixset21
-rw-r--r--ext/tk/sample/demos-jp/knightstour.rb273
-rw-r--r--ext/tk/sample/demos-jp/label.rb14
-rw-r--r--ext/tk/sample/demos-jp/labelframe.rb10
-rw-r--r--ext/tk/sample/demos-jp/mclist.rb121
-rw-r--r--ext/tk/sample/demos-jp/menu.rb15
-rw-r--r--ext/tk/sample/demos-jp/menu84.rb9
-rw-r--r--ext/tk/sample/demos-jp/menu8x.rb13
-rw-r--r--ext/tk/sample/demos-jp/menubu.rb11
-rw-r--r--ext/tk/sample/demos-jp/msgbox.rb15
-rw-r--r--ext/tk/sample/demos-jp/msgbox2.rb90
-rw-r--r--ext/tk/sample/demos-jp/paned1.rb16
-rw-r--r--ext/tk/sample/demos-jp/paned2.rb10
-rw-r--r--ext/tk/sample/demos-jp/pendulum.rb44
-rw-r--r--ext/tk/sample/demos-jp/plot.rb15
-rw-r--r--ext/tk/sample/demos-jp/puzzle.rb33
-rw-r--r--ext/tk/sample/demos-jp/radio.rb13
-rw-r--r--ext/tk/sample/demos-jp/radio2.rb19
-rw-r--r--ext/tk/sample/demos-jp/radio3.rb21
-rw-r--r--ext/tk/sample/demos-jp/rolodex-j1
-rw-r--r--ext/tk/sample/demos-jp/ruler.rb9
-rw-r--r--ext/tk/sample/demos-jp/sayings.rb9
-rw-r--r--ext/tk/sample/demos-jp/search.rb20
-rw-r--r--ext/tk/sample/demos-jp/spin.rb16
-rw-r--r--ext/tk/sample/demos-jp/states.rb9
-rw-r--r--ext/tk/sample/demos-jp/style.rb42
-rw-r--r--ext/tk/sample/demos-jp/tcolor1
-rw-r--r--ext/tk/sample/demos-jp/text.rb9
-rw-r--r--ext/tk/sample/demos-jp/textpeer.rb82
-rw-r--r--ext/tk/sample/demos-jp/toolbar.rb136
-rw-r--r--ext/tk/sample/demos-jp/tree.rb120
-rw-r--r--ext/tk/sample/demos-jp/ttkbut.rb145
-rw-r--r--ext/tk/sample/demos-jp/ttkmenu.rb91
-rw-r--r--ext/tk/sample/demos-jp/ttknote.rb97
-rw-r--r--ext/tk/sample/demos-jp/ttkpane.rb216
-rw-r--r--ext/tk/sample/demos-jp/ttkprogress.rb71
-rw-r--r--ext/tk/sample/demos-jp/twind.rb13
-rw-r--r--ext/tk/sample/demos-jp/twind2.rb7
-rw-r--r--ext/tk/sample/demos-jp/unicodeout.rb16
-rw-r--r--ext/tk/sample/demos-jp/vscale.rb30
-rw-r--r--ext/tk/sample/demos-jp/widget278
-rw-r--r--ext/tk/sample/editable_listbox.rb69
-rw-r--r--ext/tk/sample/encstr_usage.rb5
-rw-r--r--ext/tk/sample/figmemo_sample.rb456
-rw-r--r--ext/tk/sample/images/teapot.ppm49
-rw-r--r--ext/tk/sample/irbtkw.rbw146
-rw-r--r--ext/tk/sample/tcltklib/sample2.rb2
-rw-r--r--ext/tk/sample/tkextlib/tile/demo.rb39
-rw-r--r--ext/tk/sample/tkextlib/tile/repeater.tcl2
-rw-r--r--ext/tk/sample/tkextlib/tile/themes/blue/pkgIndex.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.rb30
-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/tkextlib/treectrl/demo.rb7
-rw-r--r--ext/tk/sample/tkextlib/vu/canvSticker2.rb12
-rw-r--r--ext/tk/sample/tkrttimer.rb13
-rw-r--r--ext/tk/sample/tksleep_sample.rb29
-rw-r--r--ext/tk/sample/tktextio.rb557
-rw-r--r--ext/tk/sample/ttk_wrapper.rb154
-rw-r--r--ext/tk/stubs.c78
-rw-r--r--ext/tk/tcltklib.c2692
-rw-r--r--ext/tk/tkutil/extconf.rb11
-rw-r--r--ext/tk/tkutil/tkutil.c710
-rw-r--r--ext/win32ole/extconf.rb4
-rw-r--r--ext/win32ole/sample/olegen.rb4
-rw-r--r--ext/win32ole/tests/testOLEEVENT.rb91
-rw-r--r--ext/win32ole/tests/testWIN32OLE.rb3
-rw-r--r--ext/win32ole/tests/test_win32ole_event.rb133
-rw-r--r--ext/win32ole/tests/testall.rb1
-rw-r--r--ext/win32ole/win32ole.c191
-rw-r--r--ext/zlib/doc/zlib.rd2
-rw-r--r--ext/zlib/extconf.rb2
-rw-r--r--ext/zlib/zlib.c15
-rw-r--r--file.c160
-rw-r--r--gc.c380
-rw-r--r--hash.c544
-rw-r--r--ia64.s33
-rw-r--r--inits.c6
-rw-r--r--[-rwxr-xr-x]instruby.rb373
-rw-r--r--intern.h45
-rw-r--r--io.c388
-rw-r--r--keywords2
-rw-r--r--lex.c2
-rw-r--r--lib/.document3
-rw-r--r--lib/README4
-rw-r--r--lib/abbrev.rb2
-rw-r--r--lib/base64.rb2
-rw-r--r--lib/benchmark.rb4
-rw-r--r--lib/cgi.rb39
-rw-r--r--lib/cgi/session.rb28
-rw-r--r--lib/cgi/session/pstore.rb2
-rw-r--r--lib/complex.rb32
-rw-r--r--lib/csv.rb2
-rw-r--r--lib/date.rb996
-rw-r--r--lib/date/format.rb1595
-rw-r--r--lib/delegate.rb27
-rw-r--r--lib/drb/acl.rb2
-rw-r--r--lib/drb/drb.rb26
-rw-r--r--lib/drb/extservm.rb41
-rw-r--r--lib/drb/unix.rb2
-rw-r--r--lib/erb.rb306
-rw-r--r--lib/fileutils.rb133
-rw-r--r--lib/forwardable.rb6
-rw-r--r--lib/generator.rb40
-rw-r--r--lib/getopts.rb6
-rw-r--r--lib/ipaddr.rb148
-rw-r--r--lib/irb.rb6
-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.rb6
-rw-r--r--lib/irb/frame.rb4
-rw-r--r--lib/irb/help.rb6
-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.rb6
-rw-r--r--lib/irb/output-method.rb6
-rw-r--r--lib/irb/ruby-lex.rb8
-rw-r--r--lib/irb/ruby-token.rb4
-rw-r--r--lib/irb/slex.rb8
-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.rb8
-rw-r--r--lib/matrix.rb20
-rw-r--r--lib/mkmf.rb437
-rw-r--r--lib/net/ftp.rb23
-rw-r--r--lib/net/http.rb4
-rw-r--r--lib/net/https.rb8
-rw-r--r--lib/net/imap.rb41
-rw-r--r--lib/net/pop.rb234
-rw-r--r--lib/net/protocol.rb6
-rw-r--r--lib/net/smtp.rb639
-rw-r--r--lib/net/telnet.rb9
-rw-r--r--lib/open-uri.rb2
-rw-r--r--lib/open3.rb45
-rw-r--r--lib/optparse.rb164
-rw-r--r--lib/parsearg.rb6
-rw-r--r--lib/parsedate.rb44
-rw-r--r--lib/ping.rb49
-rw-r--r--lib/pp.rb13
-rw-r--r--lib/prettyprint.rb12
-rw-r--r--lib/pstore.rb25
-rw-r--r--lib/rational.rb78
-rw-r--r--lib/rdoc/generators/ri_generator.rb2
-rw-r--r--lib/rdoc/options.rb13
-rw-r--r--lib/rdoc/parsers/parse_c.rb272
-rw-r--r--lib/rdoc/parsers/parse_f95.rb8
-rw-r--r--lib/rdoc/parsers/parse_rb.rb10
-rw-r--r--lib/rdoc/rdoc.rb54
-rw-r--r--lib/rdoc/ri/ri_formatter.rb4
-rw-r--r--lib/rdoc/ri/ri_options.rb34
-rw-r--r--lib/rdoc/ri/ri_paths.rb27
-rw-r--r--lib/resolv-replace.rb3
-rw-r--r--lib/resolv.rb1241
-rw-r--r--lib/rexml/attlistdecl.rb2
-rw-r--r--lib/rexml/attribute.rb38
-rw-r--r--lib/rexml/cdata.rb21
-rw-r--r--lib/rexml/comment.rb28
-rw-r--r--lib/rexml/doctype.rb27
-rw-r--r--lib/rexml/document.rb113
-rw-r--r--lib/rexml/element.rb2258
-rw-r--r--lib/rexml/encoding.rb31
-rw-r--r--lib/rexml/encodings/CP-1252.rb13
-rw-r--r--lib/rexml/encodings/ISO-8859-15.rb9
-rw-r--r--lib/rexml/encodings/UNILE.rb2
-rw-r--r--lib/rexml/encodings/UTF-16.rb3
-rw-r--r--lib/rexml/entity.rb7
-rw-r--r--lib/rexml/formatters/default.rb109
-rw-r--r--lib/rexml/formatters/pretty.rb138
-rw-r--r--lib/rexml/formatters/transitive.rb56
-rw-r--r--lib/rexml/functions.rb29
-rw-r--r--lib/rexml/instruction.rb4
-rw-r--r--lib/rexml/node.rb25
-rw-r--r--lib/rexml/parsers/baseparser.rb87
-rw-r--r--lib/rexml/parsers/sax2parser.rb8
-rw-r--r--lib/rexml/parsers/treeparser.rb9
-rw-r--r--lib/rexml/parsers/xpathparser.rb10
-rw-r--r--lib/rexml/rexml.rb13
-rw-r--r--lib/rexml/sax2listener.rb2
-rw-r--r--lib/rexml/source.rb378
-rw-r--r--lib/rexml/text.rb64
-rw-r--r--lib/rexml/undefinednamespaceexception.rb8
-rw-r--r--lib/rexml/xmldecl.rb11
-rw-r--r--lib/rexml/xpath.rb16
-rw-r--r--lib/rexml/xpath_parser.rb103
-rw-r--r--lib/rinda/ring.rb4
-rw-r--r--lib/rinda/tuplespace.rb100
-rw-r--r--lib/rss.rb7
-rw-r--r--lib/rss/0.9.rb23
-rw-r--r--lib/rss/1.0.rb13
-rw-r--r--lib/rss/2.0.rb2
-rw-r--r--lib/rss/atom.rb749
-rw-r--r--lib/rss/content.rb25
-rw-r--r--lib/rss/content/1.0.rb10
-rw-r--r--lib/rss/content/2.0.rb12
-rw-r--r--lib/rss/converter.rb8
-rw-r--r--lib/rss/dublincore.rb39
-rw-r--r--lib/rss/dublincore/1.0.rb13
-rw-r--r--lib/rss/dublincore/2.0.rb13
-rw-r--r--lib/rss/dublincore/atom.rb17
-rw-r--r--lib/rss/image.rb10
-rw-r--r--lib/rss/itunes.rb410
-rw-r--r--lib/rss/maker.rb25
-rw-r--r--lib/rss/maker/0.9.rb375
-rw-r--r--lib/rss/maker/1.0.rb332
-rw-r--r--lib/rss/maker/2.0.rb147
-rw-r--r--lib/rss/maker/atom.rb172
-rw-r--r--lib/rss/maker/base.rb844
-rw-r--r--lib/rss/maker/content.rb14
-rw-r--r--lib/rss/maker/dublincore.rb145
-rw-r--r--lib/rss/maker/entry.rb163
-rw-r--r--lib/rss/maker/feed.rb429
-rw-r--r--lib/rss/maker/image.rb116
-rw-r--r--lib/rss/maker/itunes.rb242
-rw-r--r--lib/rss/maker/slash.rb33
-rw-r--r--lib/rss/maker/syndication.rb13
-rw-r--r--lib/rss/maker/taxonomy.rb118
-rw-r--r--lib/rss/maker/trackback.rb115
-rw-r--r--lib/rss/parser.rb167
-rw-r--r--lib/rss/rss.rb735
-rw-r--r--lib/rss/slash.rb49
-rw-r--r--lib/rss/syndication.rb9
-rw-r--r--lib/rss/taxonomy.rb2
-rw-r--r--lib/rss/utils.rb78
-rw-r--r--lib/rss/xml-stylesheet.rb4
-rw-r--r--lib/rss/xml.rb71
-rw-r--r--lib/scanf.rb10
-rw-r--r--lib/securerandom.rb137
-rw-r--r--lib/set.rb65
-rw-r--r--lib/shell/builtin-command.rb4
-rw-r--r--lib/shell/command-processor.rb11
-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/shellwords.rb146
-rw-r--r--lib/singleton.rb61
-rw-r--r--lib/sync.rb6
-rw-r--r--lib/tempfile.rb28
-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.rb28
-rw-r--r--lib/tmpdir.rb108
-rw-r--r--lib/uri.rb3
-rw-r--r--lib/uri/common.rb10
-rw-r--r--lib/uri/ftp.rb88
-rw-r--r--lib/uri/generic.rb121
-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/ldaps.rb12
-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/httpproxy.rb2
-rw-r--r--lib/webrick/httprequest.rb2
-rw-r--r--lib/webrick/httpresponse.rb2
-rw-r--r--lib/webrick/httpservlet/cgihandler.rb4
-rw-r--r--lib/webrick/httputils.rb16
-rw-r--r--lib/webrick/ssl.rb2
-rw-r--r--lib/xmlrpc/base64.rb2
-rw-r--r--lib/xmlrpc/client.rb14
-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.rb2
-rw-r--r--lib/xmlrpc/server.rb2
-rw-r--r--lib/xmlrpc/utils.rb2
-rw-r--r--lib/yaml.rb2
-rw-r--r--lib/yaml/baseemitter.rb2
-rw-r--r--lib/yaml/encoding.rb6
-rw-r--r--lib/yaml/rubytypes.rb2
-rw-r--r--lib/yaml/store.rb20
-rw-r--r--lib/yaml/tag.rb2
-rw-r--r--main.c13
-rw-r--r--marshal.c158
-rw-r--r--math.c8
-rwxr-xr-xmdoc2man.rb2
-rw-r--r--misc/README3
-rw-r--r--misc/inf-ruby.el10
-rw-r--r--misc/rdebug.el136
-rw-r--r--misc/ruby-mode.el45
-rw-r--r--misc/ruby-style.el66
-rw-r--r--missing.h6
-rw-r--r--missing/acosh.c4
-rw-r--r--missing/crypt.c34
-rw-r--r--missing/flock.c5
-rw-r--r--missing/strtod.c2
-rw-r--r--missing/vsnprintf.c2
-rw-r--r--[-rwxr-xr-x]mkconfig.rb8
-rw-r--r--node.h120
-rw-r--r--numeric.c472
-rw-r--r--object.c221
-rw-r--r--pack.c40
-rw-r--r--parse.y221
-rw-r--r--prec.c4
-rw-r--r--process.c55
-rw-r--r--random.c32
-rw-r--r--range.c100
-rw-r--r--re.c176
-rw-r--r--re.h4
-rw-r--r--regex.c74
-rw-r--r--regex.h4
-rw-r--r--ruby.c104
-rw-r--r--ruby.h64
-rw-r--r--rubyio.h29
-rw-r--r--rubysig.h12
-rw-r--r--[-rwxr-xr-x]rubytest.rb0
-rwxr-xr-xrunruby.rb22
-rw-r--r--sample/README3
-rw-r--r--sample/biorhythm.rb4
-rw-r--r--sample/cal.rb84
-rw-r--r--sample/cbreak.rb4
-rw-r--r--sample/dualstack-httpd.rb2
-rw-r--r--sample/erb/erb4html.rb60
-rw-r--r--sample/eval.rb2
-rw-r--r--sample/from.rb2
-rw-r--r--sample/goodfriday.rb48
-rw-r--r--sample/openssl/c_rehash.rb4
-rw-r--r--sample/philos.rb2
-rw-r--r--sample/regx.rb2
-rwxr-xr-xsample/rss/blend.rb6
-rwxr-xr-xsample/rss/convert.rb2
-rw-r--r--[-rwxr-xr-x]sample/rss/list_description.rb13
-rwxr-xr-xsample/rss/re_read.rb10
-rw-r--r--[-rwxr-xr-x]sample/rss/rss_recent.rb20
-rw-r--r--sample/test.rb64
-rw-r--r--sample/time.rb16
-rw-r--r--signal.c145
-rw-r--r--sprintf.c43
-rw-r--r--string.c529
-rw-r--r--struct.c19
-rw-r--r--test/dbm/test_dbm.rb4
-rw-r--r--test/digest/test_digest.rb30
-rw-r--r--test/drb/drbtest.rb2
-rw-r--r--test/erb/hello.erb4
-rw-r--r--test/erb/test_erb.rb386
-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.rb8
-rw-r--r--test/iconv/test_basic.rb49
-rw-r--r--test/iconv/test_option.rb31
-rw-r--r--test/iconv/test_partial.rb41
-rw-r--r--test/iconv/utils.rb26
-rw-r--r--test/logger/test_logger.rb4
-rw-r--r--test/matrix/test_matrix.rb43
-rw-r--r--test/matrix/test_vector.rb43
-rw-r--r--test/net/http/test_https_proxy.rb9
-rw-r--r--test/net/imap/test_imap.rb11
-rw-r--r--test/net/pop/test_pop.rb132
-rw-r--r--test/openssl/test_ec.rb113
-rw-r--r--test/openssl/test_ssl.rb348
-rw-r--r--test/optparse/test_getopts.rb31
-rw-r--r--test/pathname/test_pathname.rb26
-rw-r--r--test/rdoc/parsers/test_parse_c.rb261
-rw-r--r--test/rexml/test_document.rb66
-rw-r--r--test/rinda/test_rinda.rb119
-rw-r--r--test/rss/dot.pngbin111 -> 0 bytes-rw-r--r--test/rss/rss-assertions.rb1894
-rw-r--r--test/rss/rss-testcase.rb208
-rw-r--r--test/rss/test_1.0.rb61
-rw-r--r--test/rss/test_2.0.rb28
-rw-r--r--test/rss/test_atom.rb681
-rw-r--r--test/rss/test_content.rb68
-rw-r--r--test/rss/test_dublincore.rb316
-rw-r--r--test/rss/test_image.rb49
-rw-r--r--test/rss/test_inherit.rb5
-rw-r--r--test/rss/test_itunes.rb347
-rw-r--r--test/rss/test_maker_0.9.rb147
-rw-r--r--test/rss/test_maker_1.0.rb205
-rw-r--r--test/rss/test_maker_2.0.rb56
-rw-r--r--test/rss/test_maker_atom_entry.rb367
-rw-r--r--test/rss/test_maker_atom_feed.rb389
-rw-r--r--test/rss/test_maker_content.rb13
-rw-r--r--test/rss/test_maker_dc.rb9
-rw-r--r--test/rss/test_maker_itunes.rb471
-rw-r--r--test/rss/test_maker_slash.rb37
-rw-r--r--test/rss/test_maker_sy.rb1
-rw-r--r--test/rss/test_maker_xml-stylesheet.rb8
-rw-r--r--test/rss/test_parser.rb26
-rw-r--r--test/rss/test_parser_1.0.rb10
-rw-r--r--test/rss/test_parser_atom_entry.rb163
-rw-r--r--test/rss/test_parser_atom_feed.rb276
-rw-r--r--test/rss/test_setup_maker_0.9.rb25
-rw-r--r--test/rss/test_setup_maker_1.0.rb26
-rw-r--r--test/rss/test_setup_maker_atom_entry.rb409
-rw-r--r--test/rss/test_setup_maker_atom_feed.rb445
-rw-r--r--test/rss/test_setup_maker_itunes.rb144
-rw-r--r--test/rss/test_setup_maker_slash.rb38
-rw-r--r--test/rss/test_slash.rb64
-rw-r--r--test/rss/test_syndication.rb4
-rw-r--r--test/rss/test_taxonomy.rb16
-rw-r--r--test/rss/test_to_s.rb232
-rw-r--r--test/rss/test_version.rb2
-rw-r--r--test/rss/test_xml-stylesheet.rb6
-rw-r--r--test/ruby/marshaltestlib.rb6
-rw-r--r--test/ruby/suicide.rb2
-rw-r--r--test/ruby/test_array.rb1159
-rw-r--r--test/ruby/test_beginendblock.rb35
-rw-r--r--test/ruby/test_bignum.rb11
-rw-r--r--test/ruby/test_enum.rb258
-rw-r--r--test/ruby/test_enumerator.rb105
-rw-r--r--test/ruby/test_fixnum.rb26
-rw-r--r--test/ruby/test_float.rb34
-rw-r--r--test/ruby/test_hash.rb3
-rw-r--r--test/ruby/test_integer.rb653
-rw-r--r--test/ruby/test_iterator.rb12
-rw-r--r--test/ruby/test_marshal.rb6
-rw-r--r--test/ruby/test_method.rb18
-rw-r--r--test/ruby/test_objectspace.rb2
-rw-r--r--test/ruby/test_proc.rb5
-rw-r--r--test/ruby/test_settracefunc.rb6
-rw-r--r--test/ruby/test_sleep.rb10
-rw-r--r--test/ruby/test_super.rb17
-rw-r--r--test/ruby/test_symbol.rb15
-rw-r--r--test/ruby/test_time.rb21
-rw-r--r--test/runner.rb2
-rw-r--r--test/strscan/test_stringscanner.rb13
-rw-r--r--test/testunit/collector/test_dir.rb29
-rwxr-xr-xtest/thread/lbtest.rb51
-rw-r--r--test/thread/test_thread.rb81
-rw-r--r--test/uri/test_common.rb5
-rw-r--r--test/uri/test_ftp.rb22
-rw-r--r--test/uri/test_generic.rb80
-rw-r--r--test/webrick/test_cookie.rb31
-rwxr-xr-x[-rw-r--r--]test/webrick/webrick_long_filename.cgi0
-rw-r--r--test/xmlrpc/test_cookie.rb96
-rw-r--r--test/yaml/test_yaml.rb2
-rw-r--r--test/yaml/test_yamlstore.rb74
-rw-r--r--time.c30
-rw-r--r--util.c51
-rw-r--r--util.h4
-rw-r--r--variable.c108
-rw-r--r--version.c35
-rw-r--r--version.h31
-rw-r--r--win32/Makefile.sub233
-rwxr-xr-xwin32/configure.bat4
-rw-r--r--win32/dir.h4
-rw-r--r--[-rwxr-xr-x]win32/mkexports.rb2
-rw-r--r--[-rwxr-xr-x]win32/resource.rb26
-rw-r--r--win32/setup.mak32
-rw-r--r--win32/win32.c281
-rw-r--r--win32/win32.h26
-rw-r--r--wince/Makefile.sub489
-rw-r--r--wince/mkconfig_wce.rb7
-rw-r--r--wince/mkexports.rb35
-rw-r--r--wince/resource.rb96
-rw-r--r--x68/_dtos18.c2
-rw-r--r--x68/_round.c2
-rw-r--r--x68/fconvert.c2
-rw-r--r--x68/select.c2
971 files changed, 17766 insertions, 65834 deletions
diff --git a/.cvsignore b/.cvsignore
index a72211d03f..9fd96ca149 100644
--- a/.cvsignore
+++ b/.cvsignore
@@ -3,14 +3,12 @@
*.rej
*.sav
*~
-.*.list
-.*.time
.ccmalloc
.ppack
.ext
.git
.svn
-.pc
+.rbconfig.time
COPYING.LIB
ChangeLog.pre-alpha
ChangeLog.pre1_1
@@ -28,20 +26,32 @@ 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
-patches
+parse.y.try
+pitest.rb
ppack
preview
rbconfig.rb
+rename2.h
repack
riscos
rubicon
ruby
ruby-man.rd.gz
+rubyunit
+st.c.power
+this that
tmp
web
y.output
diff --git a/ChangeLog b/ChangeLog
index abcb212803..5011c72aeb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,1260 +1,88 @@
-Wed Feb 18 22:28:00 2009 NAKAMURA Usaku <usa@ruby-lang.org>
+Wed Jun 18 13:19:55 2008 URABE Shyouhei <shyouhei@ruby-lang.org>
- * win32/win32.c (rb_w32_isatty): check whether fd is valid.
+ * file.c: fixes to compile on mswin32. Patch from U. Nakamura
+ <usa at garbagecollect.jp>. [ruby-dev:35127]
-Wed Feb 18 22:24:23 2009 NAKAMURA Usaku <usa@ruby-lang.org>
+Tue Jun 17 22:14:41 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * win32/win32.c (waitpid): fix bug of checking child slot.
-
- * win32/win32.c (FindChildSlotByHandle): new.
-
-Wed Feb 18 22:17:04 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * pack.c (pack_pack): propagate taint status from format string to
- result string.
-
-Wed Feb 18 22:07:44 2009 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
-
- * ext/gdbm/gdbm.c: do not set members of RSTRING(str) directly.
- [ruby-dev:37182]
-
- * ext/gdbm/gdbm.c (rb_gdbm_nextkey): fix memory leak.
-
-Tue Feb 17 11:58:58 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * string.c (str_independent): no independent string points null_str.
- [ruby-core:20082]
-
-Mon Feb 16 23:30:24 2009 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/lib/tkextlib/blt.rb, ext/tk/lib/tkextlib/blt/vector.rb:
- fix NameError bug.
-
-Mon Feb 16 23:08:22 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * string.c (rb_str_s_alloc, rb_str_replace): use null_str as well as
- rb_string_value so that extension libraries do not segfault.
- [ruby-core:19971]
-
- * string.c (rb_str_replace): reduced unnecessary malloc and copy.
-
-Mon Feb 16 22:45:41 2009 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-
- * test/rinda/test_rinda.rb: fixed fails occasionally [ruby-dev:37119].
- thanks, shinichiro.h.
-
-Mon Feb 16 22:36:37 2009 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-
- * lib/drb/drb.rb (DRbConn::alive?): fixed NoMethodError problem
- from NaHi [ruby-dev:37110].
-
-Sun Feb 15 04:21:42 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/net/ftp.rb (Net::FTP#open_socket): SOCKSsocket is obsolete.
- a patch from Alan Johnson <alan.wayne.johnson at gmail.com> in
- [ruby-core:19982].
-
-Fri Feb 13 19:18:42 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/logger.rb (ProgName): fixed for svn, based on a patch from
- Nobuhiro IMAI at [ruby-dev:37108].
-
-Sun Feb 15 04:17:40 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/webrick/httprequest.rb (WEBrick::HTTPRequest#read_request_line):
- use non-greedy match for path retrieval to avoid huge recursion
- for insanely long path.
-
-Fri Feb 13 19:04:54 2009 Keiju Ishitsuka <keiju@ruby-lang.org>
-
- * shell/command-processor.rb: undefined method `top_level_test' in
- Shell#test. [ruby-list:45634]
-
-Tue Feb 10 20:00:52 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (load_lock): makes circular require deadlock.
- [ruby-core:19821]
-
-Tue Feb 10 19:40:58 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (rb_feature_p): returns found feature name if loading.
- [ruby-core:19798]
-
- * eval.c (search_required): ditto.
-
-Wed Feb 11 23:37:35 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/bigdecimal/bigdecimal.c (VpMidRound): Round method bug
- pointed by Ryan Platte fixed(Patch to the patch from "NATORI
- Shin"). [ruby-talk:273360]
- back ported from 1.9. fix [ruby-core:19791]
-
-Mon Feb 9 17:35:38 2009 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/win32.c (rb_w32_accept): secure fd before accept because if
- error causes in securing, cannot restore the state of accepted
- socket.
- fixed [ruby-core:19728]
-
-Mon Feb 9 13:42:15 2009 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/win32.c (ifs_open_socket): should retry without proto_buffer
- if cannot find the suitable protocol. a patch from Heesob Park.
- fixed [ruby-core:19713]
-
-Mon Feb 9 13:40:21 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/stringio/stringio.c (strio_ungetc): should allow ungetc at
- the top of the buffer. ref #701
-
-Thu Feb 5 09:38:48 2009 NARUSE, Yui <naruse@ruby-lang.org>
-
- * ext/nkf/nkf-utf8/nkf.c (h_conv): can't guess UTF-8 input in
- conversion. [ruby-list:45609]
-
-Thu Feb 5 09:03:21 2009 Shugo Maeda <shugo@ruby-lang.org>
-
- * lib/rexml/entity.rb (unnormalized): do not call
- document.record_entity_expansion if document is nil.
- see <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=502535>.
- Thanks, Naohisa Goto. backported from trunk.
-
- * test/rexml/test_document.rb: ditto.
-
-Thu Feb 5 08:55:24 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * array.c (rb_ary_join): do not repeat self in a recursive array.
- [ruby-dev:37019]
-
-Wed Feb 4 14:26:58 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * dir.c (dir_globs): need taint check. reported by steve
- <oksteev at gmail.com>
-
-Tue Feb 3 14:35:26 2009 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
-
- * lib/net/pop.rb: check for invalid APOP timestamp. (CVE-2007-1558)
- [ruby-dev:36631]
-
- * test/net/pop/test_pop.rb: ditto.
-
-Mon Feb 2 20:03:58 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * time.c (time_mdump, time_mload): preserves GMT status.
- [ruby-core:19252]
-
-Mon Feb 2 11:34:51 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * variable.c (autoload_delete, autoload_file): should not delete
- autoload table, since it may be shared with duplicated modules.
- [ruby-core:19181]
-
-Thu Jan 29 11:54:22 2009 Tadayoshi Funaba <tadf@dotrb.org>
-
- * lib/date.rb (today,now): should produce own instances.
- [ruby-talk:317020]
-
-Wed Jan 28 22:51:55 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (rb_mod_modfunc): method undefined in included module
- may not have nd_body. [ruby-core:18738]
-
-Wed Jan 28 20:53:27 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * marshal.c (marshal_dump): fixed for check_dump_arg.
-
-Tue Jan 27 17:30:11 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * marshal.c (marshal_dump): initializes dump_arg before any funcall.
- [ruby-dev:36648]
-
-Tue Jan 27 15:17:35 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/socket/socket.c (host_str): numeric address should be unsigned.
- [ruby-core:18971]
-
-Mon Jan 26 11:12:03 2009 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * lib/tmpdir.rb: setup buffer with nul characters instead of spaces.
- fixed [ruby-dev:36493]
-
-Sun Jan 25 00:07:23 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/rexml/formatters/pretty.rb (REXML::Formatters::Pretty#wrap):
- abandon wrapping if the line contains no space. [ruby-dev:36045]
- fix: #342
-
-Sun Jan 25 00:02:23 2009 Yuki Sonoda (Yugui) <yugui@yugui.jp>
-
- * lib/matrix.rb (Vector#eql?): typo of the method name as "eqn?".
- (Vector#eqn?): removed. Defined by mistake.
- Fixes [ruby-dev:36294]. Reported by weda <weda AT
- issp.u-tokyo.ac.jp> and an anonymous user.
-
- * test/matrix/test_matrix.rb: added.
-
- * test/matrix/test_vector.rb: added.
-
-Fri Jan 23 11:49:45 2009 Shugo Maeda <shugo@ruby-lang.org>
-
- * NEWS: added an entry for REXML.
-
- * lib/rexml/document.rb: fixed typo.
-
-Fri Jan 23 11:49:45 2009 Shugo Maeda <shugo@ruby-lang.org>
-
- * lib/rexml/document.rb: limit entity expansion. Thanks, Luka
- Treiber, Mitja Kolsek, and Michael Koziarski. backported from
- trunk r19033, r19317, r19318.
-
- * lib/rexml/entity.rb: ditto.
-
- * test/rexml/test_document.rb: ditto.
-
-Thu Jan 22 15:19:39 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * marshal.c (marshal_load): arg.data is no longer a VALUE but a
- st_table, and freed in load_ensure. pointed out by pegacorn.
- [ruby-dev:37008]
-
-Thu Jan 22 15:19:39 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * gc.c (rb_mark_set): new function to mark keys.
-
- * marshal.c (struct dump_arg, struct load_arg): added wrappers to mark
- data entries. backport from trunk r13527,r13528,r13961,r16533.
- [ruby-dev:36082]
-
-Wed Jan 21 11:12:55 2009 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/win32.c (filetime_to_timeval): new function, split from
- gettimeofday().
-
- * win32/win32.c (gettimeofday): use above function.
-
- * win32/win32.c (filetime_to_unixtime): ditto. [ruby-dev:36135]
-
-Wed Jan 21 11:12:55 2009 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/win32.c (gettimeofday): tv_usec is usec, not msec.
- [ruby-dev:36094]
-
-Wed Jan 21 11:12:55 2009 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/win32.c (gettimeofday): calc tv_sec and tv_usec from system
- time by myself. [ruby-dev:36084]
-
-Wed Jan 21 11:12:55 2009 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/win32.c (gettimeofday): shouldn't use mktime(2) because it's
- buggy about handling summer time.
- reported by Yoshikawa <yoshixool AT gmail.com> at [ruby-dev:36071]
-
-Tue Jan 20 12:23:38 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/scanf.rb (Scanf::FormatSpecifier#initialize): %i should accept
- single digit decimal. [ruby-core:18355]
-
-Mon Jan 19 18:25:28 2009 Tanaka Akira <akr@fsij.org>
-
- * configure.in (rb_cv_broken_glibc_ia64_erfc): renamed from
- rb_broken_glibc_ia64_erfc.
- [ruby-core:18228]
-
-Sat Jan 17 12:16:10 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * random.c (Init_Random): always initialize seed.
-
-Fri Jan 16 10:59:31 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * class.c (clone_method): should copy cbase in cref as well.
- [ruby-dev:35116]
-
- * node.h (NEW_CREF): new NEW_ macro.
-
- * eval.c (PUSH_CREF): use NEW_CREF().
-
-Thu Jan 15 14:34:32 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * gc.c (STACK_LEVEL_MAX, ruby_stack_length): returns size_t.
- [ruby-core:18207]
-Wed Jan 14 10:39:56 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * stable/ext/socket/socket.c (NI_MAXHOST, NI_MAXSERV): fixed invalid
- preprocessor directives. a patch from Peter Bowen at
- [ruby-core:18211].
-
-Tue Jan 13 04:40:30 2009 Shugo Maeda <shugo@ruby-lang.org>
-
- * lib/net/ftp.rb (login): raise FTPReplyError if passwd or acct
- is not supplied. backported from trunk. fixed [ruby-core:18058].
-
-Mon Jan 12 00:23:37 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * gc.c (gc_sweep, obj_free, run_final): defer finalizers of IO and
- Data. [ruby-dev:35578]
-
- * gc.c (rb_gc_call_finalizer_at_exit): self-referencing finalizers
- cannot be invoked. [ruby-dev:35681]
-
-Sun Jan 11 11:33:27 2009 Shugo Maeda <shugo@ruby-lang.org>
-
- * lib/net/ftp.rb (chdir): handle 5xx errors correctly.
- backported from trunk. fixed [ruby-core:18057].
-
-Fri Jan 9 19:25:25 2009 Shugo Maeda <shugo@ruby-lang.org>
-
- * lib/net/imap.rb (disconnect): do not refer SSL::SSLSocket for
- environments without OpenSSL. backported from trunk.
- fixed [ruby-dev:35755].
-
-Thu Jan 8 13:24:23 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (deferred_nodes, compstmt, arg, fixup_nodes, range_op): fix
- up fixnum range literal in conditional as automagical line number
- comparison. [ruby-core:12124], [ruby-dev:35731]
-
-Wed Jan 7 10:09:46 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (timeofday): use monotonic clock. based on a patch
- from zimbatm <zimbatm@oree.ch> in [ruby-core:16627].
-
-Tue Jan 6 09:03:35 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (yylex): 8 and 9 in octal integer should cause compile
- error. [ruby-dev:35729]
-
-Mon Jan 5 11:14:39 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (rb_thread_schedule): runs deferred finalizers.
-
- * gc.c (gc_sweep): sets rb_thread_pending to run deferred finalizers.
-
- * rubysig.h (CHECK_INTS): now checks rb_thread_pending even on
- platforms where setitimer is not available. [ruby-core:18045]
-
-Mon Jan 5 11:14:39 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * rubysig.h (CHECK_INTS): gives the chance to perform to deferred
- finalizers before explicit GC.start or the process termination.
- [ruby-core:18045]
-
-Sun Jan 4 04:49:01 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * win32/win32.c (rb_w32_telldir): just returns loc.
-
- * win32/win32.c (rb_w32_rewinddir): needs to intialize loc.
- [ruby-core:18041]
-
-Sun Jan 4 04:45:26 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * win32/win32.c (rb_w32_select): recalc the rest of timeout for each
- iterations. [ruby-core:18015]
-
-Fri Jan 2 03:08:47 2009 Kouhei Sutou <kou@cozmixng.org>
-
- * test/rss/: use PNG instead of zlib as binary data. [ruby-dev:35666]
-
-Tue Nov 11 01:07:32 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
-
- * configure.in: fix SEGV on Mac OS X 10.5.3 with --enable-pthread.
- a patch from Wataru Kimura in Bug #193 [ruby-core:17333].
-
-Mon Aug 11 09:37:17 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/dl/dl.c (rb_str_to_ptr): should propagate taint to dlptr.
-
- * ext/dl/dl.c (rb_ary_to_ptr): ditto.
-
- * ext/dl/sym.c (rb_dlsym_call): should check taint of DLPtrData as
- well.
-
-Fri Aug 8 10:53:52 2008 Tanaka Akira <akr@fsij.org>
-
- * lib/resolv.rb: randomize source port and transaction id.
- CVE-2008-1447.
-
- * lib/resolv-replace.rb (UDPSocket#bind): don't resolv host if host is
- "".
-
-Mon Aug 4 14:49:35 2008 URABE Shyouhei <shyouhei@ruby-lang.org>
-
- * lib/net/smtp.rb (Net::SMTP::rcptto): fix a typo. a patch from
- Masao Takaku <masao at nii.ac.jp>
- fix [ruby-dev:35489].
-
-Mon Aug 4 14:13:15 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * regex.c (xmalloc, xrealloc, xfree): not to use ruby managed memory.
-
- * regex.c (DOUBLE_STACK, re_compile_fastmap0, re_adjust_startpos),
- (re_search, re_match_exec): check if failed to allocate memory.
-
-Mon Aug 4 13:53:42 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * bignum.c (rb_big2str0, bigsqr): made interruptible. [ruby-Bugs-20622]
-
-Mon Aug 4 13:31:41 2008 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * numeric.c (check_uint, rb_num2uint, rb_fix2uint): fixed wrong check
- about 64bit positive value.
-Mon Aug 4 13:31:41 2008 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * numeric.c (check_uint, rb_num2uint, rb_fix2uint): strict check.
- fixed [ruby-dev:33683]
-
-Thu Jul 17 21:42:07 2008 URABE Shyouhei <shyouhei@ruby-lang.org>
-
- * lib/net/smtp.rb (Net::SMTP::start): revert to avoid RFC2821
- violation. [ruby-dev:35487]
-
-Thu Jul 17 21:32:49 2008 Tanaka Akira <akr@fsij.org>
-
- * string.c (rb_str_format_m): make tmp volatile to avoid possible GC
- problem.
-
-Thu Jul 17 21:30:55 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/optparse.rb (OptionParser#environment): requires shellwords.
- [ruby-dev:35466]
-
-Thu Jul 17 02:05:10 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/xmlrpc/client.rb (XMLRPC::Client#do_rpc): requires
- webrick/cookie. [ ruby-Bugs-21139 ]
-
-Thu Jul 17 01:38:31 2008 Yusuke Endoh <mame@tsg.ne.jp>
-
- * ext/zlib/zlib.c (rb_gzfile_set_mtime): fix typo. [ruby-core:17713]
-
-Sun Jul 13 00:08:16 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/ipaddr.rb (IPAddr#initialize): get rid of ArgumentError in
- IPAddr#to_range. a patch from okkez <okkez000 AT gmail.com> in
- [ruby-dev:35091].
-
-Sun Jul 13 00:04:38 2008 Tanaka Akira <akr@fsij.org>
-
- * configure.in (erfc): erfc of glibc comes with Debian GNU/Linux Etch
- on IA64 is broken. erfc(10000.0) aborts.
- use missing/erf.c instead.
- http://sources.redhat.com/ml/libc-hacker/2005-08/msg00008.html
-
-Thu Jul 10 18:50:48 2008 Tanaka Akira <akr@fsij.org>
-
- * common.mk (SPEC_GIT_BASE): update RubySpec GIT URL.
-
-Thu Jul 10 18:46:28 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * file.c (rb_file_s_extname): fix for file name with spaces.
- [ruby-talk:307404]
-
-Thu Jul 10 18:42:37 2008 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-
- * lib/erb.rb (PercentScanner#scan): fix %% line bug. [ruby-core:17491]
-
- * test/erb/test_erb.rb (test_percent): ditto.
-
-Thu Jul 10 18:40:22 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/net/ftp.rb (Net::FTP#sendport): use divmod. [ruby-core:17557]
-
-Thu Jul 10 18:36:53 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
-
- * ruby.c: Mac OS X needs origargc times of '\0' in
- origargv. [ruby-dev:35308]
-
-Thu Jul 10 13:53:08 2008 Tanaka Akira <akr@fsij.org>
-
- * include/ruby/ruby.h (POSFIXABLE): use FIXNUM_MAX+1 instead of
- FIXNUM_MAX to make it possible to convert to double accurately.
- It assumes FLT_RADIX is 2.
- fix RubyForge bug #14102.
- backported from 1.9.
-
-Mon Jul 7 16:21:38 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/net/smtp.rb (Net::SMTP::start): use 'localhost' instead of
- 'localhost.localdomain'. [ruby-dev:35333]
-
- * lib/net/smtp.rb (Net::SMTP::SMTP.start): ditto.
-
-Mon Jul 7 15:02:13 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (rb_longjmp): duplicate the thrown exception to set backtrace
- if it was frozen. clear all raised flags.
-
- * eval.c (stack_check): leave clearing flag to rb_longjmp.
-
- * eval.c (rb_thread_set_raised, rb_thread_reset_raised): use generic
- flags.
-
- * eval.c (Init_Proc), gc.c (Init_GC): freeze preallocated special exceptions.
-
- * gc.c (rb_memerror): use thread raised flag instead of static flag,
- and raise nomem_error without backtrace if failed to make backtrace.
- [ruby-dev:34724]
-
- * gc.c (ruby_xmalloc): increase malloc_increase only if malloc
- succeeds. failed malloc size can be huge. it may increase
- malloc_limit too big which cause less GC and memory full.
- (ruby_xrealloc): ditto.
-
-Mon Jul 7 12:23:05 2008 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c: avoid creating Ruby object during
- GC. thanks to arton <artonx AT yahoo.co.jp>. [ruby-dev:35313]
-
- * ext/win32ole/tests: add test_win32ole_event.rb, remove
- testOLEEVENT.rb
-
- * ext/win32ole/tests/testWIN32OLE.rb(test_convert_bignum):
- fix test.
-
-Mon Jul 7 12:23:05 2008 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * gc.c: add rb_during_gc(). based on a patch from arton <artonx AT
- yahoo.co.jp> at [ruby-dev:35313].
-
- * intern.h: ditto.
-
-Thu Jul 3 20:13:20 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * marshal.c (w_object, marshal_dump, r_object0, marshal_load): search
- public methods only. [ruby-core:17283]
-
- * object.c (convert_type): ditto.
-
- * lib/singleton.rb (Singleton#_dump): conversion method should be
- public.
-
-Wed Jul 2 19:06:43 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/cgi.rb (CGI::QueryExtension.read_multipart): blanks inside
- double quotes are allowed. [ruby-list:45140]
-
-Wed Jul 2 19:03:37 2008 Tanaka Akira <akr@fsij.org>
-
- * numeric.c (num_coerce): call rb_Float(x) first. don't depend on
- evaluation order of function arguments.
-
-Wed Jul 2 18:57:19 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/syslog/syslog.c (syslog_write): syslog operations should be
- protected from $SAFE level 4. a patch from Keita Yamaguchi
- <keita.yamaguchi at gmail.com>.
-
- * ext/syslog/syslog.c (mSyslog_close): ditto.
-
- * ext/syslog/syslog.c (mSyslog_set_mask): ditto.
-
-Wed Jul 2 18:26:20 2008 Tanaka Akira <akr@fsij.org>
-
- * math.c (domain_check): fix preprocess condition.
-
-Wed Jul 2 18:22:52 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/tmpdir.rb (@@systmpdir): prior LOCAL_APPDATA if possible, and
- should be clean. based on a patch from arton <artonx AT
- yahoo.co.jp> at [ruby-dev:35269]
-
-Wed Jul 2 18:16:19 2008 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c (date2time_str): fix the overflow in
- some situation. [ruby-bugs-20793]
-
-Tue Jul 1 15:11:14 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * array.c (rb_ary_fill): check if beg is too big.
-
-Mon Jun 30 20:35:32 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * string.c (str_buf_cat): check for self concatenation.
-
-Sun Jun 29 21:39:54 2008 Tanaka Akira <akr@fsij.org>
-
- * eval.c (rb_obj_respond_to): use RTEST to test the result of
- respond_to? method.
-
-Sun Jun 29 21:20:17 2008 URABE Shyouhei <shyouhei@ruby-lang.org>
-
- * array.c (rb_ary_fill): (compatibility) do not raise
- ArgumentError on negative length. This behaviour shall change
- in a future release.
-
-Sun Jun 29 20:08:11 2008 Tanaka Akira <akr@fsij.org>
-
- * time.c (time_timeval): fix rounding negative float.
-
-Sun Jun 29 19:19:08 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * test/inlinetest.rb (InlineTest.in_progname): workaround for frozen
- $0. [ruby-dev:35261]
-
- * lib/test/unit/ui/console/testrunner.rb (TestRunner#finished): ditto.
-
-Sun Jun 29 19:19:08 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ruby.c (set_arg0, ruby_prog_init): freeze $0. a patch from Keita
- Yamaguchi <keita.yamaguchi at gmail.com>.
-
-Sun Jun 29 18:33:33 2008 Tanaka Akira <akr@fsij.org>
-
- * process.c: include sys/resource.h if HAVE_SYS_RESOURCE_H is defined.
- pointed by TOYOFUKU Chikanobu. [ruby-dev:35258]
-
-Sun Jun 29 18:26:01 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * variable.c (rb_f_trace_var): should not be allowed at safe level 4.
- a patch from Keita Yamaguchi <keita.yamaguchi at gmail.com>.
-
- * eval.c (rb_call0): wrong condition to check insecure method.
- a patch from Keita Yamaguchi <keita.yamaguchi at gmail.com>.
-
-Sun Jun 29 18:22:52 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * array.c (rb_ary_fill): not depend on unspecified behavior at integer
- overflow. reported by Vincenzo Iozzo <snagg AT openssl.it>.
-
-Sun Jun 29 18:22:06 2008 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c(ole_invoke): fix memory leak.
- [ruby-bugs-20792]
-
-Sun Jun 29 18:19:11 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * eval.c (PUSH_FRAME, PUSH_CLASS): Add volatile to avoid a
- possible optimization bug on OS X/PPC. This at least makes
- build with gcc -O1 and `make test' pass.
-
-Sun Jun 29 17:24:43 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/rdoc/parsers/parse_rb.rb (RDoc#collect_first_comment): skip
- magic comment.
-
-Sun Jun 29 17:22:09 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/stringio/stringio.c (strio_each, strio_readlines): IO#each and
- IO#readlines do not affect $_. [ruby-core:17277]
-
-Sun Jun 29 17:19:59 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/stringio/stringio.c (strio_readline, strio_each)
- (strio_readlines): set lastline. [ruby-core:17257]
-
-Sun Jun 29 17:15:49 2008 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * ext/openssl/ossl.h: include winsock.h if USE_WINSOCK2 is not defined.
- a patch from arton <artonx at yahoo.co.jp> in [ruby-dev:35078]
-
-Sun Jun 29 17:09:48 2008 wanabe <s.wanabe@gmail.com>
-
- * util.c (ruby_strtod): ruby_strtod don't allow a trailing
- decimal point like "7.". [ruby-dev:34835] [ruby-dev:35009]
-
-Sat Jun 28 19:23:40 2008 URABE Shyouhei <shyouhei@ruby-lang.org>
-
- * class.c (clone_method): use rb_copy_node_scope.
- fixed [ruby-list:45102]
- fixed [ruby-core:17393]
-
-Sat Jun 28 18:49:50 2008 URABE Shyouhei <shyouhei@ruby-lang.org>
-
- * class.c: revert to r15855.
-
-Fri Jun 20 18:25:18 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * string.c (rb_str_buf_append): should infect.
-
-Fri Jun 20 16:33:09 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * array.c (rb_ary_store, rb_ary_splice): not depend on unspecified
- behavior at integer overflow.
-
- * string.c (str_buf_cat): ditto.
-
-Wed Jun 18 22:24:46 2008 URABE Shyouhei <shyouhei@ruby-lang.org>
-
- * array.c (ary_new, rb_ary_initialize, rb_ary_store,
- rb_ary_aplice, rb_ary_times): integer overflows should be
- checked. based on patches from Drew Yao <ayao at apple.com>
- fixed CVE-2008-2726
-
- * string.c (rb_str_buf_append): fixed unsafe use of alloca,
- which led memory corruption. based on a patch from Drew Yao
- <ayao at apple.com> fixed CVE-2008-2726
-
- * sprintf.c (rb_str_format): backported from trunk.
-
- * intern.h: ditto.
-
-Tue Jun 17 15:09:46 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * file.c (file_expand_path): no need to expand root path which has no
- short file name. [ruby-dev:35095]
-
-Sun Jun 15 19:27:40 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * configure.in: Fix $LOAD_PATH. Properly expand vendor_ruby
- directories; submitted by Takahiro Kambe <taca at
- back-street.net> in [ruby-dev:35099].
-
-Mon Jun 9 17:56:30 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * lib/set.rb (Set#delete_if): Call to_a.
- (SortedSet#delete_if, TC_SortedSet#test_sortedset): Use super to
- yield elements in sorted order; [ruby-core:17144] by Arthur
- Schreiber.
- (SortedSet#each, SortedSet#each, TC_Set#test_each)
- (TC_SortedSet#test_sortedset): Return self; [ruby-dev:35002] by
- Arthur Schreiber.
-
-Mon Jun 9 03:28:05 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/zlib/zlib.c (rb_deflate_initialize, Init_zlib): Fix up
- initialize_copy; [ruby-list:45016], [ruby-list:45018].
-
-Mon Jun 9 03:26:03 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
-
- * NEWS: Mention new constants.
-
-Mon Jun 9 03:24:18 2008 Tanaka Akira <akr@fsij.org>
-
- * hash.c (hash_i): make Hash#hash order insensitive.
-
-Mon Jun 9 03:22:43 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in (VENDOR_DIR): use LIBDIR instead of PREFIX as well as
- SITE_DIR. a patch from Richard Brown <rbrown AT exherbo.org> in
- [ruby-core:17129].
-
-Mon Jun 9 03:21:20 2008 Tanaka Akira <akr@fsij.org>
-
- * gc.c (os_obj_of): assure to not free the scanning heap.
-
-Mon Jun 9 03:20:12 2008 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * io.c (rb_open_file, rb_io_s_sysopen): fmode should be unsigned int.
- fixed [ruby-dev:34979]
-
-Fri Jun 6 21:16:55 2008 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/Makefile.sub (COMMON_HEADERS): include ws2tcpip.h.
-
- * ext/socket/addrinfo.h (addrinfo, getaddrinfo, getnameinfo,
- freehostent, freeaddrinfo): undef before define because these are
- macros in some versions of Windows SDK.
-
- * win32/setup.mak: maybe commit miss.
-
-Fri Jun 6 19:34:22 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * mkconfig.rb: hide build path from rbconfig.rb.
-
- * util.c (ruby_strtod, dtoa): initialize more variables for error
- handling.
-
- * io.c (rscheck), marshal.c (w_nbyte, w_bytes, w_unique),
- (path2class, path2module): constified.
-
- * pack.c (pack_unpack), process.c (rb_syswait): suppress warnings.
-
- * suppress warnings on cygwin, mingw and mswin.
-
-Fri Jun 6 19:23:53 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * file.c (file_expand_path): fix for non-existent files and SFN of
- symlinks. [ruby-talk:303736]
-
-Fri Jun 6 18:25:43 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * test/iconv: Tests fixed.
-
-Fri Jun 6 17:04:56 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * win32/win32.h: include ws2tcpip.h. fixed [ruby-Bugs-20528]
-
- * lib/time.rb (Time.xmlschema): don't use float. fix
- http://rubyforge.org/tracker/index.php?func=detail&group_id=426&atid=1698&aid=20504
-
- * object.c (rb_obj_alloc): RDoc updated. a patch from Gaston
- Ramos <ramos.gaston at gmail.com> in [ruby-core:17073].
-
- * lib/rdoc.rb: massive spelling correction patch from Evan Farrar
- <evanfarrar at gmail.com> in [ruby-doc:1382] applied.
-
- * ext/openssl/ossl_ssl_session.c (ossl_ssl_session_initialize):
- Add a null check for ssl; submitted by akira yamada
- in [ruby-dev:34950].
-
- * ext/openssl/ossl_ssl.c (Init_ossl_ssl): Define OP_NO_TICKET if
- SSL_OP_NO_TICKET is present; submitted by akira yamada
- in [ruby-dev:34944].
-
- * test/openssl/test_ssl.rb (OpenSSL#test_server_session): Add a
- workaround for the case where OpenSSL is configured with
- --enable-tlsext; submitted by akira yamada in [ruby-dev:34944].
-
-Fri Jun 6 16:58:23 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/iconv/iconv.c (iconv_iconv): fix for length argument and now
- allows range. [ruby-core:17092] [ruby-core:17115]
-
-Wed Jun 4 17:22:30 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * NEWS: Fix typos and move misplaced entries.
- NEWS: Somehow optflags and warnflags were not actually included
- in this release.
-
-Tue Jun 3 19:33:22 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * enumerator.c (enumerator_init_copy): Take care of
- initialize_copy as well as initialize.
-
- * test/ruby/test_enumerator.rb: Pull in the test suite for
- enumerator from trunk.
-
-Tue Jun 3 12:51:57 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * enumerator.c (enumerator_allocate, enumerator_ptr): Properly
- detect if the object is initialized and raise error when
- appropriate.
- (enumerator_initialize): Fix a typo in rdoc. [ruby-core:17052]
-
-Tue Jun 3 10:16:40 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * lib/erb.rb (ERB::Compiler::TrimScanner#scan_line): Fix a bug
- where tokens are not yilelded one by one.
- (ERB::Compiler::TrimScanner#explicit_trim_line): Fix without-
- strscan problems. [ruby_core:17028].
-
- * test/erb/test_erb.rb (TestERBCore#_test_01)
- (TestERBCore#test_02_safe_04): The expected value should come
- first for assert_equal().
- (TestERBCoreWOStrScan): Add test class for without-strscan.
-
-Mon Jun 2 19:47:16 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * lib/delegate.rb (DelegateClass, Delegator#respond_to?):
- respond_to? must take optional second argument. This was a
- latent bug exposed by a recent internal change of marshal.c to
- call respond_to? with a second argument; submitted by Jeremy
- Kemper <jeremy at bitsweat.net> in [ruby-core:17045].
-
-Sat May 31 23:53:35 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * .: Release as Ruby 1.8.7.
-
-Sat May 31 23:33:34 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * README, README.ja: Add a note about default C flags.
-
-Sat May 31 22:11:15 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
-
- * version.c (ruby_description, ruby_copyright): backported from
- 1.9. bug#19002, [ruby-dev:34883]
-
- * error.c (report_bug): uses ruby_description.
-
-Sat May 31 20:56:04 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * array.c (rb_ary_delete_if): should return enumerator if no block
- is given. [ruby-dev:34901]
-
-Sat May 31 18:28:17 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * suppress warnings with -Wwrite-string.
-
-Sat May 31 15:58:08 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * Makefile.in, configure.in (warnflags): defaulted to -Wall
- -Wno-parentheses with gcc. [ruby-dev:34810]
-
-Fri May 30 05:28:18 2008 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * enum.c (count_i, count_iter_i, count_all_i): add prototypes for VC.
-
-Fri May 30 04:32:07 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * enum.c (count_i, count_iter_i): Sync with trunk.
- enum.c (enum_count, count_all_i, Init_Enumerable),
- array.c (rb_ary_count): Sync with trunk. If no argument or
- block is given, count the number of all elements.
+ * configure.in (LIBPATHFLAG, RPATHFLAG): no needs to be quoted,
+ it is done by libpathflag in mkmf.rb.
-Fri May 30 03:12:18 2008 Akinori MUSHA <knu@iDaemons.org>
+Mon Jun 16 19:18:35 2008 NAKAMURA Usaku <usa@ruby-lang.org>
- * ext/openssl/ossl_bn.c (ossl_bn_s_rand, ossl_bn_s_pseudo_rand):
- Int should be enough here.
+ * lib/mkmf.rb: fixed the bug of handling COMMON_MACROS.
-Fri May 30 02:35:00 2008 Akinori MUSHA <knu@iDaemons.org>
+Mon Jun 16 17:11:32 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * ext/openssl/ossl_bn.c (ossl_bn_s_rand, ossl_bn_s_pseudo_rand),
- ext/openssl/ossl_pkey_dh.c (ossl_dh_s_generate)
- (ossl_dh_initialize),
- ext/openssl/ossl_pkey_dsa.c (ossl_dsa_s_generate),
- ext/openssl/ossl_rand.c (ossl_rand_bytes)
- (ossl_rand_pseudo_bytes, ossl_rand_egd_bytes),
- ext/openssl/ossl_x509store.c (ossl_x509stctx_set_error): Do not
- use FIX2INT() without checking the value type. Use NUM2INT()
- instead; found by akr in [ruby-dev:34890].
+ * mkconfig.rb: autoconf 2.61 support. [ruby-core:10016]
-Thu May 29 20:07:45 2008 Akinori MUSHA <knu@iDaemons.org>
+Mon Jun 16 15:40:37 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
- * configure.in, win32/Makefile.sub, mkconfig.rb, instruby.rb,
- ruby.c, lib/mkmf.rb, README.EXT, README.EXT.ja: Backport the
- vendor_ruby directory support.
+ * proc.c (proc_dup): should copy safe_level from src proc
+ properly. a patch from Keita Yamaguchi
+ <keita.yamaguchi at gmail.com>
-Thu May 29 17:52:31 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 15 23:31:10 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/zlib/extconf.rb: search zlib1, and regard mswin32 later than VC6
as WIN32. [ruby-core:16984]
-Wed May 28 17:54:29 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * string.c (rb_str_start_with): Remove an unused variable.
- (rb_str_upto_m): Fix a prototype.
-
-Wed May 28 17:48:28 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * range.c (range_step): Fix brokenness when a non-integer numeric
- value is specified as step. [rubyspec]
- (range_step): Make use of String#step internally if a string (or
- string-alike) range is given.
-
- * string.c (rb_str_upto_m, Init_String): Add an optional second
- argument to specify if the last value should be included.
-
-Wed May 28 16:53:39 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * array.c (rb_ary_slice_bang): Call rb_ary_modify_check() at the
- beginning. [rubyspec]
-Wed May 28 16:12:44 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * lib/webrick/httpservlet/cgihandler.rb (WEBrick::HTTPServlet::CGIHandler#do_GET):
- Set the HTTP status code to 302 if a Location header field is
- present and the status code is not valid as a client
- redirection. cf. RFC 3875 6.2.3, 6.2.4.
-
-Wed May 28 15:18:16 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/singleton.rb (SingletonClassMethods): _load should be public.
-
-Wed May 28 12:52:41 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 15 23:27:31 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* marshal.c (w_object, marshal_dump, r_object0, marshal_load): search
private methods too. [ruby-dev:34671]
* object.c (convert_type): ditto.
-Tue May 27 23:26:49 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * error.c (rb_bug): description from rb_bug() should include
- patchlevel. [ruby-dev:34826]
-
-Tue May 27 20:19:22 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * array.c (rb_ary_slice_bang): Return an empty array instead of
- nil when pos is valid and len is adjusted from a valid value to
- zero; caught by RubySpec.
-
-Tue May 27 19:45:20 2008 Akinori MUSHA <knu@iDaemons.org>
+Sun Jun 15 23:26:24 2008 Akinori MUSHA <knu@iDaemons.org>
* numeric.c (flo_divmod): Revert the behavior change; do not
suppress an exception when div is NaN or Inf. [ruby-dev:34857]
-Tue May 27 19:24:40 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * enum.c (enum_to_a): Pass arguments through to #each().
- (enum_sort): Follow the enum_to_a signature change.
- (enum_reverse_each): Add #reverse_each().
-
-Tue May 27 18:54:02 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/stringio/stringio.c (strio_each_char, Init_stringio): Add
- StringIO#{each_char,chars}.
-
-Tue May 27 17:59:34 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/stringio/stringio.c (strio_each): Return an enumerator if no
- block is given.
- (strio_each_byte): Return an enumerator if no block is given,
- and return self if one is given as the rdoc says.
-
- * io.c (rb_io_each_byte): Fix rdoc. IO#each_byte returns self,
- not nil.
-
-Tue May 27 16:02:58 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * eval.c (rb_mod_module_exec, Init_eval): Add
- Module#{module_exec,class_exec}.
-
-Tue May 27 15:36:37 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * io.c (rb_io_each_char, argf_each_char, Init_IO):
- Add {IO#,ARGF.}{each_char,chars}.
-
-Tue May 27 13:46:52 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/stringio/stringio.c (Init_stringio): Define
- StringIO#{getbyte,readbyte}.
-
-Tue May 27 13:38:51 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * io.c (Init_IO): Define {IO#,ARGF.}{getbyte,readbyte}.
-
-Tue May 27 13:26:15 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/stringio/stringio.c (Init_stringio): Define #bytes and
- #lines.
-
-Tue May 27 13:20:35 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * io.c: (rb_io_lines, rb_io_bytes, Init_IO): Define
- IO#{lines,bytes} and ARGF.{lines,bytes}.
-
-Tue May 27 12:13:17 2008 NAKAMURA Usaku <usa@ruby-lang.org>
+Sun Jun 15 23:21:48 2008 NAKAMURA Usaku <usa@ruby-lang.org>
* file.c (BUFCHECK): wrong condition. [ruby-core:16921]
* file.c (file_expand_buf): shouldn't use buflen for length of string.
-Mon May 26 18:24:48 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * file.c (BUFCHECK): no resize if enough room.
-
- * file.c (file_expand_path): use BUFCHECK.
-
-Mon May 26 16:46:19 2008 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * file.c (ntfs_tail): filename which starts with '.' is valid.
-
- * file.c (file_expand_path): cygwin symlink support.
-
-Mon May 26 12:16:43 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * .: Release as Ruby 1.8.7-preview4.
-
-Mon May 26 12:12:26 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * marshal.c (dump_ensure, load_ensure): should return values.
-
- * eval.c (yield_under, yield_under_i, yield_args_under_i)
- (specific_eval, rb_obj_instance_exec, Init_eval): Implement
- Object#instance_exec(), a 1.9 feature.
-
-Mon May 26 11:53:21 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * eval.c (rb_yield_0, proc_invoke, proc_arity): allow passing a
- block to a Proc. [ruby-dev:23533]; by nobu; backported from
- 1.9. This implementation in current shape is known to be
- buggy/broken, especially with nested block invocation. Take
- this as an experimental feature.
-
- * parse.y (block_par, block_var): ditto.
-
-Mon May 26 08:00:52 2008 Akinori MUSHA <knu@iDaemons.org>
+Sun Jun 15 23:20:37 2008 Akinori MUSHA <knu@iDaemons.org>
* marshal.c (r_object0, Init_marshal): Fix the garbled s_call
definition; fixes [ruby-dev:34843].
-Mon May 26 03:16:20 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * hash.c (rb_hash_default): Fix rdoc.
- (rb_hash_each, env_each_value, env_each_pair): Return an
- enumerator if no block is given.
- (rb_hash_update): Update rdoc.
- (envix): Conditionalize the definition itself.
- (rb_f_getenv, env_fetch, env_keys, env_values, env_values_at)
- (env_select, env_inspect, env_to_a, env_empty_p, env_has_key)
- (env_has_value, env_index, env_indexes, env_to_hash, env_shift)
- (env_update): Require secure level 4.
- (env_each_value, env_each_i): Delay variable initialization.
- (env_each_key, env_each_value, env_reject_bang)
- (env_clear, env_replace): Omit duplicated secure level check.
- (env_has_value): Do to_str conversion.
-
-Sun May 25 19:48:12 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * hash.c (env_delete_if): Return an enumerator if no block is
- given.
- (env_each_key): Delay a variable initialization after
- RETURN_ENUMERATOR().
-
-Sun May 25 05:07:19 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * array.c (rb_ary_slice_bang): Be consistent with Array#slice()
- and String#slice!(). Just return nil when a negative length or
- out of boundary index is given instead of raising an exception
- via internal functions.
- (rb_ary_slice_bang): should not use rb_ary_subseq() which shares
- internal pointer. splice modifies the receiver right after
- subseq. [ruby-dev:34005]
- (rb_ary_slice_bang): should adjust length before making
- sub-array.
-
- * enumerator.c (Init_Enumerator): Override
- Enumerable::Enumerator#each_with_index with #with_index.
-
-Sun May 25 03:13:09 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * eval.c (Init_Thread): Initialize recursive_key.
-
-Sun May 25 02:45:49 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * error.c (syserr_eqq): Use en.
-
-Sat May 24 22:32:49 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sun Jun 15 23:19:14 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* object.c (rb_cstr_to_dbl): should clear errno before calling
strtod(3). [ruby-dev:34834]
-Sat May 24 22:27:44 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sun Jun 15 23:17:34 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* marshal.c (marshal_load): should initialize arg.data used for
reentrant check. [ruby-dev:34837]
-Sat May 24 00:34:59 2008 Tanaka Akira <akr@fsij.org>
-
- * lib/rational.rb (Rational#to_i): fix rdoc. Rational(-7,4).to_i
- should be -1.
-
-Fri May 23 20:22:44 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * marshal.c (reentrant_check): check reentrance via callcc.
- [ruby-dev:34802]
-
-Fri May 23 16:46:28 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * enumerator.c (proc_call): Remove an unused static function.
-
-Fri May 23 13:46:09 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in (cflags): commit miss.
-
-Fri May 23 09:52:21 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in (MINIRUBY), common.mk (RUBYOPT): add purelib.rb.
- [ruby-core:16642]
-
- * ext/extmk.rb: load purelib.rb only when not cross compiling.
-
-Fri May 23 08:47:02 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * error.c (syserr_eqq): === should be able to handle delegated
- objects as well.
-
-Fri May 23 04:22:19 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/tcltklib.c, ext/tk/tkutil/tkutil.c: fix memory leak.
-
- * ext/tk/lib/tk.rb: avoid trouble when finalize TclTkIp.
-
- * ext/tk/lib/tk.rb, ext/tk/lib/tk/*: help to fix troubles when
- use Ttk widgets on old Tk scripts.
-
- * ext/tk/sample/*: update and add demo scripts. some of them are
- introduction about new features of Tcl/Tk8.5.
-
-Fri May 23 03:48:10 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * class.c (clone_method): Just use ruby_cref as cref.
-
-Fri May 23 01:03:23 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * class.c (rb_singleton_class_clone): Pass Qnil, not 0.
-
-Fri May 23 00:51:48 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * class.c (clone_method): Totally revamp the previous fix which
- was incorrect.
- (rb_mod_init_copy): Ditto.
- (singleton_class_clone_int): Ditto.
-
-Fri May 23 00:48:10 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * eval.c (rb_copy_node_scope), node.h: Rename from copy_node_scope
- and export.
-
-Thu May 22 21:24:15 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sun Jun 15 23:12:02 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* parse.y (top_local_setup): fixed memory leak bug based on a
patch from Roger Pack <rogerpack2005 at gmail.com> in
[ruby-core:16610].
+Sun Jun 15 23:15:35 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-Thu May 22 14:20:54 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * array.c (flatten): check if reentered. [ruby-dev:34798]
-
-Thu May 22 08:28:49 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * array.c (flatten): free memo hash table before raising exception.
- [ruby-dev:34789]
-
-Thu May 22 06:30:10 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * array.c (flatten): fix memory leak.
-
-Thu May 22 05:45:30 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * proc.c (proc_dup): should copy safe_level from src proc
- properly. a patch from Keita Yamaguchi
- <keita.yamaguchi at gmail.com>
-
-Wed May 21 23:31:44 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (rb_get_method_body, rb_alias, rb_eval): should not cache
- uninitialized value, since search_method doesn't set origin if the
- method wasn't found.
-
- * eval.c (search_method, remove_method, error_print, rb_alias)
- (rb_eval, rb_rescue2, search_required, Init_eval, rb_thread_create),
- gc.c (rb_source_filename, Init_stack), io.c (rb_io_getline),
- parse.y (rb_id2name, rb_parser_free): suppress warnings.
-
-Wed May 21 12:34:51 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * hash.c (rb_hash_delete): rdoc fix based on a patch from Gaston Ramos
- <ramos.gaston AT gmail.com>. [ruby-core:16825]
-
-Tue May 20 13:15:46 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * file.c (lchmod_internal): Remove a compiler warning.
-
-Mon May 19 18:22:35 2008 Akinori MUSHA <knu@iDaemons.org>
+ * marshal.c (reentrant_check): check reentrance via callcc.
+ [ruby-dev:34802]
- * ext/openssl/ossl_pkcs5.c (ossl_pkcs5_pbkdf2_hmac): Fix the type
- of md; pointed out by Takahiro Kambe <taca at back-street.net>
- in [ruby-dev:34748].
-Mon May 19 14:20:13 2008 NAKAMURA Usaku <usa@ruby-lang.org>
+Sun Jun 15 23:08:29 2008 NAKAMURA Usaku <usa@ruby-lang.org>
* sprintf.c (rb_f_sprintf): fixed SEGV on win32 with "% 0e" % 1.0/0.0.
-Mon May 19 13:29:58 2008 NAKAMURA Usaku <usa@ruby-lang.org>
+Sun Jun 15 23:06:49 2008 NAKAMURA Usaku <usa@ruby-lang.org>
* process.c (rb_f_system): set last_status when status == -1 because
there is no path to set it on win32. this patch is derived from
[ruby-core:16787], submitted by Luis Lavena <luislavena at gmail.com>
-Mon May 19 13:01:05 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * common.mk ({MSPEC,RUBYSPEC}_GIT_URL): moved from Makefine.in.
-
- * {win32,bcc32}/Makefile.sub (update-rubyspec): added.
-
-Mon May 19 11:53:45 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/openssl/openssl_missing.c (HMAC_CTX_copy): adopted
- prototype change in openssl bundled with newer OpenBSD.
- a patch from Takahiro Kambe <taca at back-street.net> in
- [ruby-dev:34691].
-
-Mon May 19 06:36:37 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * .: Release as Ruby 1.8.7-preview3.
-
-Sun May 18 22:26:51 2008 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Sun Jun 15 22:54:39 2008 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/webrick/httpservlet/filehandler.rb: should normalize path
name in path_info to prevent script disclosure vulnerability on
@@ -1270,54 +98,7 @@ Sun May 18 22:26:51 2008 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/webrick/httpservlet/cgi_runner.rb: accept interpreter
command line arguments.
-Sat May 17 23:53:57 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * file.c (file_expand_path): fix for short file name on Cygwin.
-
-Sat May 17 11:29:11 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * file.c (rb_file_s_extname): first dot is not an extension name.
-
-Sat May 17 10:18:44 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * re.c (rb_reg_search): need to free allocated buffer in re_register.
-
-Fri May 16 17:01:44 2008 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/Makefile.sub (test-rubyspec): added.
-
-Fri May 16 16:22:40 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/tcltklib.c: sometimes freeze when receive Interrupt signal.
-
-Fri May 16 14:54:56 2008 Tanaka Akira <akr@fsij.org>
-
- * Makefile.in (update-rubyspec): move rubyspec to srcdir.
- (test-rubyspec): ditto.
-
-Fri May 16 14:25:22 2008 Tanaka Akira <akr@fsij.org>
-
- * Makefile.in (test-rubyspec): use RUNRUBY. suggested by nobu.
-
-Fri May 16 13:01:43 2008 Tanaka Akira <akr@fsij.org>
-
- * Makefile.in (update-rubyspec): new target to download rubyspec.
- (test-rubyspec): new target to run rubyspec. this doesn't work
- before install.
-
-Fri May 16 08:15:52 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/lib/tk.rb: fix memory (object) leak bug.
-
- * ext/tk/sample/demos-jp/aniwave.rb, ext/tk/sample/demos-en/aniwave.rb:
- bug fix.
-
-Thu May 15 17:00:22 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * string.c (Init_String): Define #bytesize as an alias for #size
- for compatibility with 1.9.
-
-Thu May 15 15:33:59 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 15 22:54:39 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* file.c (file_expand_path): support for alternative data stream
and ignored trailing garbages of NTFS.
@@ -1326,93 +107,22 @@ Thu May 15 15:33:59 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* file.c (rb_file_s_extname): ditto.
-Wed May 14 19:24:59 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * array.c (rb_ary_count): Override Enumerable#count for better
- performance.
- (rb_ary_nitems): Undo the backport. Use #count {} instead.
-
- * enumerator.c (enumerator_iter_i): Remove an unused function.
- (enumerator_with_index, enumerator_each): Remove unused
- variables.
-
-Wed May 14 17:15:11 2008 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * ext/tk/tkutil/extronf.rb: check stdndup() because it's not standard
- function of C.
-
- * ext/tk/tkutil/tkutil.c (cbsubst_table_setup): use malloc() and
- strncpy() instead of strndup() if not available.
-
-Wed May 14 09:52:02 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/tkutil/tkutil.c: improve handling callback-subst-keys.
- Now, support longnam-keys (e.g. '%CTT' on tkdnd-2.0; however, still
- not support tkdnd-2.0 on tkextlib), and symbols of parameters (e.g.
- :widget=>'%W', :keycode=>'%k', '%x'=>:x, '%X'=>:root_x, and so on;
- those are attributes of event object). It means that Ruby/Tk accepts
- not only "widget.bind(ev, '%W', '%k', ...){|w, k, ...| ... }", but
- also "widget.bind(ev, :widget, :keycode, ...){|w, k, ...| ... }".
- It is potentially incompatible, when user passes symbols to the
- arguments of the callback block (the block receives the symbols as
- strings). I think that is very rare case (probably, used by Ruby/Tk
- experts only). When causes such trouble, please give strings instead
- of such symbol parameters (e.g. call Symbol#to_s method).
-
- * ext/tk/lib/tk/event.rb, ext/tk/lib/tk/validation.rb,
- ext/tk/lib/tkextlib/blt/treeview.rb,
- ext/tk/lib/tkextlib/winico/winico.rb: ditto.
-
- * ext/tk/tkutil/tkutil.c: strings are available on subst_tables on
- TkUtil::CallbackSubst class (it is useful on Ruby 1.9).
-
- * ext/tk/lib/tk/spinbox.rb, ext/tk/lib/tkextlib/iwidgets/hierarchy.rb,
- ext/tk/lib/tkextlib/iwidgets/spinner.rb,
- ext/tk/lib/tkextlib/iwidgets/entryfield.rb,
- ext/tk/lib/tkextlib/iwidgets/calendar.rb,
- ext/tk/lib/tkextlib/blt/dragdrop.rb,
- ext/tk/lib/tkextlib/tkDND/tkdnd.rb,
- ext/tk/lib/tkextlib/treectrl/tktreectrl.rb,
- ext/tk/lib/tkextlib/tktable/tktable.rb: disable code piece became
- unnecessary by reason of the changes of ext/tk/tkutil/tkutil.c.
-
-Tue May 13 15:10:50 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * enumerator.c: Update rdoc.
- (enumerator_initialize): Discourage the use.
- (enum_each_slice, enum_each_cons, enumerator_each)
- (enumerator_with_index): Add a note about a call without a block.
-
- * NEWS: Intentionally omit enum_slice and enum_cons, which are
- removed in 1.9.
-
-Tue May 13 07:56:36 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sun Jun 15 22:52:24 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (rb_str_cat): fixed buffer overrun reported by
Christopher Thompson <cthompson at nexopia.com> in [ruby-core:16746]
-Mon May 12 13:57:19 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sun Jun 15 22:50:34 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (is_defined): add NODE_OP_ASGN_{OR,AND}. "defined?(a||=1)"
should not operate assignment. [ruby-dev:34645]
-Mon May 12 12:59:23 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/lib/tk/wm.rb: Wm#overrideredirect overwrites arguemnt to
- an invalid value.
-
- * ext/tk/sample/ttk_wrapper.rb: support "if __FILE__ == $0" idiom.
-
-Mon May 12 12:36:55 2008 NAKAMURA Usaku <usa@ruby-lang.org>
+Sun Jun 15 22:49:12 2008 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.c (rb_w32_select): backport from trunk.
[ruby-talk:300743]
-Mon May 12 12:33:21 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * common.mk (RUBYLIB, RUBYOPT): clear.
-
-Mon May 12 10:41:10 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 15 22:47:37 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/delegate.rb (SimpleDelegator::dup): removed needless argument.
[ruby-list:44910]
@@ -1420,111 +130,24 @@ Mon May 12 10:41:10 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/delegate.rb (clone, dup): keep relationship with the target
object.
-Sun May 11 23:19:39 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * enum.c (all_iter_i, any_iter_i): reduced duplicated code.
-
-Sun May 11 17:57:36 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in (MINIRUBY): should not include extension library path.
-
-Sun May 11 10:36:10 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
-
- * eval.c (method_name, method_owner): New methods; backported
- from 1.9. (UnboundMethod#name, UnboundMethod#owner)
-
-Sun May 11 02:48:13 2008 <nagai@orca16.orcabay.ddo.jp>
-
- * ext/tk/lib/tk/pack.rb, ext/tk/lib/tk/grid.rb: fail to do pack/grid
- without options.
-
- * ext/tk/lib/tk.rb: add TkWindow#grid_anchor, grid_column, grid_row.
-
-Sat May 10 18:19:16 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_each_line): RDoc updated. [ruby-dev:34586]
-
-Sat May 10 13:17:56 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/lib/tk/pack.rb, ext/tk/lib/tk/grid.rb: increase supported
- parameter patterns of configure method.
-
-Sat May 10 09:16:13 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sun Jun 15 22:45:19 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* util.c (ruby_strtod): backported from 1.9. a patch from Satoshi
Nakagawa <psychs at limechat.net> in [ruby-dev:34625].
fixed: [ruby-dev:34623]
-Fri May 9 23:33:25 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/lib/tk/wm.rb: methods of Tk::Wm_for_General module cannot
- pass the given block to methods of Tk::Wm module.
-
- * ext/tk/lib/tk/grid.rb: lack of module-method definitions.
-
- * ext/tk/lib/tkextlib/tile.rb: lack of autoload definitions.
-
- * ext/tk/lib/tkextlib/tile/tnotebook.rb: cannot use kanji (not UTF-8)
- characters for headings.
-
- * ext/tk/tcltklib.c: maybe a little more stable about @encoding value
- of TclTkIp object.
-
-Wed May 7 08:46:44 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sun Jun 15 22:43:39 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* struct.c (rb_struct_s_def): to_str should be called only once.
[ruby-core:16647]
-Wed May 7 00:54:25 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sun Jun 15 22:41:49 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/zlib/zlib.c (gzreader_gets): may cause infinite loop.
a patch from Kouya <kouyataifu4 at gmail.com> in
[ruby-reference-manual:762].
-Sun May 4 09:35:51 2008 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-
- * sample/erb/erb4html.rb (ERB4Html) : add example of ERB#set_eoutvar.
- ERB4Html is an auto-quote ERB.
-
-Sat May 3 22:52:48 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/lib/tkextlib/tile.rb, ext/tk/lib/tkextlib/tile/style.rb,
- ext/tk/sample/ttk_wrapper.rb: improve treating and control themes.
- add Tk::Tile.themes and Tk::Tile.set_theme(theme).
-
-Fri May 2 14:52:33 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * misc/ruby-mode.el: move fontifying code from hook. a patch from
- Phil Hagelberg <phil at hagelb.org> in [ruby-core:16636].
-
-Fri May 2 13:47:51 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * re.c (match_select): restore previous behavior of MatchData#select.
- RDoc updated as well, mentioning the plan to remove this method
- in the future. [ruby-dev:34556]
-
-Fri May 2 13:04:04 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/dbm/dbm.c (Init_dbm): defines DBM::VERSION even when
- DB_VERSION_STRING is not available. [ruby-dev:34569]
-
-Thu May 1 23:57:06 2008 James Edward Gray II <jeg2@ruby-lang.org>
-
- Merged 16257 from trunk.
-
- * lib/net/telnet.rb: This patch from Brian Candler adds a FailEOF mode which
- can be activated to have net/telnet raise EOFError exceptions when the
- remote connection is closed. The default behavior remains unchanged though.
-
-Thu May 1 23:43:21 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * range.c (range_step): check if step can be converted to an integer.
- [ruby-dev:34558]
-
- * range.c (range_step): allow float step bigger than zero but less
- than one. [ruby-dev:34557]
-
-Wed Apr 30 20:22:40 2008 James Edward Gray II <jeg2@ruby-lang.org>
+Sun Jun 15 22:32:39 2008 James Edward Gray II <jeg2@ruby-lang.org>
Merged 16241 from trunk.
@@ -1532,214 +155,32 @@ Wed Apr 30 20:22:40 2008 James Edward Gray II <jeg2@ruby-lang.org>
escaped when the two character ending was broken up into separate TCP
packets. Issue reported and patched by Brian Candler.
-Wed Apr 30 17:47:21 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 15 22:30:30 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* re.c (rb_reg_search): use local variable. a patch from wanabe
<s.wanabe AT gmail.com> in [ruby-dev:34537]. [ruby-dev:34492]
-Sat Apr 26 19:40:34 2008 Guy Decoux <decoux@moulon.inra.fr>
-
- * class.c (struct clone_method_data): Add cref.
- (clone_method): Properly handle NODE_BMETHOD and NODE_DMETHOD.
- (rb_singleton_class_clone, singleton_class_clone_int): Set a
- proper value to klass and propagate cref. [ruby-core:16238]
-
- * eval.c (rb_block_dup, rb_method_dup), intern.h: Add duplicator
- methods for use from class.c#clone_method().
-
-Fri Apr 25 15:46:37 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/lib/tk.rb, ext/tk/lib/tk/scrollbar.rb, ext/tk/lib/tk/scale.rb:
- improve unknonw-option check when create a widget.
-
- * ext/tk/lib/tkextlib/blt/unix_dnd.rb, ext/tk/lib/tkextlib/blt/ted.rb,
- ext/tk/lib/tkextlib/treectrl/tktreectrl.rb: bug fix on 'cget'.
-
- * ext/tk/lib/tk/menuspec.rb: option check will fail when
- TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__ is true.
-
- * ext/tk/lib/tk/palette.rb: bug fix.
-
-Fri Apr 25 12:37:54 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * array.c (flatten): returns an instance of same class.
- [ruby-core:16554]
-
-Thu Apr 24 23:47:50 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
-
- * lib/net/pop.rb: backported from 1.9. bug#19003
-
- * ext/openssl/lib/openssl/ssl.rb: set_params; backported from 1.9.
- bug#19552, [ruby-dev:34402]
-
- * ext/openssl/ossl_ssl.c: ditto.
-
- * test/openssl/test_ssl.rb: ditto.
-
-Thu Apr 24 17:06:34 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (THREAD_SAVE_CONTEXT): remove unnecessary
- FLUSH_REGISTER_WINDOWS before calling setjmp(). [ruby-core:16285]
-
-Thu Apr 24 14:15:11 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 15 22:21:07 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* dln.c (dln_find_1): prior files with extensions to files sans
extensions. [ruby-core:16517]
-Wed Apr 23 15:39:31 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * eval.c (bind_eval): Add Binding#eval, a shorthand method for
- eval(str, binding, ..); backported from 1.9.
-
-Wed Apr 23 15:28:52 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
-
- * test/gdbm/test_gdbm.rb (TestGDBM#test_s_open_no_create): failed
- notice moved from comment to assertion message. [ruby-dev:29127]
-
-Wed Apr 23 14:00:05 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * lib/mkmf.rb (create_makefile): Add a missing dependency on the
- target directory for each .rb file. This will hopefully fix
- parallel make (-jN). Tested on FreeBSD.
-
-Wed Apr 23 11:49:54 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * lib/set.rb (Set#each, SortedSet#each, TC_Set#test_each): Return
- an enumerator if no block is given.
-
-Wed Apr 23 00:42:49 2008 Tanaka Akira <akr@fsij.org>
-
- * eval.c (error_print): show full stack grace except SystemStackError.
- backport from 1.9. [ruby-dev:31014]
-
-Wed Apr 23 00:18:45 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
-
- * test/ruby/test_symbol.rb (TestSymbol#test_to_proc): Improve
- tests of Symbol#to_proc.
-
-Tue Apr 22 22:43:05 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * eval.c (rb_proc_new, YIELD_FUNC_LAMBDA): Add a new nd_state
- YIELD_FUNC_LAMBDA which avoids automatic `avalue' conversion for
- arguments. This fixes a bug where [1,[2,3]].map(&:object_id)
- fails.
-
- * intern.h, object.c: Hide rb_proc_new() from intern.h. It should
- not be considered an official API function yet.
-
-Tue Apr 22 21:24:32 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * eval.c (rb_proc_new): Turn the BLOCK_LAMBDA flag on.
-
- * object.c (sym_to_proc), test/ruby/test_symbol.rb: Add back
- Symbol#to_proc, now that it passes the tests.
-
-Tue Apr 22 19:35:03 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * enumerator.c (enumerator_initialize): Remove an undocumented
- feature (passing a block to the constructor) that's broken.
- This is not what I intended.
-
-Tue Apr 22 17:49:46 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sun Jun 15 22:19:33 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* sprintf.c (rb_f_sprintf): should protect temporary string from
GC. [ruby-dev:34480]
-Tue Apr 22 17:12:05 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sun Jun 15 22:17:35 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* regex.c (re_search): string might be NULL. [ruby-core:16478]
-Tue Apr 22 16:44:00 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
-
- * object.c (rb_obj_tap): Correct documentation; pointed out by
- okkez in [ruby-dev:34472].
-
-Tue Apr 22 10:05:51 2008 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * file.c (eaccess): workaround for recent msvcrt's behavior.
- [ruby-core:16460]
-
-Mon Apr 21 16:06:47 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * enumerator.c (enumerator_init): preserve the method name in ID.
-
- * enumerator.c (enumerator_each): need not to call rb_to_id().
-
- * enumerator.c (enumerator_with_index): ditto.
-
-Mon Apr 21 17:19:52 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * eval.c (rb_f_method_name): New gloval function: __method__;
- backported from matzruby / 1.9.
-
- * eval.c (rb_frame_this_func), intern.h: New internal function.
-
- * intern.h (RETURN_ENUMERATOR): Use rb_frame_this_func() instead
- of rb_frame_last_func(), to accommodate the behavior to that of
- 1.9.
-
-Mon Apr 21 15:54:48 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/tempfile.rb (Tempfile::_close): check @data before modifying
- it; backported from 1.9. [ruby-dev:34094]
-
- * lib/tempfile.rb (Tempfile::close): clear @data and @tmpname.
-
-Mon Apr 21 10:17:17 2008 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * time.c: should include <errno.h> to refer errno.
-
-Mon Apr 21 10:02:43 2008 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * hash.c (recursive_hash): prototype.
-
-Mon Apr 21 10:00:51 2008 NAKAMURA Usaku <usa@ruby-lang.org>
+Sun Jun 15 22:13:13 2008 NAKAMURA Usaku <usa@ruby-lang.org>
* time.c (rb_strftime): check errno to detect strftime(3)'s error.
this is workaround for recent version of MSVCRT.
[ruby-dev:34456]
-Sun Apr 20 21:10:04 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * .: Release as Ruby 1.8.7-preview2.
-
-Sun Apr 20 21:02:06 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * enumerator.c: Resolve the method every time an enumeration
- method is run, not once when the enumerator is initialized as it
- was before, so that method_missing() and method (re)definition
- afterwards are both in effect; pointed out in: [ruby-core:16441]
-
-Sun Apr 20 17:59:25 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * object.c, NEWS, test/ruby/test_symbol.rb: Revert Symbol#to_proc
- since it does not pass the tests.
-
-Sun Apr 20 14:29:35 2008 Technorama Ltd. <oss-ruby@technorama.net>
-
- * ext/openssl/ossl_ssl.c: initialize session class.
-
-Sat Apr 19 20:54:42 2008 akira yamada <akira@arika.org>
-
- * lib/uri/ftp.rb, lib/uri/generic.rb, test/uri/test_common.rb,
- test/uri/test_ftp.rb, test/uri/test_generic.rb: backported from 1.9.
- [ruby-dev:31318]
-
-Sat Apr 19 20:35:02 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * lib/yaml/baseemitter.rb, lib/yaml/encoding.rb: performance
- tuning around String#gsub.
-
- * lib/yaml/tag.rb: Replace nodoc with stopdoc so Module methods get
- documented.
-
- * lib/yaml/store.rb (YAML::load): modified to support empty
- database.
-
- * lib/yaml/store.rb (YAML::Store::marshal_dump_supports_canonical_option?):
- add a method to support faster PStore.
-
-Sat Apr 19 20:16:52 2008 Akinori MUSHA <knu@iDaemons.org>
+Sun Jun 15 22:10:14 2008 Akinori MUSHA <knu@iDaemons.org>
* lib/yaml/types.rb: Likewise, pass self to YAML::quick_emit;
merged from 1.9.
@@ -1749,577 +190,41 @@ Sat Apr 19 20:16:52 2008 Akinori MUSHA <knu@iDaemons.org>
objects during output of YAML. [ruby-Bugs-8548] [ruby-Bugs-3698];
merged from 1.9.
-Sat Apr 19 20:05:39 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * array.c (rb_ary_equal, rb_ary_eql, rb_ary_hash, rb_ary_cmp):
- Make Array#eql?, #hash, #== and #<=> use rb_exec_recursive() and
- handle recursive data properly.
-
- * hash.c (hash_equal, rb_hash_hash): Make Hash#eql?, #hash and #==
- use rb_exec_recursive() and handle recursive data properly.
-
-Sat Apr 19 19:26:09 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * intern.h, eval.c (rb_exec_recursive): New internal function to
- help perform recursive operation; backported from 1.9.
-
-Sat Apr 19 18:42:04 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * intern.h, hash.c (rb_hash_lookup): New internal function to
- check if a key exists in a hash, ignoring #default; backported
- from 1.9.
-
-Fri Apr 18 18:56:57 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/syck/rubyext.c (syck_genericresolver_node_import): should
- not set instance variable "@kind" before initializing it.
- [ruby-dev:32677]
-
- * ext/syck/rubyext.c (syck_resolver_initialize,
- syck_resolver_detect_implicit, syck_emitter_emit): remove unused
- variables.
-
-Fri Apr 18 18:54:57 2008 Akinori MUSHA <knu@iDaemons.org>
+Sun Jun 15 22:05:45 2008 Akinori MUSHA <knu@iDaemons.org>
* ext/syck/rubyext.c: Node#value defined twice.
* lib/yaml/: several method redefinitions causing warnings.
-Fri Apr 18 16:36:16 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * lib/rexml/node.rb (REXML::Node::indent): should initialize rv
- variable. a patch from Tadayoshi Funaba <tadf AT dotrb.org> in
- [ruby-dev:32783].
-
-Fri Apr 18 16:01:37 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * lib/rexml: Merge fixes since 1.8.6 made solely on the ruby_1_8_6
- branch.
-
-Wed Apr 16 06:11:49 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * test/ruby/test_settracefunc.rb (TestSetTraceFunc#test_event):
- Fix tests to reflect the following changes: r15833, r15759.
-
-Wed Apr 16 05:03:48 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * .: Release as Ruby 1.8.7-preview1.
-
-Wed Apr 16 02:09:14 2008 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/xmlrpc/client.rb: fix cookie handling. [ruby-dev:34403]
-
- * test/xmlrpc/test_cookie.rb: add a test for the above fix.
-
-Tue Apr 15 23:48:28 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * version.h: Branch off ruby_1_8_7 from ruby_1_8 in preparation
- for the forthcoming 1.8.7 release.
-
-Tue Apr 15 23:40:39 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/syck/rubyext.c (rb_syck_mktime): Avoid buffer overflow.
-
-Tue Apr 15 20:32:03 2008 Tanaka Akira <akr@fsij.org>
-
- * re.c (match_inspect): backported from 1.9.
-
-Tue Apr 15 19:03:28 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
-
- * eval.c (method_receiver, method_name, method_owner): New
- methods; backported from 1.9. bug#19007
-
-Tue Apr 15 18:39:14 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
-
- * lib/uri.rb, lib/uri/ldaps.rb: added LDAPS
- scheme; backported from 1.9. bug#19015, [ruby-dev:31896]
-
-Tue Apr 15 17:45:43 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
-
- * lib/net/smtp.rb: backported from 1.9. bug#19003
-
-Tue Apr 15 17:06:12 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
-
- * test/ruby/test_symbol.rb (TestSymbol#test_to_proc): add tests.
-
-Tue Apr 15 16:58:55 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/lib/tk/menuspec.rb: option check will fail when
- TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__ is true.
-
- * ext/tk/lib/tk/palette.rb: bug fix.
-
-Tue Apr 15 16:47:48 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
-
- * signal.c, gc.c: New methods: GC.stress, GC.stress=;
- backported from 1.9. a patch from Tadashi Saito
- in [ruby-dev:34394] and bug#19000
-
-Tue Apr 15 12:35:44 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * rubyio.h (rb_io_t): renamed from OpenFile.
-
- * ruby.h (struct RHash), file.c, gc.c, io.c, ext/dl/dl.c,
- ext/io/wait/wait.c, ext/pty/pty.c, ext/readline/readline.c,
- ext/socket/socket.c: ditto.
-
- * win32/win32.h: removed workaround for OpenFile.
-
-Tue Apr 15 00:15:29 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/lib/tk/text.rb: typo. call a wrong method.
-
- * ext/tk/lib/tk/itemconfig.rb: ditto.
-
- * ext/tk/sample/ttk_wrapper.rb: bug fix.
-
- * ext/tk/sample/tktextio.rb: add binding for 'Ctrl-u' at console mode.
-
- * ext/tk/lib/tk.rb, ext/tk/lib/tk/itemfont.rb, ext/tk/lib/font.rb:
- support __IGNORE_UNKNOWN_CONFIGURE_OPTION__ about font options.
-
- * ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb,
- ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb,
- ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb: bug fix.
-
- * ext/tk/lib/tkextlib/tile/tpaned.rb: improve TPaned#add.
-
- * ext/tk/lib/tk/timer.rb: add TkTimer#at_end(proc) to register the
- procedure which called at end of the timer.
-
-Mon Apr 14 19:54:21 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * array.c (rb_ary_flatten, rb_ary_flatten_bang): Take an optional
- argument that determines the level of recursion to flatten;
- backported from 1.9.
-
- * array.c (rb_ary_shuffle_bang, rb_ary_shuffle, rb_ary_choice,
- rb_ary_cycle, rb_ary_permutation, rb_ary_combination,
- rb_ary_product, rb_ary_take, rb_ary_take_while, rb_ary_drop,
- rb_ary_drop_while): New methods: Array#shuffle, #shuffle!,
- #choice, #cycle, #permutation, #combination, #product, #take,
- #take_while, #drop, #drop_while; backported from 1.9.
-
-Mon Apr 14 19:52:35 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * ruby.h: New macro: RB_GC_GUARD().
-
-Mon Apr 14 19:49:35 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * random.c (rb_genrand_int32, rb_genrand_real), intern.h: Export.
-
- * string.c (rb_str_tmp_new), intern.h: New function.
-
-Mon Apr 14 19:18:55 2008 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * enum.c (inject_i, inject_op_i): prototype.
-
-Mon Apr 14 19:10:47 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * enum.c New methods: Enumerable#take, #take_while, #drop and
- #drop_while; backported from 1.9.
-
-Mon Apr 14 18:50:15 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * enum.c: New methods: Enumerable#one?, #none?, #minmax, #min_by,
- #max_by, #minmax_by and #cycle; backported from 1.9.
-
- * enum.c (enum_find_index): Add support for find_index(obj);
- [ruby-dev:34313]; backported from 1.9.
-
- * enum.c (enum_inject): Add support for Enumerable#inject(:binop);
- backported from 1.9.
-
- * enum.c: Alias Enumerable#reject to #inject; backported from 1.9.
-
-Mon Apr 14 18:14:19 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * enum.c (enum_find, enum_reject): Return an enumerator if no
- block is given; backported from 1.9.
-
- * io.c (rb_io_each_line, rb_io_each_byte, rb_io_s_foreach,
- argf_each_line, argf_each_byte): Ditto.
-
- * string.c (str_gsub): Ditto.
-
-Mon Apr 14 18:10:05 2008 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * enum.c (find_index_i, find_index_iter_i): add prototype for VC.
-
-Mon Apr 14 17:55:30 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * array.c (rb_ary_collect_bang, rb_ary_select): Return an
- enumerator if no block is given; backported from 1.9.
-
- * dir.c (dir_each, dir_foreach): Ditto.
-
- * enum.c (enum_partition, enum_sort_by): Ditto.
-
- * gc.c (os_each_obj): Ditto.
-
- * hash.c (rb_hash_delete_if, rb_hash_reject_bang, rb_hash_select,
- rb_hash_each_value, rb_hash_each_key, rb_hash_each_pair,
- env_each_key, env_each_value, env_each, env_each_pair,
- env_reject_bang, env_delete_if, env_select): Ditto.
-
- * numeric.c (num_step, int_upto, int_downto, int_dotimes): Ditto.
-
-Mon Apr 14 16:42:53 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * ruby.h (rb_block_call_func): Fix prototype.
-
- * enumerator.c (enumerator_iter_i, enumerator_each_i): Ditto.
-
-Mon Apr 14 15:49:05 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * enum.c (enum_count, enum_find_index): New methods:
- Enumerable#count and #find_index; backported from 1.9.
-
-Mon Apr 14 14:16:08 2008 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * enumerator.c (enumerator_mark, enumerator_iter_i, enumerator_each_i,
- enumerator_allocate): add prototype.
-
- * enumerator.c (enumerator_each_i): declare unused two arguments.
-
-Mon Apr 14 13:58:32 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * string.c (rb_str_each_char): New methods: String#chars and
- #each_char; backported from 1.9.
-
-Mon Apr 14 13:42:20 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * string.c (rb_str_each_line, rb_str_each_byte): Reflect
- enumerator integration. #lines and #bytes are now aliases to
- #each_line and #each_byte, respectively.
-
-Mon Apr 14 13:19:36 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * range.c (range_each, range_step): Return an enumerator if no
- block is given; backported from 1.9.
-
- * struct.c (rb_struct_each, rb_struct_each_pair): Ditto.
-
-Mon Apr 14 13:07:59 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * string.c (rb_str_partition, rb_str_rpartition,
- rb_str_start_with, rb_str_end_with): New methods:
- String#partition, #rpartition, #start_with? and #end_with?;
- backported from 1.9. These methods are $KCODE aware unlike
- #index, #rindex and #include?.
-
-Sun Apr 13 15:55:52 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
-
- * object.c (sym_to_proc): new method Symbol#to_proc; backported
- from 1.9. bug#19012
-
-Fri Apr 11 19:14:30 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
-
- * object.c (rb_obj_tap): new method Object#tap; backported from
- 1.9. bug#19008
-
-Fri Apr 11 18:58:09 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
-
- * process.c: new method Process.exec; backported from 1.9. bug#19006
-
-Fri Apr 11 12:43:56 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/lib/tkextlib/tile.rb, ext/tk/lib/tkextlib/tile/style.rb,
- ext/tk/sample/tkextlib/tile/demo.rb: previous patch is not complete.
-
-Fri Apr 11 10:22:54 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/lib/tkextlib/tile.rb:
- __define_LoadImages_proc_for_compatibility__! do nothing when the
- Tcl command exists.
-
- * ext/tk/lib/tkextlib/tile/style.rb:
- __define_wrapper_proc_for_compatibility__! do nothing when the Tcl
- command exists.
-
- * ext/tk/sample/tkextlib/tile/demo.rb: don't create 'step' theme if
- it already exists.
-
-Fri Apr 11 08:05:12 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sun Jun 15 22:03:36 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* 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].
-Thu Apr 10 20:29:13 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * misc/rdebug.el, misc/README: Remove rdebug.el as per request
- from the maintainer and mention the ruby-debug project at
- RubyForge in README; bug#19043.
-
-Thu Apr 10 20:08:37 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * enum.c (enum_first, enum_group_by): New methods:
- Enumerable#first and #group_by; backported from 1.9.
-
-Thu Apr 10 19:49:10 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * enumerator.c (rb_eStopIteration), eval.c (rb_f_loop), ruby.h:
- Add a new exception class StopIteration, which breaks Kernel#loop
- iteration when raised; backported from 1.9.
-
- * enumerator.c (enumerator_next, enumerator_rewind): Implement
- #next and #rewind using the "generator" library.
-
- * lib/generator.rb: Implement Enumerable::Enumerator#next and
- #rewind.
-
-Thu Apr 10 19:29:48 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * array.c (rb_ary_first, rb_ary_last): Return a shared array when
- possible.
-
- * array.c (rb_ary_pop, rb_ary_pop_m, rb_ary_shift, rb_ary_shift_m):
- Array#pop and Array#shift can take an optional argument
- specifying the number of elements to remove and return;
- backported from 1.9.
-
-Thu Apr 10 14:00:44 2008 Tanaka Akira <akr@fsij.org>
-
- * lib/resolv.rb (Resolv::DNS#each_address): backport from 1.9 for
- CNAME. [ruby-dev:34200]
-
-Thu Apr 10 01:42:25 2008 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * enum.c (iterate_method): add prototype to avoid warning on VC++.
-
-Wed Apr 9 23:12:41 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/tcltklib.c: SEGV when tcltk-stubs is enabled.
-
- * ext/tk/tcltklib.c: avoid error on a shared object.
-
- * ext/tk/extconf.rb: support --with-tcltkversion
-
- * ext/tk/README.tcltklib: add document about --with-tcltkversion
-
- * ext/tk/sample/demos-jp/widget, ext/tk/sample/demos-en/widget,
- ext/tk/sample/demos-jp/style.rb, ext/tk/sample/demos-en/style.rb,
- ext/tk/sample/demos-jp/bind.rb, ext/tk/sample/demos-en/bind.rb:
- bug fix.
-
-Wed Apr 9 21:54:45 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * array.c (rb_ary_pop): Do not reallocate too often; backported
- from 1.9.
-
-Wed Apr 9 21:13:05 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * array.c (rb_ary_each, rb_ary_each_index, rb_ary_reverse_each,
- rb_ary_reject, rb_ary_reject_bang): Array#each, #each_index,
- #reverse_each, #reject, #reject! and #delete_if return an
- enumerator if no block is given; backported from 1.9.
-
-Wed Apr 9 20:47:16 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * array.c (rb_ary_index, rb_ary_index): Array#index and #rindex
- can take a block instead of an argument; backported from 1.9.
-
-Wed Apr 9 19:58:31 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * enumerator.c, inits.c (rb_call_inits), ruby.h, intern.h,
- ext/enumerator, common.mk (OBJS, enumerator.$(OBJEXT)): Make the
- enumerator module built-in.
-
- * enumerator.c: New method: Enumerable::Enumerator#with_index.
-
- * enum.c (enum_each_with_index): Enumerable#each_with_index now
- returns an enumerator instead of raising an exception if no
- block is given. Enumerable#enum_with_index, formerly defined in
- the enumerator module, is kept as an alias to each_with_index
- for backward compatibility.
-
-Wed Apr 9 19:43:51 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * eval.c (rb_obj_method, rb_proc_call), intern.h: Export.
-
-Tue Apr 8 11:11:28 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (EXEC_TAG): remove unnecessary FLUSH_REGISTER_WINDOWS for
- better performance on SPARC. [ruby-core:16159]
-
-Tue Apr 8 10:49:54 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sun Jun 15 21:57:19 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* re.c (rb_reg_quote): should always copy the quoting string.
[ruby-core:16235]
-Mon Apr 7 21:35:08 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * array.c (rb_ary_nitems): Backport Array#nitems with a block;
- suggested by Bertram Scharpf <lists@bertram-scharpf.de> in
- [ruby-talk:134083].
-
-Sun Apr 6 09:45:00 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * dir.c (dir_tell): check if closed. [ruby-core:16223]
-
-Sat Apr 5 10:05:00 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * object.c (rb_check_to_integer): backported for range_step.
-
-Fri Apr 4 05:57:11 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sun Jun 15 21:26:54 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/net/pop.rb (Net::POP3::do_finish): clear @n_mails and
@n_bytes as well. [ruby-core:16144]
-Fri Apr 4 02:17:06 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * range.c (range_step): should not round step into integer if
- begin and end are numeric. [ruby-core:15990]
-
-Tue Apr 1 14:43:38 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in: get rid of empty expansion.
-
- * {bcc,win}32/Makefile (config.h): need to define RUBY_SETJMP, etc.
-
-Tue Apr 1 11:36:19 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in: _setjmp is available but _longjmp is not on mingw.
-
-Tue Apr 1 03:20:40 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in (RUBY_SETJMP, RUBY_LONGJMP, RUBY_JMP_BUF): prefers
- _setjmp over setjmp and sigsetjmp. [ruby-core:16023]
- __builtin_setjmp cannot handle a variable.
-
- * configure.in (--with-setjmp-type): new option to override the
- default rule in the above.
-
- * eval_intern.h (ruby_setjmp, ruby_longjmp), gc.c (rb_setjmp),
- vm_core.h (rb_jmpbuf_t): use RUBY_SETJMP, RUBY_LONGJMP and
- RUBY_JMP_BUF.
-
-Tue Apr 1 01:55:52 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 15 21:07:37 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/resolv.rb (Resolv::Config.default_config_hash): requires
win32/resolv to use Win32::Resolv. [ruby-dev:34138]
-Mon Mar 31 14:51:11 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * bignum.c (rb_big_div): Bignum#div should return integer for
- floating number operand.
-
-Sun Mar 30 07:00:32 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/tk/tcltklib.c: rb_hash_lookup has not been backported yet.
-
-Sat Mar 29 14:18:41 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/*: full update Ruby/Tk to support Ruby(1.9|1.8) and Tc/Tk8.5.
-
- * ext/tk/lib/tkextlib/tile.rb: [incompatible] remove TileWidgets'
- instate/state/identify method to avoid the conflict with standard
- widget options. Those methods are renamed to ttk_instate/ttk_state/
- ttk_identify (tile_instate/tile_state/tile_identify are available
- too). Although I don't recommend, if you realy need old methods,
- please define "Tk::USE_OBSOLETE_TILE_STATE_METHOD = true" before
- "require 'tkextlib/tile'".
-
- * ext/tk/lib/tkextlib/tile.rb: "Tk::Tile::__Import_Tile_Widgets__!"
- is obsolete. It outputs warning. To control default widget set,
- use "Tk.default_widget_set = :Ttk".
-
- * ext/tk/lib/tk.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__ method and
- __set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method are defind
- as module methods of TkConfigMethod. It may help users to wrap old
- Ruby/Tk scripts (use standard widgets) to force to use Ttk widgets.
- Ttk widgets don't have some options of standard widgets which are
- control the view of widgets. When set ignore-mode true, configure
- method tries to ignoure such unknown options with no exception.
- Of course, it may raise other troubles on the GUI design.
- So, those are a little danger methods.
-
- * ext/tk/lib/tk/itemconfig.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__
- method and __set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method
- are defind as module methods of TkItemConfigMethod as the same
- purpose as TkConfigMethod's ones.
-
- * ext/tk/sample/ttk_wrapper.rb: A new example. This is a tool for
- wrapping old Ruby/Tk scripts (which use standard widgets) to use
- Ttk (Tile) widgets as default.
-
- * ext/tk/sample/tkextlib/tile/demo.rb: use ttk_instate/ttk_state
- method instead of instate/state method.
-
- * ext/tk/lib/tk/root, ext/tk/lib/tk/namespace.rb,
- ext/tk/lib/tk/text.rb, ext/tk/lib/tkextlib/*: some 'instance_eval's
- are replaced to "instance_exec(self)".
-
- * ext/tk/lib/tk/event.rb: bug fix on KEY_TBL and PROC_TBL (?x is not
- a character code on Ruby1.9).
-
- * ext/tk/lib/tk/variable.rb: support new style of operation argument
- on Tcl/Tk's 'trace' command for variables.
-
- * ext/tk/sample/demos-jp/widget, ext/tk/sample/demos-en/widget: bug fix
-
- * ext/tk/sammple/demos-jp/textpeer.rb,
- ext/tk/sammple/demos-en/textpeer.rb: new widget demo.
-
- * ext/tk/tcltklib.c: decrase SEGV troubles (probably)
-
- * ext/tk/lib/tk.rb: remove Thread.critical access if Ruby1.9
-
- * ext/tk/lib/tk/multi-tk.rb: support Ruby1.9 (probably)
-
- * ext/tk/lib/tkextlib/tile.rb: add method to define Tcl/Tk command
- to make Tcl/Tk theme sources (based on different version of Tile
- extension) available.
- (Tk::Tile::__define_LoadImages_proc_for_comaptibility__)
-
- * ext/tk/lib/tk.rb, ext/tk/lib/tk/wm.rb: support dockable frames
- (Tcl/Tk8.5 feature). 'wm' command can treat many kinds of widgets
- as toplevel widgets.
-
- * ext/tk/lib/tkextlib/tile/style.rb: ditto.
- (Tk::Tile::Style.__define_wrapper_proc_for_compatibility__)
-
- * ext/tk/lib/tk/font.rb: add actual_hash and metrics_hash to get
- properties as a hash. metrics_hash method returns a boolean value
- for 'fixed' option. But metrics method returns numeric value
- (0 or 1) for 'fixed' option, because of backward compatibility.
-
- * ext/tk/lib/tk/timer.rb: somtimes fail to set callback procedure.
-
- * ext/tk/lib/tk.rb: add Tk.sleep and Tk.wakeup method. Tk.sleep
- doesn't block the eventloop. It will be better to use the method
- in event callbacks.
-
- * ext/tk/sample/tksleep_sample.rb: sample script about Tk.sleep.
-
-Sat Mar 29 04:08:59 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * class.c (clone_method): should copy cref as well.
- [ruby-core:15833]
-
-Mon Mar 24 20:07:42 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * eval.c (rb_eval): Call trace hook for if expression after the
- condition has been evaluated, not before; submitted by Rocky
- Bernstein in #18722.
-
-Mon Mar 24 19:44:53 2008 Akinori MUSHA <knu@iDaemons.org>
+Sun Jun 15 20:52:45 2008 Akinori MUSHA <knu@iDaemons.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.
-Mon Mar 24 10:25:54 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in: sitearch should use target_cpu. [ruby-core:15986]
-
-Mon Mar 24 01:24:24 2008 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-
- * lib/erb.rb (result): use proc instead of Thread. [ruby-dev:33692]
-
-Fri Mar 21 21:26:52 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 15 20:28:45 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/resolv.rb (Resolv::Hosts): should not use win32/resolv on cygwin.
[ruby-dev:29945], [ruby-dev:34095]
@@ -2329,314 +234,81 @@ Fri Mar 21 21:26:52 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/win32/resolv.rb (Win32::Resolv.get_hosts_path): use expand_path.
-Fri Mar 21 21:10:00 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * lib/ipaddr.rb: Say that I am the current maintainer.
-
- * lib/set.rb: Ditto.
-
- * lib/shellwords.rb: Ditto.
-
- * ext/syslog/syslog.txt: Ditto.
-
-Fri Mar 21 09:24:28 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * instruby.rb (open_for_install): write block result and rewrite only
- if changed from existing file.
-
-Wed Mar 19 21:01:08 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * dir.c (dir_inspect, dir_path, dir_tell): check for frozen and closed
- is not needed. [ruby-dev:32640]
-
-Wed Mar 19 20:25:40 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * dir.c (Init_Dir): define inspect method. [ruby-core:15960]
-
-Wed Mar 19 14:59:12 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * misc/ruby-style.el (ruby-style-{case,label}-indent): fix for labels
- inside blocks in switch and function top level.
-
-Wed Mar 19 14:36:40 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * bignum.c (rb_cstr_to_inum): treat successive underscores as
- nondigit. [ruby-dev:34089]
-
-Wed Mar 19 00:01:23 2008 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-
- * lib/erb.rb (ERB::Compiler): Make some minor code optimization.
-
-Mon Mar 17 17:11:13 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 15 20:27:21 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* 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]
-Mon Mar 17 16:41:08 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in: unset GREP_OPTIONS. [ruby-core:15918]
-
-Fri Mar 14 16:59:23 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in (RUBY_LIB_PREFIX): fix for prefix.
-
-Fri Mar 14 16:35:11 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/cgi.rb (CGI::Cookie::initialize): performance patch from
- Makoto Kuwata <kwa@kuwata-lab.com> in [ruby-dev:34048].
-
-Fri Mar 14 15:49:05 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in (RUBY_LIB_PREFIX): use libdir.
-
-Fri Mar 14 10:12:29 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in (RUBY_CHECK_VARTYPE): should not indent preprocessor
- directives.
-
-Thu Mar 13 00:37:20 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (rb_call0): yields the last executed node line number at
- return event. [ruby-core:15855]
-
-Wed Mar 12 02:12:20 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
-
- * lib/delegate.rb: check $@ to avoid NoMethodError.
-
-Tue Mar 11 19:48:09 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 15 20:07:30 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* numeric.c (fix_coerce): try conversion before type check.
[ruby-core:15838]
-Tue Mar 11 17:03:23 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/delegate.rb (Delegator#initialize, DelegateClass): skip correct
- backtrace. [ruby-dev:34019]
-
-Tue Mar 11 16:43:53 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * win32/win32.c (rb_w32_cmdvector): terminate shrunken command line.
-
-Tue Mar 11 12:39:03 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * common.mk (clean-local): removes MINOBJS.
-
-Sat Mar 8 18:50:57 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * file.c (isdirsep): backslash is valid path separator on cygwin too.
-
-Fri Mar 7 19:56:10 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/mkmf.rb: rdoc added. [ruby-Patches-9762]
-
-Thu Mar 6 15:10:21 2008 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * {bcc32,win32}/Makefile.sub (RUNRUBY): use $(PROGRAM) instead of
- ruby$(EXEEXT).
- suggested by KIMURA Koichi <kimura.koichi at canon.co.jp>.
- [ruby-dev:34000]
-
-Thu Mar 6 12:15:06 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (opt_block_param): command can start just after block param
- definition. [ruby-list:44479]
-
-Thu Mar 6 00:34:11 2008 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-
- * lib/erb.rb: update RDoc. Thanks Makoto Kuwata [ruby-dev:33702]
-
-Mon Mar 3 23:28:34 2008 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * 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].
-
- * lib/webrick/httpservlet/filehandler.rb: pathnames which have
- not to be published should be checked case-insensitively.
-
-Mon Mar 3 16:14:24 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * hash.c (rb_any_hash): shrinks all results in Fixnum range.
- [ruby-core:15713]
-
-Sat Mar 1 02:35:08 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * bignum.c (big2str_find_n1): check integer overflow.
-
-Tue Feb 26 16:06:00 2008 Technorama Ltd. <oss-ruby@technorama.net>
-
- * ext/openssl/ossl_pkey_{ec,dh,dsa,rsa}.c: Remove useless warnings.
-
- * ext/openssl/ossl_asn1.c: Simplify code.
-
- * ext/openssl/ossl_ssl_session.c Fix compiler warnings.
- Undefine #id if SSL_SESSION_get_id is not supported.
-
-Tue Feb 26 15:43:42 2008 Tanaka Akira <akr@fsij.org>
-
- * parse.y (tokadd_escape): refactored. [ruby-core:15657]
-
-Mon Feb 25 17:30:29 2008 Technorama Ltd. <oss-ruby@technorama.net>
-
- * ext/openssl/digest.c ext/openssl/lib/openssl/digest.rb:
- Commit patch #9280 from Akinori MUSHA.
- Simplify the OpenSSL::Digest class and make use of the
- existing Digest framework.
- Enhance performance.
-
-Mon Feb 25 13:40:03 2008 Tanaka Akira <akr@fsij.org>
-
- * process.c (Init_process): share bignum objects for RLIM_INFINITY,
- RLIM_SAVED_MAX and RLIM_SAVED_CUR if they are equal.
-
-Sun Feb 24 23:29:48 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * common.mk, {bcc,win}32/Makefile.sub (clean-local): remove
- intermediate files.
-
-Sun Feb 24 03:52:58 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * util.c (valid_filename): use O_EXCL to get rid of clobbering
- existing files in race conditions.
-
-Fri Feb 22 19:50:19 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 15 19:55:46 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* bignum.c (BIGZEROP): fix for longer Bignum zeros. [ruby-Bugs-17454]
-Fri Feb 22 16:09:53 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * bignum.c (rb_big_lshift, rb_big_rshift, rb_big_aref): removed excess
- arguments.
-
-Thu Feb 21 00:01:34 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in (RPATHFLAG): -R option of HP-UX ld is not for runtime
- load path. [ruby-list:44600]
-
-Wed Feb 20 23:55:19 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * win32/win32.c (rb_w32_map_errno): exported.
-
-Wed Feb 20 13:08:52 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 15 19:53:16 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * instruby.rb (parse_args): added --dir-mode, --script-mode and
- --cmd-type options. [ruby-dev:33816]
-
- * instruby.rb (parse_args): added bin-arch and bin-comm to install
- type, for compiled files and script files.
-
- * instruby.rb (parse_args): deal with make style command line macros,
- and count as long syle options if prefixed with INSTALL_.
-
- * instruby.rb (makedirs): use $dir_mode. [ruby-dev:33805]
-
- * instruby.rb (open_for_install): set file mode, which is now
- permission mode instead of access mode.
-
- * instruby.rb (bin-comm): installs scripts with replacing shebang
- lines.
+ * bignum.c (big2str_find_n1): check integer overflow.
-Tue Feb 19 18:34:32 2008 Tanaka Akira <akr@fsij.org>
+Sun Jun 15 19:51:37 2008 Tanaka Akira <akr@fsij.org>
* gc.c (STACK_LENGTH) [SPARC] : 0x80 offset removed. [ruby-dev:33857]
-Tue Feb 19 14:27:32 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 15 19:49:10 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/readline/readline.c (readline_event): prevent polling. based on
a patch from error errorsson in [ruby-Bugs-17675].
-Tue Feb 19 12:08:29 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 15 19:24:42 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (yycompile): clear ruby_eval_tree_begin if parse failed.
-Mon Feb 18 16:23:45 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 15 19:23:23 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (yycompile): clear ruby_eval_tree_begin too before parse.
-Mon Feb 18 10:17:42 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 15 19:21:26 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/pty/lib/expect.rb (IO#expect): check if peer is closed.
[ruby-Bugs-17940]
-Fri Feb 15 20:37:06 2008 Tadayoshi Funaba <tadf@dotrb.org>
-
- * lib/rational.rb (floor, ceil, truncate, round): do not use
- definitions of Numeric.
-
- * lib/rational.rb (to_i): should returns truncated self.
-
- * lib/complex.rb (numerator): requires
- Integer#{numerator,denominator}.
-
- * lib/complex.rb (quo): do not use definition of Numeric.
-
- * lib/complex.rb (div, divmod, floor, ceil, truncate, round):
- undef'ed.
-
-Fri Feb 15 15:23:12 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 15 19:19:21 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/iconv/iconv.c (iconv_convert): check upper bound. a patch from
Daniel Luz at [ruby-Bugs-17910].
-Fri Feb 15 02:42:25 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 15 19:07:41 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in (ftruncate): check if available.
* file.c (rb_file_truncate): check if ftruncate instead of truncate.
-Fri Feb 15 02:40:54 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 15 18:59:04 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in (sigsetmask): check when signal semantics is not POSIX.
* signal.c (USE_TRAP_MASK): set true if sigprocmask or sigsetmask is
available.
-Thu Feb 14 17:44:32 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/dl/ptr.c (dlmem_each_i): typo fixed. a patch from IKOMA
- Yoshiki <ikoma AT mb.i-chubu.ne.jp> in [ruby-dev:33776].
-
-Thu Feb 14 16:02:51 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * file.c (rb_file_s_utime): inhibits with secure level 2 or higher.
-
-Thu Feb 14 01:43:16 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sat Jun 14 16:12:17 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/timeout.rb (Timeout::timeout): made sensitive to location on the
stack. [ruby-core:15458]
-Thu Feb 14 00:49:53 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * common.mk (INSTRUBY_ARGS): pass mode to install. [ruby-dev:33766]
-
- * instruby.rb (parse_args): added --data-mode and --prog-mode options.
-
-Tue Feb 12 11:33:26 2008 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-
- * test/erb/test_erb.rb(TestERBCore): import from erb-2.0.4.
-
- * test/erb/hello.erb: ditto
-
-Mon Feb 11 17:25:21 2008 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/rss.rb (RSS::VERSION), test/rss/test_version.rb, NEWS:
- 0.2.3 -> 0.2.4.
-
- * lib/rss/maker.rb, lib/rss/maker/, test/rss/test_maker_2.0.rb:
- fixed a bug that RSS::Maker.make("0.9")'s item doesn't make some
- elements if description is missed.
- Reported by Michael Auzenne. Thanks!!!
+Fri Jun 13 13:10:12 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
- * lib/rss/maker/0.9.rb, test/rss/test_maker_0.9.rb:
- RSS::Maker.make("0.9") generates RSS 0.92 not RSS 0.91.
+ * 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>
-Mon Feb 11 16:57:00 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
+ * class.c (clone_method): should copy cref as well.
+ [ruby-core:15833]
- * ChangeLog: format-time-string under C locale. [ruby-dev:33261]
+ Yoshiki <ikoma@mb.i-chubu.ne.jp> in [ruby-dev:33776].
-Mon Feb 11 16:31:47 2008 URABE Shyouhei <shyouhei@ice.uec.ac.jp>
+Fri Jun 13 12:10:58 2008 URABE Shyouhei <shyouhei@ice.uec.ac.jp>
* gc.c (rb_newobj): prohibit call of rb_newobj() during gc.
Submitted by Sylvain Joyeux [ruby-core:12099].
@@ -2646,15 +318,11 @@ Mon Feb 11 16:31:47 2008 URABE Shyouhei <shyouhei@ice.uec.ac.jp>
[ruby-core:12099] [ ruby-bugs-11859 ] [ ruby-bugs-11882 ]
[ ruby-patches-13151 ].
-Mon Feb 11 00:22:55 2008 NARUSE, Yui <naruse@ruby-lang.org>
+Fri Jun 13 12:09:02 2008 NARUSE, Yui <naruse@ruby-lang.org>
* lib/benchmark.rb (Job::Benchmark#item): fix typo.
-Sat Feb 9 23:22:52 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/bigdecimal/extconf.rb: simplified the condition.
-
-Sat Feb 9 17:51:24 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Jun 13 12:03:31 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/bigdecimal/bigdecimal.c (BigDecimal_to_f): use strtod() for more
precision. [ruby-talk:290296]
@@ -2663,81 +331,18 @@ Sat Feb 9 17:51:24 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/bigdecimal/extconf.rb: ditto. [ruby-dev:33658]
-Sat Feb 9 00:44:52 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Jun 13 11:58:34 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/irb.rb (IRB::Irb::eval_input): rescues Interrupt and other than
SystemExit and SignalException. [ruby-core:15359]
-Fri Feb 8 15:09:21 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/mkmf.rb (xsystem): expand macros like as make.
-
-Tue Feb 5 11:14:11 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/mkmf.rb (INSTALL_DIRS, install_dirs): added BINDIR.
-
- * lib/mkmf.rb (install_files): rejects files matching to
- $NONINSTALLFILES.
-
- * lib/mkmf.rb (init_mkmf): defaults $NONINSTALLFILES to backup and
- temporary filse.
-
-Mon Feb 4 16:44:24 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in (darwin): NSIG is not defined if _XOPEN_SOURCE > 500L.
- [ruby-dev:33584]
-
-Sat Feb 2 20:06:42 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+Fri Jun 13 11:56:28 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/benchmark.rb (Benchmark::realtime): make Benchmark#realtime
- a bit faster. a patch from Alexander Dymo <dymo AT ukrpost.ua> in
+ a bit faster. a patch from Alexander Dymo <dymo@ukrpost.ua> in
[ruby-core:15337].
-Sat Feb 2 09:53:39 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in (darwin): disabled fat-binary support which confuses
- configure much, since ``universal'' implies hidden cross-compiling.
- TODO: ruby and libruby.bundle might be possible to bound with `lipo'
- after builds for each archs. Anyway, config.h and rbconfig.rb must
- be separated definitely at least.
-
-Fri Feb 1 21:42:37 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in (darwin): _XOPEN_SOURCE is necessary to make ucontext_t
- consistent with the library implementation of MacOS X 10.5.
- [ruby-dev:33461]
-
- * configure.in (darwin): ucontext on PowerPC MacOS X 10.5 is broken.
-
-Thu Jan 31 08:31:19 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * common.mk (ext/extmk.rb, instruby.rb): inlined $(MAKE) so that can
- be executed even with -n.
-
-Thu Jan 31 07:00:19 2008 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-
- * lib/rinda/tuplespace.rb (bin_for_find): should find a symbol by
- Symbol class.
-
- * test/rinda/test_rinda.rb (test_symbol_tuple): ditto.
-
-Wed Jan 30 22:07:58 2008 Tadayoshi Funaba <tadf@dotrb.org>
-
- * lib/date.rb: refined deprecated methods.
-
-Wed Jan 30 22:06:54 2008 Tadayoshi Funaba <tadf@dotrb.org>
-
- * bignum.c (rb_cstr_to_inum): '0_2' is a valid representation.
-
-Tue Jan 29 22:40:12 2008 Yusuke Endoh <mame@tsg.ne.jp>
-
- * range.c (step_i): rb_funcall receives VALUE as an argument.
-
-Tue Jan 29 11:53:05 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in: rm largefile.h.
-
-Mon Jan 28 01:21:15 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+Fri Jun 13 11:42:52 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (rb_open_file): should check NUL in path.
<http://www.rubyist.net/~matz/20080125.html#c01>.
@@ -2754,245 +359,43 @@ Mon Jan 28 01:21:15 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (rb_io_s_read): ditto.
-Fri Jan 25 22:33:38 2008 Yusuke Endoh <mame@tsg.ne.jp>
-
- * math.c: fix comment. [ruby-dev:33276]
-
-Fri Jan 25 10:31:58 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * */*.bat: set svn:mime-type to text/batch.
-
-Thu Jan 24 19:36:22 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed Jun 11 15:06:00 2008 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]
-
-Tue Jan 22 11:22:47 2008 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/setup.mak ($(ARCH)): if a macro is appended by $(APPEND),
- a space will be inserted on the top of the line.
-
- * win32/Makefile.sub (MKFILES): stop make process if Makefile is
- updated.
-
-Mon Jan 21 17:34:41 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * io.c (rb_io_mode_flags, rb_io_mode_modenum): Ignore encoding
- options for forward compatibility.
+ object_id with printf. [ruby-dev:33347]
-Mon Jan 21 12:50:02 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c, gc.c (setjmp): sigsetjmp is a macro on cygwin.
-
-Sat Jan 19 11:21:53 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in (sigsetjmp): check if available.
-
- * eval.c, gc.c (setjmp): do not use _setjmp if sigsetjmp is available.
-
-Sat Jan 19 11:10:11 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed Jun 11 14:58:49 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in: Remove wrong assumptions about Cygwin. a patch from
Corinna Vinschen in [ruby-Bugs-17018].
-Thu Jan 17 21:06:01 2008 Tadayoshi Funaba <tadf@dotrb.org>
-
- * lib/date.rb (Date::Infinity#<=>): didn't work. A patch from
- Dirkjan Bussink <d.bussink AT gmail.com> [ruby-core:15098].
- This is a bug obviously. However it didn't affect the library's
- functions.
-
- * lib/date.rb, lib/date/format.rb: some trivial changes.
-
-Tue Jan 15 15:09:28 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * win32/setup.mak: strip out empty lines from CPP output.
-
-Tue Jan 15 03:41:42 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Mon Jun 9 18:03:32 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (eval): check if backtrace is empty. [ruby-core:15040]
-Tue Jan 15 01:28:47 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * common.mk: simplified dummy objects dependencies.
-
-Mon Jan 14 16:12:58 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/shellwords.rb: scape should be an alias to shellescape. a
- patch from Masahiro Kawato <m-kawato AT mwb.biglobe.ne.jp> in
- [ruby-dev:33060].
-
-Mon Jan 14 09:32:40 2008 Tadayoshi Funaba <tadf@dotrb.org>
-
- * lib/time.rb: do not reference Time directly from the inside of
- definitions. [ruby-dev:33059]
-
-Sat Jan 12 18:27:41 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 8 06:07:02 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (rb_define_alloc_func, rb_undef_alloc_func): should
define/undef on a signleton class. [ruby-core:09959]
-Sat Jan 12 12:04:14 2008 Tadayoshi Funaba <tadf@dotrb.org>
-
- * lib/date.rb, lib/date/format.rb: tuning for performance.
-
-Fri Jan 11 12:35:56 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in: moved broken syscall checks from process.c etc.
-
- * defines.h (WORDS_BIGENDIAN): honor __BIG_ENDIAN__ than the result of
- configure.
-
- * dln.c: use dlopen on Mac OS X 10.3 or later. backport from trunk.
-
- * lib/rdoc/options.rb (check_diagram): more precise check, darwin
- is not Windows but minwg is on it.
-
-Thu Jan 10 10:53:50 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * win32/win32.c (rb_w32_open_osfhandle): reverted to old definition.
- [ ruby-Bugs-16948 ]
-
-Tue Jan 8 20:02:08 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * win{32,ce}/Makefile.sub: merged.
-
-Sun Jan 6 09:39:02 2008 Tadayoshi Funaba <tadf@dotrb.org>
-
- * lib/date.rb, lib/date/format.rb: introduced some constants
- (for internal use).
-
- * sample/cal.rb: trivial adjustments.
-
-Fri Jan 4 23:08:48 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 8 06:03:45 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* time.c (time_arg): use converted object. [ruby-core:14759]
-Fri Jan 4 01:20:21 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * win32.h: only VC6 needs extern "C++" for math.h. [ruby-talk:285660]
-
-Thu Jan 3 11:28:58 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 8 06:01:25 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* io.c (fptr_finalize): clear errno first. [ruby-talk:284492]
-Wed Jan 2 10:18:56 2008 Tadayoshi Funaba <tadf@dotrb.org>
-
- * sample/time.rb: use Process.times instead of Time.times.
-
-Wed Jan 2 09:18:11 2008 Tadayoshi Funaba <tadf@dotrb.org>
-
- * sample/goodfriday.rb: examples for date are enough. retired.
-
-Wed Jan 2 09:06:55 2008 Tadayoshi Funaba <tadf@dotrb.org>
-
- * sample/cal.rb: just updated with the newest version.
-
-Mon Dec 31 06:50:38 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * trunk/common.mk: not use -I$(srcdir)/lib with $(MINIRUBY) for cross
- compiling.
-
- * configure.in, {win,bcc}32/Makefile.sub (MINIRUBY): -I$(srcdir)/lib
- moved.
-
-Sun Dec 30 22:48:37 2007 Tadayoshi Funaba <tadf@dotrb.org>
-
- * lib/date.rb (_valid_time?): I'm not sure to recommend such an
- expression. but anyway it is acceptable now. [ruby-core:14580]
-
-Fri Dec 28 16:36:33 2007 NARUSE, Yui <naruse@airemix.com>
-
- * lib/resolv.rb (Resolv::DNS#each_address): now returns IPv6 address.
-
-Fri Dec 28 13:21:32 2007 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/rss.rb, test/rss/test_version.rb, NEWS: 0.2.2 -> 0.2.3.
-
- * lib/rss/parser.rb, test/rss/test_parser.rb: supported "-" in tag name.
- Reported by Ray Chen. Thanks.
-
-Thu Dec 27 23:56:01 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * mkconfig.rb: should not use the libraries under the source directory
- at cross compiling.
-
-Thu Dec 27 11:02:45 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * intern.h, string.c (rb_str_set_len): added for upgrading path from
- 1.8 to 1.9. [ruby-dev:32807]
-
- * string.c (rb_str_lines, rb_str_bytes): ditto.
-
-Thu Dec 27 10:47:32 2007 Technorama Ltd. <oss-ruby@technorama.net>
-
- * ext/openssl/ossl_ssl.c: Only show a warning if the default
- DH callback is actually used.
-
- * ext/openssl/ossl_rand.c: New method: random_add().
-
-Wed Dec 26 22:27:45 2007 NARUSE, Yui <naruse@ruby-lang.org>
-
- * lib/resolv.rb (Resolv::DNS::Name.==): fix for other is array of
- Resolv::DNS::Label::Str.
-
- * lib/resolv.rb (Resolv::DNS::MessageEncoder#put_label): String#string
- is not defined, so replace to_s.
-
- * lib/resolv.rb (Resolv::IPv6#to_name): ip6.int is obsoleted by
- int.arpa.
-
-Mon Dec 24 16:18:57 2007 Eric Hodel <drbrain@segment7.net>
-
- * lib/rdoc/ri/ri_options.rb: Fix ri --help listing of gem ri paths.
- Merge of r14567 and r14569 from trunk.
-
- * lib/rdoc/ri/ri_paths.rb: Fix duplication of ri data for multiple
- gems. Merge of r14567 from trunk
-
-Mon Dec 24 12:35:03 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * win{32,ce}/Makefile.sub (MFLAGS): defaulted to -l.
-
-Mon Dec 24 11:56:31 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * {bcc32,win{32,ce}}/Makefile.sub (SET_MAKE): set MFLAGS which is not
- set by default, to get rid of chaotic situation of MFLAGS/MAKEFLAGS.
-
-Sat Dec 22 14:49:46 2007 Tadayoshi Funaba <tadf@dotrb.org>
-
- * lib/date.rb: don't freeze nil even if 1.8 will not be aware of
- the issue. [ruby-dev:32677]
-
-Wed Dec 19 13:57:43 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 8 05:53:46 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in (TIMEZONE_VOID): check whether timezone requires zero
arguments. [ruby-dev:32631]
-Wed Dec 19 12:01:42 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 8 05:35:32 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (f_rest_arg): check if duplicated. [ruby-core:14140]
-Wed Dec 19 10:52:29 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * bignum.c (rb_cstr_to_inum): an underscore succeeding after octal
- prefix is allowed. [ruby-core:14139]
-
-Mon Dec 17 13:43:15 2007 Tanaka Akira <akr@fsij.org>
-
- * gc.c (stack_end_address): use local variable address instead of
- __builtin_frame_address(0) to avoid SEGV on SunOS 5.11 on x86 with
- gcc (GCC) 3.4.3 (csl-sol210-3_4-20050802).
- stack_end_address returned a frame address of garbage_collect
- since stack_end_address doesn't create its own frame.
- So a VALUE stored in a callee saved register, %edi, pushed into
- the stack at the beginning of garbage_collect was not marked.
-
-Mon Dec 17 12:21:25 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * Makefile.in (RUNRUBY): added RUNRUBYOPT.
-
-Fri Dec 14 12:36:35 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 8 05:21:46 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in (RUBY_CHECK_VARTYPE): check if a variable is defined
and its type.
@@ -3006,264 +409,108 @@ Fri Dec 14 12:36:35 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/readline/extconf.rb: should use have_func for functions instead
of have_var.
-Tue Dec 11 00:04:05 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * array.c (rb_ary_slice_bang): If an invalid negative index (<
- -size) is given, do not raise an exception but return nil just
- like slice() does.
-
- * test/ruby/test_array.rb (TestArray::test_slice,
- TestArray::test_slice!): Pull in test cases from trunk.
-
-Mon Dec 10 21:47:53 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * transcode.c (str_transcode): allow non-registered encodings.
- [ruby-dev:32520]
-
-Mon Dec 10 21:00:30 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * array.c (rb_ary_slice_bang): should return nil if position out
- of range. a patch from Akinori MUSHA <knu AT iDaemons.org>.
- [ruby-dev:32518]
-
-Mon Dec 10 18:28:06 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sun Jun 8 05:09:29 2008 Yukihiro Matsumoto <matz@ruby-lang.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]
-Sun Dec 9 12:39:01 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 8 05:05:05 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/cgi.rb (read_multipart): exclude blanks from header values.
[ruby-list:44327]
-Wed Dec 5 23:38:50 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * range.c (range_each): followed step_i change.
-
-Wed Dec 5 18:08:45 2007 Tanaka Akira <akr@fsij.org>
-
- * numeric.c (int_odd_p): new method Integer#odd?.
- (int_even_p): new method Integer#even?.
- (int_pred): new method Integer#pred.
- (fix_odd_p): new method Fixnum#odd?.
- (fix_even_p): new method Fixnum#even?.
-
-Wed Dec 5 15:15:21 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * range.c (step_i, range_step): support non-fixnum steps.
- [ruby-talk:282100]
-
-Tue Dec 4 11:23:50 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 8 05:00:44 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* bignum.c (rb_cstr_to_inum): trailing spaces may exist at sqeezing
preceeding 0s. [ruby-core:13873]
-Sun Dec 2 22:43:45 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 8 04:56:55 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (error_print): put newline unless multiple line message ends
with a newline. [ruby-dev:32429]
-Sun Dec 2 15:49:20 2007 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/rss.rb, test/rss/test_version.rb, NEWS: 0.2.1 -> 0.2.2.
-
- * lib/rss/maker/itunes.rb: fixed new_itunes_category.
- * lib/rss/maker/taxonomy.rb: new_taxo_topic -> new_topic because
- of consistency.
-
- * test/rss/test_maker_itunes.rb, test/rss/test_itunes.rb: removed
- needless UTF-8 characters.
-
-Sun Dec 2 01:12:15 2007 James Edward Gray II <jeg2@ruby-lang.org>
+Sun Jun 8 04:54:36 2008 James Edward Gray II <jeg2@ruby-lang.org>
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.
-Sat Dec 1 15:13:33 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/resolv.rb: documentation update. backported from 1.9.
- [ruby-core:13273]
-
-Sat Dec 1 03:30:47 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 8 04:46:45 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (newline_node): set line from outermost node before removing
NODE_BEGIN. [ruby-dev:32406]
-Fri Nov 30 21:53:28 2007 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/rss.rb, test/rss/test_version.rb: 0.2.0 -> 0.2.1.
-
- * lib/rss/content.rb, lib/rss/content/1.0.rb,
- lib/rss/content/2.0.rb, lib/rss/maker/content.rb,
- test/rss/rss-testcase.rb, test/rss/test_content.rb,
- test/rss/test_maker_content.rb: supported content:encoded with RSS
- 2.0.
- Suggested by Sam Lown. Thanks.
-
- * NEWS: added the above changes.
-
-Thu Nov 29 16:59:10 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 8 04:37:34 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (stmt): remove unnecessary NODE_BEGIN. [ruby-core:13814]
-Wed Nov 28 14:43:14 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/extmk.rb (extract_makefile): use dldflags instead of DLDFLAGS to
- get rid of mixing $LDFLAGS and $ARCH_FLAG.
-
- * lib/mkmf.rb (configuration): ditto.
-
- * lib/mkmf.rb (create_makefile): support for extensions which has no
- shared object.
-
-Wed Nov 28 09:51:42 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * bignum.c (rb_big2str0): do not clobber space for sign.
-
- * sprintf.c (remove_sign_bits): extends sign bit first.
-
-Wed Nov 21 01:04:12 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sun Jun 8 04:18:50 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* object.c (nil_plus): remove unused function. [ruby-core:13737]
-Sun Nov 18 14:03:44 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 8 04:15:40 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (rb_alias): do not call hook functions until initialization
finishes. [ruby-talk:279538]
-Sun Nov 18 09:09:48 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/mkmf.rb (String#tr_cpp): make preprocessor identifiers.
-
-Sat Nov 17 13:58:11 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
+Sun Jun 8 04:12:50 2008 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c (ole_invoke): bug fix. [ruby-talk:279100]
-Fri Nov 16 17:41:34 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/iconv/iconv.c (Document-class): moved the simplest example to
- the top.
-
- * ext/iconv/iconv.c (iconv_s_iconv): Document-method: needs class
- prefix for class method. [ruby-core:13542]
-
- * ext/iconv/iconv.c (iconv_iconv): also instance method needs to be
- qualified.
-
-Fri Nov 16 11:16:41 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/yaml/rubytypes.rb (String#is_binary_data?): use Integer#fdiv.
-
-Thu Nov 15 19:50:46 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+Sun Jun 8 03:54:52 2008 NAKAMURA Usaku <usa@ruby-lang.org>
* ext/curses/extconf.rb: check macro if cannot find func.
[ruby-list:44224]
-Thu Nov 15 12:19:14 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sun Jun 8 03:50:40 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/cgi/session.rb (CGI::Session::FileStore::restore): use
lockfile for exclusive locks. a patch from <tommy AT tmtm.org>.
[ruby-dev:32296]
-Wed Nov 14 01:52:59 2007 Tanaka Akira <akr@fsij.org>
+Sun Jun 8 03:46:55 2008 Tanaka Akira <akr@fsij.org>
* missing/isinf.c (isinf): don't define if the macro is defined.
-Wed Nov 14 01:34:42 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 8 03:34:23 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* numeric.c (round): fallback definition.
* numeric.c (flo_divmod, flo_round): use round() always.
[ruby-dev:32269]
-Tue Nov 13 22:02:23 2007 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-
- * lib/drb/drb.rb: remove Thread.exclusive.
-
- * lib/drb/extservm.rb: ditto.
-
-Tue Nov 13 16:33:07 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 8 03:34:23 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* numeric.c (flodivmod): work around for infinity.
* numeric.c (flo_divmod): work around for platforms have no round().
[ruby-dev:32247]
-Tue Nov 13 13:58:51 2007 Tanaka Akira <akr@fsij.org>
-
- * numeric.c (numeric.c): Integer#ord implemented. [ruby-dev:32206]
-
-Tue Nov 13 02:57:04 2007 URABE Shyouhei <shyouhei@ice.uec.ac.jp>
+Sun Jun 8 03:34:23 2008 URABE Shyouhei <shyouhei@ice.uec.ac.jp>
* numeric.c (flo_divmod): round to the nearest integer.
[ ruby-Bugs-14540 ]
-Mon Nov 12 16:52:29 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/mkmf.rb (create_makefile): rdoc about srcprefix. a patch from
- Daniel Berger <djberg96 AT gmail.com> in [ruby-core:13378].
-
-Mon Nov 12 13:53:06 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * misc/ruby-mode.el (ruby-parse-partial): handle stringified
- symbols properly using ruby-forward-string.
-
-Mon Nov 12 12:38:31 2007 Tanaka Akira <akr@fsij.org>
-
- * Makefile.in (lex.c): don't remove lex.c at first.
-
-Fri Nov 9 07:26:04 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * random.c: update MT URL.[ruby-core:13305].
-
-Wed Nov 7 03:32:38 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sun Jun 8 03:08:11 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/rexml/encodings/SHIFT-JIS.rb (REXML::Encoding): place -x for
nkf conversion. a patch from <moonwolf AT moonwolf.com>.
[ruby-dev:32183]
-Mon Nov 5 05:17:04 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 8 03:05:59 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* 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].
-Mon Nov 5 01:20:33 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (call_args): remove "parenthesize argument(s) for future
- version" warning. when I added this warning, I had a plan to
- reimplement the parser that is simpler than the current one.
- since we abandoned the plan, warning no longer required.
-
-Fri Nov 2 00:13:51 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * array.c (rb_ary_assoc): check and convert inner arrays (assocs)
- using #to_ary.
-
- * hash.c (rb_hash_s_create): check and convert argument hash
- using #to_hash.
-
- * hash.c (rb_hash_s_create): Hash#[] now takes assocs as source of
- hash conversion.
-
-Thu Nov 1 23:47:43 2007 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-
- * lib/drb/drb.rb (DRbTCPSocket): Improving with multiple network
- interface.
-
- * test/drb/drbtest.rb: ditto.
-
-Fri Oct 26 17:14:14 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * numeric.c (fix_pow): returns 1.0 for 0**0.0.
+Sun Jun 8 03:03:27 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* numeric.c (fix_pow): returns infinity for 0**-1. [ruby-dev:32084]
-Wed Oct 25 07:18:09 2007 James Edward Gray II <jeg2@ruby-lang.org>
+Sun Jun 8 02:57:32 2008 James Edward Gray II <jeg2@ruby-lang.org>
Merged 13781 from trunk.
@@ -3277,11 +524,11 @@ Wed Oct 25 06:46:21 2007 James Edward Gray II <jeg2@ruby-lang.org>
* lib/net/telnet.rb (Net::Telnet#login): Making the password prompt
pattern case insensitive. [ruby-Bugs-10746]
-Thu Oct 25 14:19:33 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 8 02:54:30 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* io.c (rb_io_tell, rb_io_seek): check errno too. [ruby-dev:32093]
-Wed Oct 25 08:03:53 2007 James Edward Gray II <jeg2@ruby-lang.org>
+Sun Jun 8 01:51:52 2008 James Edward Gray II <jeg2@ruby-lang.org>
Merged 13767, 13768, 13769, and 13770 from trunk.
@@ -3298,125 +545,36 @@ Wed Oct 25 08:03:53 2007 James Edward Gray II <jeg2@ruby-lang.org>
* lib/xmlrpc/utils.rb (XMLRPC::ParseContentType#parse_content_type):
Making Content-Type checks case insensitive. [ruby-Bugs-3367]
-Sun Oct 21 21:16:43 2007 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss.rb, lib/rss/, test/rss/, sample/rss/: merged from trunk.
- - 0.1.6 -> 2.0.0.
- - fixed image module URI. Thanks to Dmitry Borodaenko.
- - supported Atom.
- - supported ITunes module.
- - supported Slash module.
-
- * NEWS: added an entry for RSS Parser.
-
-Thu Oct 18 10:57:06 2007 Tanaka Akira <akr@fsij.org>
-
- * ruby.h (RCLASS_IV_TBL): defined.
- (RCLASS_M_TBL): ditto.
- (RCLASS_SUPER): ditto.
- (RMODULE_IV_TBL): ditto.
- (RMODULE_M_TBL): ditto.
- (RMODULE_SUPER): ditto.
-
-Mon Oct 15 22:08:55 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * NEWS: Merge some of the sub-sections, as the differences were
- unclear.
-
-Mon Oct 15 21:57:07 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * NEWS: Mention ipaddr enhancements.
-
- * lib/ipaddr.rb (in_addr, in6_addr, addr_mask): Make some minor
- code optimization.
-
- * lib/ipaddr.rb (<=>): Implement IPAddr#<=> and make IPAddr
- comparable.
-
- * lib/ipaddr.rb (succ): Implement IPAddr#succ. You can now create
- a range between two IPAddr's, which (Range) object is
- enumerable.
-
- * lib/ipaddr.rb (to_range): A new method to create a Range object
- for the (network) address.
-
- * lib/ipaddr.rb (coerce_other): Support type coercion and make &,
- |, == and include? accept a string or an integer instead of an
- IPAddr object as the argument.
-
- * lib/ipaddr.rb (initialize): Give better error messages.
-
- * lib/ipaddr.rb: Improve documentation.
-
-Mon Oct 15 21:24:25 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * NEWS: Mention shellwords and tempfile enhancements.
-
- * NEWS: Move the entry about Tk::X_Scrollable to a better section.
-
-Mon Oct 15 17:28:20 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * ext/openssl/lib/openssl/buffering.rb (read, readpartial): revert
- r12496. handling EOF is a little differnt in ruby 1.8 and ruby 1.9.
- [ruby-dev:31979]
-
-Mon Oct 15 11:45:12 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 8 01:45:27 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* marshal.c (r_bytes0): refined length check. [ruby-dev:32059]
-Mon Oct 15 09:58:07 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 8 01:45:27 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* marshal.c (r_bytes0): check if source has enough data.
[ruby-dev:32054]
-Mon Oct 15 01:15:09 2007 Tanaka Akira <akr@fsij.org>
+Sun Jun 8 01:37:58 2008 Tanaka Akira <akr@fsij.org>
* ext/socket/socket.c (s_accept_nonblock): make accepted fd
nonblocking. [ruby-talk:274079]
-Sun Oct 14 04:08:34 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in (AC_SYS_LARGEFILE): keep results also in command
- options, to vail out of mismatch. [ruby-list:44114]
-
- * mkconfig.rb, lib/mkmf.rb (configuration): add DEFS.
-
-Sun Oct 14 03:55:52 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 8 01:28:42 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* win32/mkexports.rb: deal with __fastcall name decorations.
[ruby-list:44111]
-Sat Oct 13 09:02:16 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * {bcc,win}32/mkexports.rb: explicit data. [ruby-list:44108]
-
-Sat Oct 13 00:35:03 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sun Jun 8 01:23:29 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/rexml/source.rb (REXML::SourceFactory::SourceFactory): typo
fixed. [ruby-list:44099]
-Fri Oct 12 11:22:15 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * re.c (match_values_at): make #select to be alias to #values_at
- to adapt RDoc description. [ruby-core:12588]
-
-Thu Oct 11 14:32:46 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+Sun Jun 8 01:17:45 2008 NAKAMURA Usaku <usa@ruby-lang.org>
* {bcc32,win32}/Makefile.sub (COMMON_MACROS): workaround for old SDK's
bug. [ruby-core:12584]
-Wed Oct 10 23:34:45 2007 Tanaka Akira <akr@fsij.org>
-
- * lib/securerandom.rb: new file. [ruby-dev:31928]
-
- * lib/cgi/session.rb (create_new_id): use securerandom if available.
-
-Tue Oct 9 01:01:55 2007 Tanaka Akira <akr@fsij.org>
-
- * re.c (rb_reg_s_union_m): Regexp.union accepts single
- argument which is an array of patterns. [ruby-list:44084]
-
-Mon Oct 8 20:06:23 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Sun Jun 8 00:56:44 2008 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/net/http.rb, lib/open-uri.rb: remove
Net::HTTP#enable_post_connection_check. [ruby-dev:31960]
@@ -3426,40 +584,12 @@ Mon Oct 8 20:06:23 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/lib/net/telnets.rb, ext/openssl/lib/net/ftptls.rb: ditto.
-Sat Oct 6 23:14:54 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_to_i): update RDoc since base can be any value
- between 2 and 36. [ruby-talk:272879]
-
-Fri Oct 5 15:44:50 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * lib/shellwords.rb: Add shellescape() and shelljoin().
-
- * lib/shellwords.rb: Rename shellwords() to shellsplit() and make
- the former an alias to the latter.
-
- * lib/shellwords.rb: Add escape(), split(), join() as class
- methods, which are aliases to their respective long names
- prefixed with `shell'.
-
- * lib/shellwords.rb: Add String#shellescape(), String#shellsplit()
- and Array#shelljoin() for convenience.
-
-Fri Oct 5 15:40:04 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * lib/tempfile.rb (Tempfile::make_tmpname): Allow to specify a
- suffix for a temporary file name.
-
- * lib/tempfile.rb (Tempfile::make_tmpname): Make temporary file
- names less predictable by including a random string.
- [inspired by: akr]
-
-Tue Oct 2 21:20:14 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+Thu Jun 5 16:19:27 2008 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.c (make_cmdvector): adjust escaped successive
double-quote handling. (merge from trunk)
-Tue Oct 2 20:35:24 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+Thu Jun 5 12:24:25 2008 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.c (init_env): initialize HOME and USER environment
variables unless set. [ruby-core:12328] (merge from trunk)
@@ -3469,133 +599,139 @@ Tue Oct 2 20:35:24 2007 NAKAMURA Usaku <usa@ruby-lang.org>
* configure.in, win32/Makefile.sub (LIBS): need to link shell32
library for SH* functions on mswin32 and mingw32.
-Mon Oct 1 12:50:59 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Thu Jun 5 12:21:06 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* gc.c (id2ref): valid id should not refer T_VALUE nor T_ICLASS.
[ruby-dev:31911]
-Wed Sep 26 23:54:37 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/extmk.rb (extmake), lib/mkmf.rb (configuration): top_srcdir
- should not prefixed with DESTDIR.
-
-Wed Sep 26 08:36:31 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed Jun 4 16:39:56 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* Makefile.in (ext/extinit.o): use $(OUTFLAG) as well as other
objects. [ruby-Bugs-14228]
-Wed Sep 26 05:12:17 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Tue Jun 3 16:13:40 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (yyerror): limit error message length. [ruby-dev:31848]
* regex.c (re_mbc_startpos): separated from re_adjust_startpos.
-Tue Sep 25 13:47:38 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Tue Jun 3 15:27:11 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * gc.c (os_obj_of, os_each_obj): hide objects to be finalized.
+ [ruby-dev:31810]
+
+Wed Jun 4 19:15:57 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (remove_method): should not remove undef place holder.
[ruby-dev:31817]
-Mon Sep 24 16:52:11 2007 Urabe Shyouhei <shyouhei@ruby-lang.org>
+Tue Jun 3 15:05:48 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/net/http.rb: fix typo.
+ * process.c (struct rb_exec_arg): proc should be a VALUE.
-Sun Sep 23 21:57:25 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ * process.c (rb_f_exec): suppress a warning.
- * 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>
+ * process.c (rb_detach_process): cast for the platforms where size of
+ pointer differs from size of int.
- * lib/net/open-uri.rb: use Net::HTTP#enable_post_connection_check to
- perform SSL post connection check.
+ * process.c (rb_f_exec, rb_f_system): should not exceptions after
+ fork. [ruby-core:08262]
- * ext/openssl/lib/openssl/ssl.c
- (OpenSSL::SSL::SSLSocket#post_connection_check): refine error message.
+Wed May 21 01:32:56 2008 GOTOU Yuuzou <gotoyuzo@notwork.org>
-Sun Sep 23 09:05:05 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * 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.
- * gc.c (os_obj_of, os_each_obj): hide objects to be finalized.
- [ruby-dev:31810]
+ * lib/webrick/httpservlet/abstract.rb
+ (WEBrick::HTTPServlet::AbstracServlet#redirect_to_directory_uri):
+ should escape the value of Location: header.
-Sun Sep 23 08:58:01 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * lib/webrick/httpservlet/cgi_runner.rb: accept interpreter
+ command line arguments.
- * eval_method.ci (rb_attr): should not use alloca for unknowen size
- input. [ruby-dev:31816]
+Sun May 18 01:57:44 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * parse.y (rb_intern_str): prevent str from optimization.
+ * file.c (isdirsep): backslash is valid path separator on cygwin too.
+ backported from 1.8 HEAD.
-Sun Sep 23 05:42:35 2007 URABE Shyouhei <shyouhei@ruby-lang.org>
+Sat May 17 23:53:57 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/rdoc/options.rb (Options::check_diagram): dot -V output
- changed. [ ruby-Bugs-11978 ], Thanks Florian Frank.
+ * file.c (file_expand_path): fix for short file name on Cygwin.
-Sat Sep 22 06:02:11 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sat May 17 23:50:29 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/optparse.rb (OptionParser::List::summarize): use each_line if
- defined rather than each. [ruby-Patches-14096]
+ * file.c (OpenFile): prevent conflict on Windows.
-Sat Sep 22 05:19:49 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * file.c (USE_NTFS): fixed merge miss.
- * ext/stringio/stringio.c (strio_init): separate from strio_initialize
- to share with strio_reopen properly. [ruby-Bugs-13919]
+Sat May 17 12:36:46 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Fri Sep 21 15:46:20 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * file.c (file_expand_path): rb_str_set_len is not backported.
- * process.c (struct rb_exec_arg): proc should be a VALUE.
+Sat May 17 12:15:48 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * process.c (rb_f_exec): suppress a warning.
+ * file.c (file_expand_path): support for alternative data stream
+ and ignored trailing garbages of NTFS.
-Fri Sep 21 03:05:35 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * file.c (rb_file_s_basename): ditto.
- * eval.c, intern.h, ext/thread/thread.c: should not free queue while
- any live threads are waiting. [ruby-dev:30653]
+ * file.c (rb_file_s_extname): ditto.
-Thu Sep 20 17:24:59 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Mon Mar 3 23:36:41 2008 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * process.c (rb_detach_process): cast for the platforms where size of
- pointer differs from size of int.
+ * 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].
- * process.c (rb_f_exec, rb_f_system): should not exceptions after
- fork. [ruby-core:08262]
+ * lib/webrick/httpservlet/filehandler.rb: pathnames which have
+ not to be published should be checked case-insensitively.
-Fri Sep 14 00:34:25 2007 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Sun Sep 23 21:57:25 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * lib/drb/extservm.rb (invoke_service): use Thread.exclusive instead of
- Thread.critical
+ * 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>
-Wed Sep 12 23:12:22 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/net/open-uri.rb: use Net::HTTP#enable_post_connection_check to
+ perform SSL post connection check.
- * ruby.c (proc_options): -W should be allowed in RUBYOPT
- environment variable. [ruby-core:12118]
+ * ext/openssl/lib/openssl/ssl.c
+ (OpenSSL::SSL::SSLSocket#post_connection_check): refine error message.
-Mon Sep 10 01:05:25 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sun Sep 23 06:08:38 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * range.c (range_step): fixed integer overflow. [ruby-dev:31763]
+ * ext/stringio/stringio.c (strio_init): separate from strio_initialize
+ to share with strio_reopen properly. [ruby-Bugs-13919]
-Sun Sep 9 09:14:45 2007 Tadayoshi Funaba <tadf@dotrb.org>
+Sun Sep 23 05:42:35 2007 URABE Shyouhei <shyouhei@ruby-lang.org>
- * lib/date/format.rb (_strptime): now also attaches an element
- which denotes leftover substring if exists.
+ * lib/rdoc/options.rb (Options::check_diagram): dot -V output
+ changed. [ ruby-Bugs-11978 ], Thanks Florian Frank.
-Sat Sep 8 10:22:20 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Mon Sep 17 04:47:02 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
- * struct.c (rb_struct_s_members): should raise TypeError instead
- of call rb_bug(). [ruby-dev:31709]
+ * ruby.c (proc_options): -W should be allowed in RUBYOPT
+ environment variable. [ruby-core:12118]
- * marshal.c (r_object0): no nil check require any more.
+Mon Sep 17 04:31:46 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-Sat Sep 8 09:38:19 2007 Tadayoshi Funaba <tadf@dotrb.org>
+ * range.c (range_step): fixed integer overflow. [ruby-dev:31763]
- * lib/date/format.rb (str[fp]time): now check specifications more
- strictly.
+Fri Sep 7 14:57:36 2007 URABE Shyouhei <shyouhei@ice.uec.ac.jp>
-Fri Sep 7 05:36:19 2007 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+ * ruby.c (rubylib_mangled_path): eliminate RSTRING_PTR
+ [ruby-dev:31679]
- * test/rinda/test_rinda.rb (MockClock): correct synchronous problems
- of the MultiThreading. [ruby-dev:31692]
+ * ruby.c(push_include_cygwin): ditto.
-Wed Sep 5 22:02:27 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Fri Sep 7 14:32:38 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* array.c (rb_ary_subseq): need integer overflow check.
[ruby-dev:31736]
@@ -3607,23 +743,13 @@ Wed Sep 5 22:02:27 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (rb_str_splice): integer overflow for length.
[ruby-dev:31739]
-Sun Sep 2 00:48:15 2007 Tadayoshi Funaba <tadf@dotrb.org>
-
- * lib/date/format.rb (_parse): improved parsing of ordinal dates.
-
- * lib/date/format.rb (_parse): use named character classes in some
- regular expressions.
-
-Sat Sep 1 08:13:36 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c: add WIN32OLE#ole_activex_initialize.
+Fri Sep 7 14:27:33 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-Thu Aug 30 13:13:13 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * eval.c (mnew): should preserve noex as safe_level.
- * lib/mkmf.rb (try_const, have_const): check for a const is defined.
- [ruby-core:04422]
+ * eval.c (rb_call0): tighten security check condition..
-Thu Aug 30 13:10:57 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Sep 7 14:19:16 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in (group_member): check if presents.
@@ -3631,79 +757,24 @@ Thu Aug 30 13:10:57 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* file.c (group_member): use system routine if available.
-Thu Aug 30 08:24:18 2007 Tanaka Akira <akr@fsij.org>
-
- * ruby.h (RHASH_TBL): defined for compatibility to 1.9.
- * (RHASH_ITER_LEV): ditto.
- * (RHASH_IFNONE): ditto.
- * (RHASH_SIZE): ditto.
- * (RHASH_EMPTY_P): ditto.
-
-Wed Aug 29 13:05:59 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Fri Sep 7 14:14:19 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* include/ruby/defines.h (flush_register_windows): call "ta 0x03"
even on Linux/Sparc. [ruby-dev:31674]
-Tue Aug 28 23:26:12 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
+Fri Sep 7 14:12:37 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
- * ext/win32ole/win32ole.c (ole_type_progid, reg_enum_key,
- reg_get_val, ole_wc2mb): fix the bug. Thanks, arton.
+ * ext/win32ole/win32ole.c (ole_type_progid, reg_enum_key,
+ reg_get_val, ole_wc2mb): fix the bug. Thanks, arton.
[ruby-dev:31576]
-Mon Aug 27 19:10:50 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/etc/etc.c (etc_getlogin): update documentation to note
- security issue. [ruby-Bugs-11821]
-
-Tue Aug 21 21:09:48 2007 Tanaka Akira <akr@fsij.org>
-
- * lib/tmpdir.rb (Dir.mktmpdir): make directory suffix specifiable.
-
-Tue Aug 21 13:57:04 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * hash.c (st_foreach_func, rb_foreach_func): typedefed.
-
-Mon Aug 20 17:25:33 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (mnew): should preserve noex as safe_level.
-
- * eval.c (rb_call0): tighten security check condition..
-
-Sat Aug 18 21:32:20 2007 Tanaka Akira <akr@fsij.org>
-
- * lib/tmpdir.rb (Dir.mktmpdir): new method.
- [ruby-dev:31462]
-
-Sat Aug 18 17:44:42 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/tk/tcltklib.c (Init_tcltklib): use rb_set_end_proc().
-
-Sat Aug 18 15:59:52 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Sep 7 14:02:10 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* 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]
-Sat Aug 18 12:24:30 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * sample/test.rb, test/ruby/test_system.rb(valid_syntax?): keep
- comment lines first.
-
-Thu Aug 16 20:40:50 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * bignum.c (bigtrunc): RBIGNUM(x)->len may be zero. out of bound
- access. [ruby-dev:31404]
-
-Thu Aug 16 16:46:07 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in (aix): enable shared by default.
-
- * configure.in (aix): for 64bit-mode AIX. [ruby-dev:31401]
- + use CC for LDSHARED if non-gcc,
- + moved -G option from *LDFLAGS to LDSHARED,
- + set -brtl only in XLDFLAGS.
-
-Thu Aug 16 13:06:08 2007 Tanaka Akira <akr@fsij.org>
+Fri Sep 7 13:52:36 2007 Tanaka Akira <akr@fsij.org>
* bignum.c (big_lshift): make shift offset long type.
(big_rshift): ditto.
@@ -3711,12 +782,7 @@ Thu Aug 16 13:06:08 2007 Tanaka Akira <akr@fsij.org>
(big_rshift): ditto.
[ruby-dev:31434]
-Thu Aug 16 04:09:19 2007 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-
- * lib/rinda/tuplespace.rb (Rinda::TupleSpace#start_keeper): improve
- keeper thread.
-
-Wed Aug 15 13:50:10 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Aug 16 08:44:55 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* hash.c (rb_hash_delete_key): delete the entry without calling block.
@@ -3725,39 +791,32 @@ Wed Aug 15 13:50:10 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* hash.c (delete_if_i): use rb_hash_delete_key() so that the block
isn't called twice. [ruby-core:11556]
-Sun Arg 12 03:56:30 2007 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Thu Aug 16 08:43:50 2007 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* lib/rinda/tuplespace.rb: fix Rinda::TupleSpace keeper thread bug.
- the thread is started too early. [ruby-talk:264062]
+ the thread is started too early. [ruby-talk:264062]
* test/rinda/test_rinda.rb: ditto.
-Sat Aug 11 07:34:10 2007 Tadayoshi Funaba <tadf@dotrb.org>
-
- * lib/date/format.rb: reverted some wrongly erased "o" options
- (pointed out by nobu).
-
-Tue Aug 7 14:58:39 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Aug 16 08:40:38 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/pty/pty.c (establishShell): handshaking before close slave
device. [ruby-talk:263410]
- * ext/pty/pty.c (MasterDevice, SlaveDevice, deviceNo): constified.
-
- * ext/pty/pty.c (SlaveName): removed static buffer.
-
- * ext/pty/expect_sample.rb: support for autologin.
-
-Tue Aug 7 12:45:13 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Aug 16 08:29:39 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in (ac_cv_func_isinf): set yes also on OpenSolaris.
[ruby-Bugs-12859]
-Mon Aug 6 17:36:29 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Aug 16 08:28:16 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/rexml/encodings/{ISO-8859-15,CP-1252}.rb: fixed invalid syntax.
-Fri Aug 3 11:05:54 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Aug 16 08:26:08 2007 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * lib/README: fixed a typo.
+
+Thu Aug 16 08:20:50 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/extmk.rb (extmake): save all CONFIG values.
@@ -3767,37 +826,15 @@ Fri Aug 3 11:05:54 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/extmk.rb: remove rdoc at clean, and installed list file at
distclean, respectively.
-Fri Aug 3 07:09:05 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/mkmf.rb: more verbose message. [ruby-Bugs-12766]
-
- * lib/mkmf.rb (have_type): suppress a warning with -Wall.
-
- * lib/mkmf.rb (find_type): new method.
-
-Thu Aug 2 13:46:39 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Aug 16 07:58:18 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* sprintf.c (rb_f_sprintf): should not check positional number as
width. [ruby-core:11838]
-Mon Jul 30 11:16:40 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * bignum.c (rb_big_aref): check for Bignum index range.
- [ruby-dev:31271]
-
-Sat Jul 28 09:35:41 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/digest/lib/digest.rb (Digest::self.const_missing): avoid
- infinite recursive const_missing call. [ruby-talk:262193]
-
-Thu Jul 26 13:57:45 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * dln.c (load_1, dln_find_1): constified.
+Thu Aug 16 07:52:24 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* dln.c (conv_to_posix_path): removed.
- * ruby.c (usage): constified.
-
* ruby.c (rubylib_mangled_path, rubylib_mangled_path2): return
VALUE instead of a pointer to static buffer.
@@ -3806,12 +843,17 @@ Thu Jul 26 13:57:45 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ruby.c (ruby_init_loadpath): not convert built-in paths.
-Sun Jul 22 16:07:12 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Aug 16 07:51:37 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.
+
+Thu Aug 16 07:42:10 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* intern.h (is_ruby_native_thread): removed since declared as an int
function in ruby.h already.
-Sun Jul 22 14:33:40 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Aug 16 07:40:41 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* file.c (rb_file_s_rename): deleted code to get rid of a bug of
old Cygwin.
@@ -3838,45 +880,30 @@ Sun Jul 22 14:33:40 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
folevariable_ole_type, folevariable_ole_type_detail,
folevariable_value, folemethod_visible): missing return value.
-Sat Jul 21 17:48:26 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Aug 16 07:32:13 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb (create_makefile): make OBJS depend on RUBY_EXTCONF_H
only if extconf.h is created.
- * bcc32/{Makefile.sub,configure.bat,setup.mak: configure_args
- support.
-
- * bcc32/setup.mak: check runtime version.
-
- * win32/win32.c (rb_w32_open_osfhandle): prototype has changed
- in bcc 5.82.
+Thu Aug 16 07:29:33 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* {win32,wince,bcc32}/setup.mak (-version-): no RUBY_EXTERN magic.
- * win32/resource.rb: include patchlevel number.
-
-Sat Jul 21 12:06:48 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Aug 16 06:43:03 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb (init_mkmf): should remove mkmf.log too.
-Sat Jul 21 01:53:17 2007 Tadayoshi Funaba <tadf@dotrb.org>
-
- * lib/date/format.rb (Date._parse): completes calendar week based year.
-
- * lib/date/format.rb (Date._parse): detects year of ordinal date in
- extended format.
-
-Fri Jul 20 15:22:51 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Aug 16 06:40:58 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/openssl/ossl_config.c (ossl_config_set_section): do not
initialize aggregations with dynamic values. [ruby-talk:259306]
-Thu Jul 19 19:24:14 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Aug 16 06:39:19 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (get_backtrace): check the result more.
[ruby-dev:31261] [ruby-bugs-12398]
-Thu Jul 19 14:38:45 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Aug 16 06:32:25 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* bignum.c (rb_big_lshift, rb_big_rshift): separated functions
to get rid of infinite recursion. fixed calculation in edge
@@ -3884,53 +911,36 @@ Thu Jul 19 14:38:45 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* numeric.c (rb_fix_lshift, rb_fix_rshift): ditto.
-Wed Jul 18 16:57:41 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Aug 16 06:26:58 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* bignum.c (rb_big_pow): refine overflow check. [ruby-dev:31242]
-Wed Jul 18 08:47:09 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Thu Aug 16 06:25:48 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]
-Tue Jul 17 00:50:53 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Thu Aug 16 06:24:39 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
- * numeric.c (fix_pow): integer power calculation: 0**n => 0,
+ * numeric.c (fix_pow): integer power calculation: 0**n => 0,
1**n => 1, -1**n => 1 (n: even) / -1 (n: odd).
- * test/ruby/test_fixnum.rb (TestFixnum::test_pow): update test
- suite. pow(-3, 2^64) gives NaN when pow(3, 2^64) gives Inf.
-
-Mon Jul 16 23:07:51 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Thu Aug 16 06:11:34 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/base64.rb (Base64::b64encode): should not specify /o option
for regular expression. [ruby-dev:31221]
-Mon Jul 16 18:29:33 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * string.c (rb_str_rindex_m): accept string-like object convertible
- with #to_str method, as well as rb_str_index_m. [ruby-core:11692]
-
-Mon Jul 16 05:45:53 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Aug 16 06:08:53 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]
-Mon Jul 16 00:26:10 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * bignum.c (rb_big_pow): removed invariant variable. [ruby-dev:31236]
-
-Sun Jul 15 23:59:57 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * bignum.c (rb_big_neg): SIGNED_VALUE isn't in 1.8.
+Thu Aug 16 05:39:31 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sun Jul 15 22:24:49 2007 pegacorn <subscriber.jp AT gmail.com>
+ * bignum.c (bignorm): do not empty Bignum. [ruby-dev:31229]
- * ext/digest/digest.c (rb_digest_instance_update,
- rb_digest_instance_finish, rb_digest_instance_reset,
- rb_digest_instance_block_length): %s in rb_raise() expects char*.
- [ruby-dev:31222]
+Thu Aug 16 05:12:05 2007 pegacorn <subscriber.jp AT gmail.com>
* ext/openssl/ossl.h: include ossl_pkcs5.h. [ruby-dev:31231]
@@ -3951,198 +961,89 @@ Sun Jul 15 22:24:49 2007 pegacorn <subscriber.jp AT gmail.com>
* win32.h (rb_w32_getcwd): prototype added. [ruby-dev:31232]
-Sun Jul 15 21:07:43 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * bignum.c (bigtrunc): do not empty Bignum. [ruby-dev:31229]
-
-Sun Jul 15 19:05:28 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Aug 16 05:02:39 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* bignum.c (rb_cstr_to_inum): check leading non-digits.
[ruby-core:11691]
-Sun Jul 15 04:42:20 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * bignum.c (get2comp): do nothing for empty Bignum. [ruby-dev:31225]
-
-Sat Jul 14 14:04:06 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * enum.c (sort_by_cmp): check if reentered. [ruby-dev:24291]
-
-Sat Jul 14 12:44:14 2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-
- * test/openssl/test_pkcs7.rb: reverted the previous patch. it should
- be as it was to check interface compatibility. sorry for bothering
- with this.
-
-Sat Jul 14 12:16:17 2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-
- * test/openssl/test_pkcs7.rb: follow the library change. applied a
- patch from <zn at mbf.nifty.com> [ruby-dev:31214].
- NOTE: r12496 imports the latest openssl libs from trunk to ruby_1_8
- though its's not ChangeLog-ed. maintainer should aware that.
-
-Sat Jul 14 02:51:52 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Thu Aug 16 05:00:01 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* numeric.c (fix_pow): 0**2 should not raise floating point
exception. [ruby-dev:31216]
-Sat Jul 14 02:25:48 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * numeric.c (int_pow): wrong overflow detection. [ruby-dev:31213]
-
- * numeric.c (int_pow): wrong overflow detection. [ruby-dev:31215]
-
-Fri Jul 13 16:10:00 2007 Tanaka Akira <akr@fsij.org>
-
- * lib/open-uri.rb (URI::Generic#find_proxy): use ENV.to_hash to access
- http_proxy environment variable to avoid case insensitive
- environment search.
-
-Fri Jul 13 15:02:15 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Aug 16 04:56:35 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* win32/win32.c (CreateChild): enclose command line except for
command.com which can not handle quotes. [ruby-talk:258939]
-Fri Jul 13 10:10:46 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Aug 16 04:54:45 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb (link_command, cc_command, cpp_command): do not expand
::CONFIG which is an alias of MAKEFILE_CONFIG.
-Thu Jul 12 17:03:15 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Aug 16 04:53:21 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* struct.c (rb_struct_init_copy): disallow changing the size.
[ruby-dev:31168]
-Wed Jul 11 23:38:14 2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
+Thu Aug 16 04:52:11 2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* random.c: documentation fix. srand(0) initializes PRNG with '0',
not with random_seed.
-Tue Jul 10 14:50:01 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Aug 16 04:49:10 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* bcc32/{Makefile.sub,setup.mak}: remove surplus slash from srcdir.
-Fri Jul 6 15:22:58 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (rb_interrupt): suppress a gcc's officious warning.
-
-Thu Jul 5 16:44:28 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * numeric.c (int_pow): fix previous nubu's commit.
-
- * test/ruby/test_fixnum.rb: new test.
-
-Thu Jul 5 15:56:06 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * numeric.c (int_pow): even number multiplication never be negative.
-
-Mon Jul 2 14:34:43 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Aug 16 04:40:37 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* sprintf.c (rb_f_sprintf): sign bit extension should not be done
if FPLUS flag is specified. [ruby-list:39224]
-Sat Jun 30 16:05:41 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Thu Aug 16 04:39:15 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* array.c (rb_ary_initialize): should call rb_ary_modify() first.
[ruby-core:11562]
-Sat Jun 30 00:17:00 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Aug 16 04:38:39 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (yylex): return non-valid token for an invalid
- instance/class variable name. a patch from Yusuke ENDOH
+ instance/class variable name. a patch from from Yusuke ENDOH
<mame AT tsg.ne.jp>. [ruby-dev:31095]
-Fri Jun 29 11:23:09 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Aug 16 04:36:41 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (dsym): return non-null NODE even if yyerror(). based on a
- patch from Yusuke ENDOH <mame AT tsg.ne.jp>. [ruby-dev:31085]
-
-Tue Jun 26 16:35:21 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ patch from from Yusuke ENDOH <mame AT tsg.ne.jp>. [ruby-dev:31085]
- * process.c (ruby_setreuid, ruby_setregid): rename to get rid of name
- clash.
+Thu Aug 16 04:34:56 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* process.c (proc_exec_v, rb_proc_exec): preserve errno.
-Sat Jun 23 00:37:46 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * hash.c (rb_hash_select): remove unnecessary varargs for
- rb_hash_select. a patch from Daniel Berger
- <Daniel.Berger at qwest.com>. [ruby-core:11527]
-
- * hash.c: ditto.
-
-Mon Jun 18 08:47:54 2007 Technorama Ltd. <oss-ruby@technorama.net>
-
- * ext/openssl/{extconf.rb,ossl_ssl_session.c}:
- Fix ruby-Bugs-11513.
-
- * ext/openssl/ossl_pkey_ec.c
- New methods EC::Point.[eql,make_affine!,invert!,on_curve?,infinity?]
- By default output the same key form as the openssl command.
-
- * ext/openssl/ossl_rand.c
- New method Random.status?
-
-Mon Jun 18 13:54:36 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (ruby_cleanup): return EXIT_FAILURE if any exceptions occured
- in at_exit blocks. [ruby-core:11263]
-
-Mon Jun 18 01:14:10 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Aug 16 04:30:45 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* variable.c (rb_path2class): get rid of dangling pointer caused by
optimized out value.
- * variable.c (rb_global_entry, rb_f_untrace_var, rb_alias_variable,
- rb_generic_ivar_table, generic_ivar_get, generic_ivar_set,
- generic_ivar_defined, generic_ivar_remove, rb_mark_generic_ivar,
- rb_free_generic_ivar, rb_copy_generic_ivar,
- rb_obj_instance_variables): suppress warnings.
-
-Fri Jun 15 22:33:29 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * common.mk (realclean): separate local and ext.
-
- * ext/extmk.rb: not remove unrelated directories.
-
-Fri Jun 15 17:01:20 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+Thu Aug 16 04:24:28 2007 NAKAMURA Usaku <usa@ruby-lang.org>
* ext/dl/lib/dl/win32.rb: seems that dl doesn't accept void argument.
fixed [ruby-bugs:PR#5489].
-Thu Jun 14 17:09:48 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Aug 16 04:23:44 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser): handle more
extensions. [ruby-dev:30972]
-Wed Jun 13 06:05:12 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in (darwin): prohibit loading extension libraries to
- miniruby.
-
-Wed Jun 13 05:47:58 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (rb_kill_thread): renamed in order to get rid of conflict
- with a BeOS system function. [ruby-core:10830]
-
-Tue Jun 12 14:53:51 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/mkmf.rb (Logging.quiet, Logging.message): added quiet flag and
- use it. [ruby-core:10909]
-
- * lib/mkmf.rb (find_header): use header names in the message.
-
-Sun Jun 10 13:47:36 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Aug 16 04:14:17 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * test/ruby/test_beginendblock.rb (test_should_propagate_signaled):
- get rid of invoking shell. [ruby-dev:30942]
-
-Thu Jun 7 19:02:48 2007 Tanaka Akira <akr@fsij.org>
+ * 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>
- * lib/pp.rb: call original "method" method instead of redefined one.
+ * lib/rexml/dtd/dtd.rb: Fixed typo in code. Fixes bug #10420
-Mon Jun 4 11:11:12 2007 Shugo Maeda <shugo@ruby-lang.org>
+Thu Aug 16 04:08:20 2007 Shugo Maeda <shugo@ruby-lang.org>
* lib/net/imap.rb (ResponseParser#next_token): fixed
error message. (backported from HEAD)
@@ -4151,219 +1052,58 @@ Mon Jun 4 11:11:12 2007 Shugo Maeda <shugo@ruby-lang.org>
the condition not to refer @token.symbol unexpectedly.
Thanks, Dick Monahan. (backported from HEAD)
-Thu May 31 17:27:53 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/benchmark.rb (Benchmark::Job::item): avoid modifying the
- argument unintentionally. [ruby-talk:253676]
-
-Thu May 31 02:12:32 2007 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-
- * lib/rinda/tuplespace.rb (Rinda::TupleBag): create index on tuple bag
- by first column.
-
-Wed May 30 13:27:40 2007 Shugo Maeda <shugo@ruby-lang.org>
-
- * lib/net/ftp.rb (Net::FTP#transfercmd): skip 2XX
- responses for some FTP servers. (backported from HEAD)
+Thu Aug 16 04:05:20 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-Wed May 30 05:17:55 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (rb_eval): get rid of SEGV at ZSUPER in a block
- [ruby-dev:30836]
-
-Wed May 30 04:29:43 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (thread_timer): timer thread should not receive any
- signals. submitted by Sylvain Joyeux. [ruby-core:08546]
+ * marshal.c (w_extended): erroneous check condition when dump
+ method is defined. [ruby-core:10646]
-Wed May 30 04:18:37 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sat Jun 9 10:40:00 2007 URABE Shyouhei <shyouhei@ruby-lang.org>
- * eval.c (rb_eval_cmd): just return if no exceptions.
- [ruby-dev:30820]
+ * stable version 1.8.5-p52 released.
-Tue May 29 11:01:06 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Jun 7 14:53:46 2007 URABE Shyouhei <shyouhei@ruby-lang.org>
- * win32/win32.c (rb_w32_opendir): store attributes of the second
- entries or later too.
+ * eval.c (method_inspect): show proper class name.
+ [ruby-talk:248647], Thanks Calamitas.
- * win32/win32.c (rb_w32_opendir, rb_w32_readdir): eliminate magic
- numbers.
+Mon May 28 19:37:24 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-Mon May 28 02:54:05 2007 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+ * win32/win32.c (move_to_next_entry): revert r12338. not necessary
+ on ruby_1_8_5.
- * lib/rinda/tuplespace.rb (Rinda::TupleBag#delete): use rindex and
- delete_at instead of delete for little improvement.
+Sun May 27 05:52:37 2007 URABE Shyouhei <shyouhei@ruby-lang.org>
-Sat May 26 00:05:22 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * eval.c (mnew): call of super via a method object should work again.
+ [ruby-talk:248647], Thanks Calamitas.
- * test/ruby/test_beginendblock.rb (test_should_propagate_signaled):
- skip tests for exitstatus and termsig on the platforms where
- signals not supported.
+ * test/ruby/test_method.rb (TestMethod::test_method_super): test for
+ above fix.
Wed May 23 06:51:46 2007 URABE Shyouhei <shyouhei@ruby-lang.org>
* lib/cgi.rb (CGI#[]): get rid of exceptions being raised.
[ruby-dev:30740], Thanks Kentaro KAWAMOTO.
-Wed May 23 05:49:49 2007 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]
-
-Sat May 19 10:29:18 2007 Tadayoshi Funaba <tadf@dotrb.org>
-
- * lib/date/format.rb (Date._parse): detects some OFX dates
- (Of course not fully).
-
-Fri May 18 23:07:33 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * array.c (rb_ary_first): call rb_ary_subseq() instead of pushing
- values by itself. [ruby-talk:252062]
-
- * array.c (rb_ary_first): add negative length check.
-
-Fri May 18 17:10:31 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed May 23 06:14:15 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* win32/win32.c (move_to_next_entry): loc also must move forward.
[ruby-talk:251987]
-Fri May 18 03:02:40 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * win32/mkexports.rb: preserve prefixed underscores for WINAPI
- symbols.
-
- * wince/mkconfig_wce.rb, wince/mkexports.rb: obsolete.
-
-Thu May 17 17:03:11 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * misc/ruby-style.el (ruby-style-label-indent): for yacc rules.
-
-Tue May 15 14:54:07 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+Wed May 23 05:55:04 2007 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.c (init_stdhandle): stderr should be without buffering,
but mswin32 use buffering when stderr is not connected to tty.
-Mon May 14 13:28:03 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/thread/thread.c (wait_list): supress a warning.
-
-Thu May 10 15:21:51 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * ext/iconv/iconv.c (iconv_s_conv): rdoc fix.
-
-Thu May 10 10:14:14 2007 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]
-
-Wed May 9 12:28:57 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * bignum.c (Init_Bignum), numeric.c (Init_Numeric): added fdiv as
- aliases of quo. [ruby-dev:30771]
-
-Wed May 9 11:55:15 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * bignum.c (rb_big_quo): now calculate in integer. [ruby-dev:30753]
-
-Wed May 9 11:51:06 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * bignum.c (rb_big_pow): reduce multiplying for even number.
-
- * bignum.c (rb_big_pow): truncate all zero BDIGITs. [ruby-dev:30733]
-
- * bignum.c (rb_big_pow): improvement by calculating from MSB and using
- factorization. <http://yowaken.dip.jp/tdiary/20070426.html#p01>
-
- * numeric.c (int_pow): calculate power in Fixnum as possible.
- [ruby-dev:30726]
-
-Tue May 8 23:42:51 2007 Tadayoshi Funaba <tadf@dotrb.org>
-
- * lib/date/format.rb (Date._parse): revised treatment of
- hyphened/separatorless dates.
-
- * lib/date/format.rb: some trivial adjustments.
-
-Tue May 8 20:25:05 2007 Tadayoshi Funaba <tadf@dotrb.org>
-
- * lib/date/format.rb: reverted.
-
-Sat May 5 16:26:33 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/date/format.rb (Format::Bag#method_missing): get rid of
- modifying orginal argument. [ruby-core:11090]
-
-Mon Apr 30 01:17:51 2007 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-
- * lib/rinda/tuplespace.rb (TupleSpace#create_entry, TupleBag#push,
- delete): extract method, and rename parameter.
-
-Fri Apr 27 02:00:17 2007 Ryan Davis <ryand-ruby@zenspider.com>
-
- * signal.c: Fixed backwards compatibility for 'raise Interrupt'.
-
- * lib/yaml/tag.rb: Running rdoc over the 1.8.6 tree skips
- Module. Patch from James Britt
-
-Thu Apr 26 13:54:51 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * misc/ruby-style.el: new file. C/C++ style for ruby source code.
-
-Wed Apr 25 19:49:16 2007 Tanaka Akira <akr@fsij.org>
-
- * ext/socket/socket.c (unix_send_io, unix_recv_io): use CMSG_DATA to
- align file descriptor appropriately.
-
-Tue Apr 24 09:33:57 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * dir.c (do_stat, do_lstat, do_opendir): should not warn ENOTDIR.
- [ruby-talk:248288]
-
-Mon Apr 23 22:14:42 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/extmk.rb ($ruby): add extout directory to include path.
- [ruby-core:11003]
-
- * lib/mkmf.rb (libpathflag): not to append RPATHFLAG to current
- directory.
-
- * lib/mkmf.rb (init_mkmf): add current directory to default
- library path with highest priority. [ruby-core:10960]
-
- * lib/mkmf.rb (LINK_SO): LIBPATH to be placed before DLDFLAGS.
-
-Fri Apr 20 16:05:22 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in (LIBPATHFLAG, RPATHFLAG): no needs to be quoted,
- it is done by libpathflag in mkmf.rb.
-
-Fri Apr 20 12:27:04 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/optparse.rb: fix to override conv proc.
-
-Fri Apr 20 12:17:05 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (ruby_cleanup): inversed the order of errinfos.
-
-Thu Apr 19 14:53:32 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed May 23 03:33:55 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/monitor.rb (ConditionVariable#wait, mon_enter, mon_exit_for_cond):
ensures Thread.critical to be false. [ruby-talk:248300]
-Wed Apr 18 10:41:21 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed May 23 03:25:13 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* util.c (ruby_strtod): exponent is radix 10. [ruby-talk:248272]
-Wed Apr 18 02:30:24 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in (LDFLAGS): prepend -L. instead appending it to
- XLDFLAGS. [ruby-core:10933]
-
- * configure.in (Makefile): remove $U for automake from MISSING.
- [ruby-talk:248171]
-
-Tue Apr 17 16:46:46 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Wed May 23 02:09:32 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_yield_0): should not clear state on TAG_NEXT when
it's invoked from within lambda body. [ruby-talk:248136]
@@ -4371,143 +1111,34 @@ Tue Apr 17 16:46:46 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (proc_invoke): handle TAG_NEXT which would be caused by
next in the lambda body as well.
-Mon Apr 16 22:56:01 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/pty/expect_sample.rb: avoid symbolic link representation for
- expect. a patch from Kazuhiro NISHIYAMA <zn at mbf.nifty.com>.
- [ruby-dev:30714]
-
-Mon Apr 16 22:51:11 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * sample: replace TRUE, FALSE with true, false respectively.
- a patch from Kazuhiro NISHIYAMA <zn at mbf.nifty.com>.
- [ruby-dev:30713]
-
-Mon Apr 16 17:08:02 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/optparse.rb (make_switch): do not clobber converter if pattern
- has no convert method. reported by sheepman in [ruby-dev:30709].
-
-Mon Apr 16 16:49:32 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/stringio/stringio.c (strio_seek): consistent behavior with
- IO#seek. patch by sheepman in [ruby-dev:30710].
-
-Mon Apr 16 16:34:08 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (parser_yylex): should set command_start after block
- starting "do"s and braces. [ruby-core:10916]
-
-Sun Apr 15 09:19:57 2007 Tadayoshi Funaba <tadf@dotrb.org>
-
- * lib/date/format.rb: added some zone names.
-
- * lib/date/format.rb (_parse): now interprets doted numerical
- dates as a big endian (except dd.mm.yyyy).
-
-Tue Apr 10 17:37:36 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+Wed May 23 01:55:49 2007 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.c (rb_w32_fclose, rb_w32_close): need to save errno
before calling original fclose()/close().
-Mon Apr 9 09:30:44 2007 Shugo Maeda <shugo@ruby-lang.org>
+Wed May 23 01:42:29 2007 Shugo Maeda <shugo@ruby-lang.org>
* lib/net/imap.rb (disconnect): call shutdown for
SSLSocket. Thanks, Technorama Ltd.
-Thu Apr 5 00:42:48 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed May 23 01:28:14 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* error.c (rb_notimplement), io.c (pipe_open): removed definite
articles and UNIX manual section from messages. [ruby-dev:30690]
-Wed Apr 4 17:09:17 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * io.c (pipe_open): refined the message of NotImplementedError.
- [ruby-dev:30685]
-
-Wed Apr 4 10:18:04 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
* io.c (pipe_open): raise NotImplementedError for command "-" on
platforms where fork(2) is not available. [ruby-dev:30681]
-Tue Apr 3 15:45:41 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+Wed May 23 00:06:19 2007 NAKAMURA Usaku <usa@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]
-Sat Mar 24 23:40:29 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * node.h (struct rb_thread.locals): explicit as struct.
- [ruby-core:10585]
-
- * eval.c, node.h (enum rb_thread_status, struct rb_thread,
- rb_curr_thread, rb_main_thread): prefixed. [ruby-core:10586]
-
- * file.c (chompdirsep): made an unprefixed name static.
-
- * io.c (io_fread): ditto.
-
-Sat Mar 24 01:54:03 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (ruby_cleanup): exit by SystemExit and SignalException in END
- block. [ruby-core:10609]
-
- * test/ruby/test_beginendblock.rb (test_should_propagate_exit_code):
- test for exit in END block. [ruby-core:10760]
-
- * test/ruby/test_beginendblock.rb (test_should_propagate_signaled):
- test for signal in END block.
-
-Thu Mar 22 23:13:17 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (rb_provided): check for extension library if SOEXT is
- explicitly given. [ruby-dev:30657]
-
-Thu Mar 22 10:29:25 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * test/ruby/test_bignum.rb (test_to_s): add tests for Bignum#to_s.
-
-Wed Mar 21 17:04:30 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * bignum.c (rb_big2str0): round up for the most significant digit.
- [ruby-core:10686]
-
-Wed Mar 21 07:21:24 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * 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].
-
-Tue Mar 20 22:54:50 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * marshal.c (w_extended): erroneous check condition when dump
- method is defined. [ruby-core:10646]
-
Tue Mar 20 15:37:24 2007 URABE Shyouhei <shyouhei@ruby-lang.org>
* distruby.rb: Add zip generation.
-Tue Mar 20 11:28:41 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * lib/matrix.rb (Matrix::inverse_from): adding partial pivoting to
- the Gauss-Jordan algorithm, making it stable. a patch from
- Peter Vanbroekhoven. [ruby-core:10641]
-
-Mon Mar 19 11:39:29 2007 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/protocol.rb (rbuf_read): extend buffer size for speed.
-
-Sun Mar 18 04:23:52 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * NEWS: Add a note about the new `date' library defining
- Time#to_date and Time#to_datetime private methods.
-
- * NEWS: Inform that the old `thread' library is considered to be
- stable.
-
- * NEWS: Sort library entries in alphabetical order.
-
Fri Mar 16 21:48:11 2007 Akinori MUSHA <knu@iDaemons.org>
* ext/dl/dl.c (rb_ary2cary): Fix a bug in type validation;
@@ -4521,101 +1152,40 @@ Fri Mar 16 18:28:06 2007 Akinori MUSHA <knu@iDaemons.org>
reported by: UEDA Hiroyuki <ueda AT netforest.ad.jp>
in [ruby-dev:30586].
-Fri Mar 16 16:33:58 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * 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].
-
-Fri Mar 16 16:21:35 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * 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].
-
-Fri Mar 16 16:17:27 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * 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].
-
Wed Mar 14 12:30:00 2007 Shigeo Kobayashi <shigeo@tinyforest.jp>
* ext/bigdecimal/bigdecimal.c: BigDecimal("-.31") is now
treated as ("-0.31") not as ("0.31").
-Tue Mar 13 09:25:10 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * common.mk (clear-installed-list): separated from install-prereq.
-
-Tue Mar 13 06:38:43 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * NEWS: Reword and improve entries.
-
-Tue Mar 13 06:03:46 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * stable version 1.8.6 released from the ruby_1_8_6 branch.
-
-Tue Mar 13 03:24:07 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * runruby.rb: added --pure (turned on by default) and --debugger
- options.
-
-Tue Mar 13 02:50:28 2007 Akinori MUSHA <knu@iDaemons.org>
+Fri Mar 16 18:05:40 2007 Akinori MUSHA <knu@iDaemons.org>
* 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].
-Mon Mar 12 11:07:44 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * 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].
-
- * ext/openssl/ossl_bn.c (Init_ossl_bn): Ditto.
-
- * ext/openssl/ossl_cipher.c (Init_ossl_cipher): Ditto.
-
- * ext/openssl/ossl_digest.c (Init_ossl_digest): Ditto.
+Tue Mar 13 17:29:43 2007 URABE Shyouhei <shyouhei@ruby-lang.org>
- * ext/openssl/ossl_hmac.c (Init_ossl_hmac): Ditto.
+ * stable version 1.8.5-p35 released.
- * ext/openssl/ossl_pkey.c (Init_ossl_pkey): Ditto.
+Tue Mar 13 14:42:10 2007 URABE Shyouhei <shyouhei@ruby-lang.org>
- * ext/openssl/ossl_pkey_dh.c (Init_ossl_dh): Ditto.
+ * test/fileutils/fileasserts.rb: Fix wrong error message.
- * ext/openssl/ossl_pkey_dsa.c (Init_ossl_dsa): Ditto.
+ * lib/fileutils.rb (FileUtils::mv): Type Error; should utilize
+ Strings instead of Symbols here.
- * ext/openssl/ossl_pkey_rsa.c (Init_ossl_rsa): Ditto.
+Mon Mar 12 17:22:44 2007 NAKAMURA Usaku <usa@ruby-lang.org>
- * ext/openssl/ossl_rand.c (Init_ossl_rand): Ditto.
+ * lib/fileutils.rb (FileUtils::mv): fix incomplete backport of
+ FileUtils.mv changes at r11988
- * ext/openssl/ossl_ssl.c (Init_ossl_ssl): Ditto.
+Mon Mar 12 16:09:28 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon Mar 12 01:05:17 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * 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].
-
- * ext/dl/ptr.c (rb_dlptr_inspect): Ditto.
-
-Mon Mar 12 00:59:19 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * 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].
+ * mkconfig.rb (patchlevel): read from version.h.
Sun Mar 11 18:57:50 2007 Akinori MUSHA <knu@iDaemons.org>
- * misc/README: Add a note about ruby-electric.el.
+ * misc/README: Add a note about ruby-electric.el.
* misc/ruby-mode.el (ruby-non-block-do-re): Fix
ruby-non-block-do-re. [ruby-core:03719]
@@ -4633,118 +1203,24 @@ Sun Mar 11 17:45:51 2007 Akinori MUSHA <knu@iDaemons.org>
it; submitted by sheepman <sheepman AT sheepman.sakura.ne.jp>
in [ruby-dev:30524].
-Sun Mar 11 12:09:37 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (error_handle): no message when exiting by signal.
-
- * eval.c (ruby_cleanup): re-send signal. [ruby-dev:30516]
-
- * eval.c (rb_thread_interrupt): instantiate SignalException.
-
- * eval.c (rb_thread_signal_raise): now takes signal number instead
- of signal name.
-
- * intern.h (rb_thread_signal_raise, ruby_default_signal): prototypes.
-
- * signal.c (esignal_init): takes a signal number and an optional
- signal name.
-
- * signal.c (interrupt_init): pass SIGINT always.
-
- * signal.c (ruby_default_signal): invoke system default signal
- handler.
-
- * signal.c (rb_signal_exec, trap): handle SIGTERM. [ruby-dev:30505]
-
-Tue Mar 6 19:08:46 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/digest/lib/md5.rb (MD5::new, MD5::md5): Do not modify
- Digest::MD5.
-
- * ext/digest/lib/sha1.rb (SHA1::new, SHA1::sha1): Ditto.
-
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].
-
-Tue Mar 6 18:44:26 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * 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].
-
- * ext/digest/lib/sha1.rb (SHA1::new, SHA1::sha1): Ditto.
-
-Tue Mar 6 18:24:19 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * time.c (time_to_s): Back out the format changes; discussed
- in [ruby-dev:30495].
-
-Tue Mar 6 11:53:25 2007 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/sample/irbtkw.rbw: fails to exit process.
-
-Mon Mar 5 20:14:49 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * 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].
-
-Sun Mar 4 23:38:07 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * file.c (rb_stat_s_utime): fixed a commit miss for the platforms
- where utimes() does not exist.
-
- * lib/fileutils.rb (touch): ditto.
-
-Sun Mar 4 14:46:56 2007 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * util.c (push_element): should return a int value.
-
-Sun Mar 4 01:05:57 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * lib/set.rb (Set#^, Set#&): Correct documentation. Those methods
- return sets, not arrays; noted by Oliver Frank Wittich <nietz AT
- mangabrain.de>.
-
-Sat Mar 3 23:01:07 2007 Minero Aoki <aamine@loveruby.net>
+
+Sun Mar 4 23:53:27 2007 Minero Aoki <aamine@loveruby.net>
* lib/fileutils.rb (mv): could not move a directory between
different filesystems. [ruby-dev:30411]
-Sat Mar 3 22:57:11 2007 Minero Aoki <aamine@loveruby.net>
-
- * lib/fileutils.rb (touch): last commit causes error if :mtime
- option was not given.
-
-Sat Mar 3 22:37:02 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * file.c (rb_file_s_utime): allow nil to set the current time.
-
- * lib/fileutils.rb (touch): ditto, and added :mtime and :nocreate
- options. fixed: [ruby-talk:219037]
-
-Sat Mar 3 21:17:35 2007 Akinori MUSHA <knu@iDaemons.org>
+Sat Mar 3 21:41:31 2007 Akinori MUSHA <knu@iDaemons.org>
* 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
-Sat Mar 3 19:05:31 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/thread/thread.c (push_list): Use ALLOC().
-
- * ext/thread/thread.c (rb_mutex_alloc): Ditto.
-
- * ext/thread/thread.c (rb_condvar_alloc): Ditto.
-
-Sat Mar 3 18:53:11 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * NEWS: Add a note for String#intern.
-
-Sat Mar 3 16:23:13 2007 Akinori MUSHA <knu@iDaemons.org>
+Sat Mar 3 16:30:39 2007 Akinori MUSHA <knu@iDaemons.org>
* env.h (SCOPE_CLONE): Introduce a new scope flag to prevent a
local_tbl region from getting freed many times; submitted by
@@ -4757,78 +1233,17 @@ Sat Mar 3 16:23:13 2007 Akinori MUSHA <knu@iDaemons.org>
* parse.y (top_local_setup_gen): Ditto.
-Sat Mar 3 16:07:02 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * object.c (rb_obj_ivar_set): RDoc updated according to a
- suggestion from Brian Candler <B.Candler AT pobox.com>.
- [ruby-core:10469]
-
-Thu Mar 1 21:38:07 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sat Mar 3 15:41:33 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (stmt, arg): should not omit lhs of OP_ASGN1 even if
- empty. [ruby-dev:30455]
-
-Thu Mar 1 08:55:38 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (rb_feature_p): check loading_tbl if the given ext is
empty. [ruby-dev:30452]
- * eval.c (rb_feature_p): fix possible buffer overrun.
-
-Thu Mar 1 03:30:21 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/digest/digest.c (get_digest_base_metadata): Allow inheriting
- Digest::Base subclasses, which was unintentionally made
- impossible while restructuring Digest classes.
-
-Thu Mar 1 02:05:17 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * mkconfig.rb (patchlevel): read from version.h.
-
-Thu Mar 1 00:09:39 2007 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]
-
-Wed Feb 28 21:15:00 2007 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * configure.in (ac_cv_func_fcntl): fcntl support for MinGW.
-
- * missing/flock.c: workaround for MinGW.
-
Wed Feb 28 20:51:32 2007 URABE Shyouhei <shyouhei@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]
-Wed Feb 28 18:59:57 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * NEWS: Add NEWS, a document file to keep user visible feature
- changes between releases.
-
-Wed Feb 28 18:35:50 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * 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]
-
-Wed Feb 28 18:34:48 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * 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]
-
-Wed Feb 28 18:31:32 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * doc/NEWS-1.8.0: Rename NEWS to NEWS-1.8.0. This is way too old
- NEWS.
-
-Wed Feb 28 01:22:58 2007 NAKAMURA Usaku <usa@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]
-
Wed Feb 28 00:08:11 2007 URABE Shyouhei <shyouhei@ice.uec.ac.jp>
* mkconfig.rb (RbConfig): add CONFIG['PATCHLEVEL']
@@ -4837,305 +1252,43 @@ Wed Feb 28 00:08:11 2007 URABE Shyouhei <shyouhei@ice.uec.ac.jp>
* distruby.rb: new file
-Tue Feb 27 22:18:45 2007 WATANABE Hirofumi <eban@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].
-
-Tue Feb 27 21:36:47 2007 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * util.c (__crt0_glob_function): use ruby_glob() instead of rb_globi().
-
-Tue Feb 27 21:33:04 2007 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * configure.in (ac_cv_func_setrlimit): workaround for djgpp.
-
-Tue Feb 27 19:38:52 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * lib/base64.rb (Base64::b64encode): Fix documentation; submitted
- by David Symonds <dsymonds@gmail.com> in [ruby-core:10432].
-
-Tue Feb 27 19:36:57 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * 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].
-
- * ext/bigdecimal/bigdecimal.c (BigDecimal_load): Ditto.
-
- * ext/digest/sha1/sha1ossl.c (SHA1_Finish): Ditto.
-
- * ext/digest/rmd160/rmd160ossl.c (RMD160_Finish): Ditto.
-
- * ext/digest/digest.c (rb_digest_base_finish,
- rb_digest_base_update): Ditto.
-
- * ext/nkf/nkf.c (rb_str_resize, rb_nkf_kconv, rb_nkf_guess1,
- rb_nkf_guess2): Ditto.
-
-Tue Feb 27 03:40:09 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * 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].
-
- * ext/thread/thread.c (set_critical): Merge in
- thread_exclusive_ensure().
-
- * ext/thread/thread.c: Consistently use 0 and 1 for
- rb_thread_critical values.
-
-Mon Feb 26 15:18:23 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/thread/thread.c: Use xmalloc()/xfree() instead of
- malloc()/free(); pointed out by shugo in [ruby-dev:30412].
-
-Sun Feb 25 23:02:55 2007 Akinori MUSHA <knu@iDaemons.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].
-
-Sun Feb 25 02:47:43 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.
-
-Sat Feb 24 10:42:01 2007 Minero Aoki <aamine@loveruby.net>
-
- * ext/racc/cparse/cparse.c (cparse_params_mark): remove useless
- rb_gc_mark. Thanks Tomoyuki Chikanaga. [ruby-dev:30405]
-
-Fri Feb 23 15:10:46 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+Tue Feb 27 21:19:35 2007 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.c (set_pioinfo_extra): new function for VC++8 SP1
workaround. [ruby-core:10259]
* win32/win32.c (NtInitialize): call above function.
-Fri Feb 23 14:19:40 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * signal.c (sighandler): need to tell to be interrupted to main
- context when handler is installed.
-
- * win32/win32.[ch] (rb_win32_interrupted): new function to listen
- interrupt.
-
-Fri Feb 23 13:02:17 2007 Akinori MUSHA <knu@iDaemons.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]
-
-Fri Feb 23 12:43:17 2007 James Edward Gray II <james@grayproductions.net>
-
- * 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.
-
- * lib/xmlrpc/create.rb (XMLRPC::Create::conv2value): Add DateTime
- support to xmlrpc; approved by the maintainer.
-
-Mon Feb 19 18:22:52 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * 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]
-
-Mon Feb 19 17:14:28 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * 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]
-
-Sun Feb 18 19:35:21 2007 Tadayoshi Funaba <tadf@dotrb.org>
-
- * lib/date/format.rb: updated based on date2 4.0.3.
-
-Fri Feb 16 11:18:21 2007 Eric Hodel <drbrain@segment7.net>
-
- * lib/.document: Apply patch for irb, e2mmap and README by Hugh Sasse
- <hgs at dmu.ac.uk> from [ruby-core:10135]
-
- * lib/prettyprint.rb: Suppress RDoc for PrettyPrint test suite.
-
-Thu Feb 15 20:26:30 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * lib/uri/ftp.rb: Revert the previous change pending discussion.
-
-Thu Feb 15 18:08:17 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * dir.c (glob_helper): Fix the function declaration.
-
-Thu Feb 15 17:13:32 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * version.h: Welcome to the post-1.8.6 world. Radical changes are
- inhibited in the ruby_1_8 branch until the 1.8.6 final release
- goes out of the door.
-
-Thu Feb 15 16:44:14 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * 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.
-
-Thu Feb 15 11:46:05 2007 KIMURA Koichi <hogemuta@gmail.com>
-
- * 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.
-
-Thu Feb 15 11:00:26 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * lib/uri/generic.rb (URI::Generic::userinfo): should support
- empty password. [ruby-core:10290]
-
- * lib/uri/generic.rb (URI::Generic::set_password): password can be
- cleared by nil. [ruby-core:10290]
+Mon Feb 26 09:57:58 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
- * lib/uri/common.rb (escape): regard second string argument as a
- character set properly. [ruby-dev:27692]
-
- * lib/uri/ftp.rb: Attempt to conform to RFC 1738 with regard to
- relative/absolute paths.
-
- * lib/uri: Lovely RDOC patches from mathew (metaATpoboxDOTcom).
-
-Thu Feb 15 10:57:38 2007 Tietew <tietew@tietew.net>>
-
- * 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]
-
-Thu Feb 15 10:48:40 2007 MenTaLguY <mental@rydia.net>
-
- * ext/thread/thread.c: Handle interrupted waits correctly.
- [ruby-bugs:PR#8663]
-
-Wed Feb 14 19:22:15 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * 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.
+ * 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>
* io.c (rb_f_syscall): Fix buffer overflow with syscall
arguments. [ruby-bugs:PR#8541]
-Sun Feb 11 07:46:45 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * lib/cgi.rb (CGI::QueryExtension::read_multipart): Properly parse
- a quoted-string in a Content-Disposition value.
-
-Sun Feb 11 06:27:54 2007 Akinori MUSHA <knu@iDaemons.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.
-
-Sun Feb 11 06:22:20 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/Setup: Add thread except for platforms without threads
- support.
-
-Sun Feb 11 06:15:16 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/thread/lib/thread.rb: Add a replacement of thread.rb that
- loads this extension.
+Sat Feb 10 09:33:47 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-Sun Feb 11 05:39:47 2007 Akinori MUSHA <knu@iDaemons.org>
+ * ext/win32ole/win32ole.c (ole_variant2val): sorry, fix the enbug.
- * lib/thread.rb: Remove an ineffective part of the code.
-
-Sun Feb 11 05:32:54 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/thread/thread.c (rb_thread_exclusive): Implement
- Thread.exclusive.
-
-Sun Feb 11 05:26:51 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/thread/thread.c: Get rid of use of a dummy function.
-
-Sun Feb 11 01:45:31 2007 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/thread/thread.c (Init_thread): Define missing aliases:
- Queue#enq and SizedQueue#enq.
-
-Sat Feb 10 09:27:35 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
+Sat Feb 10 09:08:01 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c (ole_variant2val): fix compile error
on VC++.
-Sat Feb 10 07:41:52 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
+Sat Feb 10 08:38:30 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c (ole_variant2val): fix the bug when
SAFEARRAY pointer is NULL.
-Sat Feb 10 00:13:11 2007 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/lib/tk.rb: fix typo (TkConfigMethod::__confinfo_cmd,
- __conv_keyonly_opts).
-
-Fri Feb 9 20:44:53 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/thread: Make style fixes (mostly de-K&R'ism) to match the
- rest of the source code.
-
- * ext/thread: Make USE_MEM_POOLS an extconf option.
-
-Fri Feb 9 20:43:01 2007 Akinori MUSHA <knu@iDaemons.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.
-
-Fri Feb 9 15:46:09 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/bigdecimal: Synchronize with trunk. Better function
- prototypes, removal of a useless method `!=', and document
- updates.
-
-Tue Feb 06 22:06:45 2007 NARUSE, Yui <naruse@ruby-lang.org>
-
- * 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]
-
-Wed Jan 31 14:52:09 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_iterate): need to PUSH_ITER in proper order.
- [ruby-core:10125]
-
- * test/ruby/test_iterator.rb (TestIterator::test_block_given_within_iterator):
- add new test. [ruby-core:10125]
-
-Tue Jan 30 14:58:51 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+Tue Feb 6 20:41:39 2007 NAKAMURA Usaku <usa@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)
-Tue Jan 30 12:05:35 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * mkconfig.rb: autoconf 2.61 support. [ruby-core:10016]
-
Sat Jan 27 15:20:11 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* parse.y (dyna_var_lookup): should not alter dvar->val not to
@@ -5143,215 +1296,67 @@ Sat Jan 27 15:20:11 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* parse.y (dyna_init): ditto.
-Fri Jan 26 12:03:39 2007 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/lib/tk.rb (TkConfigMethod#__confinfo_cmd,
- __conv_keyonly_optkeys): make them private [ruby-dev:30074].
-
- * ext/tk/lib/tk/txtwin_abst.rb: fix typo [ruby-dev:30073].
-
- * ext/tk/lib/tk/canvas.rb (TkCanvas#scan_dragto): lack of an argument.
-
- * ext/tk/lib/tk/canvas.rb: clarify the including module name
- [ruby-dev:30080].
-
- * ext/tk/lib/tk/scrollable.rb: change primary name of modules
- [ruby-dev:30080].
-
Wed Jan 24 18:05:39 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* misc/ruby-mode.el (ruby-font-lock-syntactic-keywords): fix
regexp font-lock bug. [ruby-talk:235758]
-Tue Jan 23 11:02:33 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/webrick/httprequest.rb (WEBrick::HTTPRequest::read_line):
-
-Tue Jan 23 18:26:12 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/cgi.rb (CGI::QueryExtension::read_multipart): use == instead
- of ===. [ruby-dev:30176]
+Sun Jan 14 07:26:44 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-Tue Jan 23 10:48:17 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * hash.c: added documentation for Hash about how it uses eql? and
- hash methods for the keys. [ruby-core:09995]
-
-Mon Jan 22 14:57:25 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/socket/socket.c: fix errors in socket sample code.
- [ruby-core:09992]
-
-Sat Jan 13 23:54:48 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c (ole_free, ole_type_free,
- olemethod_free, olevariable_free, oleparam_free,
+ * ext/win32ole/win32ole.c (ole_free, ole_type_free,
+ olemethod_free, olevariable_free, oleparam_free,
ole_event_free): fix memory leak. [ruby-core:09846]
-Fri Jan 12 11:13:55 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Tue Jan 9 12:29:20 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/etc/etc.c (etc_getpwuid, etc_getgrgid): fix to correctly
- convert uid/gid from VALUE. (backport of r11521)
-
-Wed Jan 10 18:57:57 2007 Minero Aoki <aamine@loveruby.net>
-
- * ext/strscan/strscan.c (strscan_do_scan): should set kcode option
- before match. [ruby-dev:29914]
-
- * test/strscan/test_stringscanner.rb: test it.
-
- * re.c: export kcode_set_option and kcode_reset_option (with "rb_"
- prefix).
-
- * intern.h: ditto.
-
-Tue Jan 9 17:45:17 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * file.c (rb_find_file): should not call fpath_check() with NULL.
- fixed: [ruby-core:09867]
-
-Tue Jan 9 03:54:38 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_upto): String#upto from empty string makes
- inifinite loop. [ruby-core:09864]
-
-Sun Jan 7 12:13:26 2007 Eric Hodel <drbrain@segment7.net>
-
- * 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>
+ convert uid/gid from VALUE.
-Sun Jan 7 10:32:12 2007 Eric Hodel <drbrain@segment7.net>
+ * ext/etc/etc.c (etc_getpwuid): ditto.
- * 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.
+Mon Dec 25 20:08:28 2006 URABE Shyouhei <shyouhei@ruby-lang.org>
-Sun Jan 7 09:33:02 2007 Tadayoshi Funaba <tadf@dotrb.org>
+ * ext/openssl/ossl.h: fixed compilation problem on gcc 3.2.
+ [ruby-talk:214786]
- * lib/date/format.rb: updated based on date2 4.0.1.
+Mon Dec 25 10:40:40 2006 URABE Shyouhei <shyouhei@ruby-lang.org>
-Wed Jan 3 11:36:51 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * stable version 1.8.5-p12 released.
- * io.c (ruby_dup): start GC on ENOMEM as well.
+Sat Dec 16 04:02:10 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Mon Jan 1 06:13:11 2007 Eric Hodel <drbrain@segment7.net>
-
- * lib/rdoc/parsers/c_parser.rb: Make Rdoc accessible. Update constant
- value information.
-
-Mon Jan 1 06:13:11 2007 Eric Hodel <drbrain@segment7.net>
-
- * ext/bigdecimal/bigdecimal.c: Update constant comments to provide
- values for RDoc.
-
-Mon Jan 1 06:05:55 2007 Eric Hodel <drbrain@segment7.net>
-
- * 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.
-
-Sun Dec 31 00:31:16 2006 Tadayoshi Funaba <tadf@dotrb.org>
-
- * lib/date.rb, lib/date/format.rb: updated based on date2 4.0.
-
-Thu Dec 14 18:29:13 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * 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 Dec 14 18:20:43 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/irb/locale.rb (IRB::Locale::puts): typo fixed. a patch from
- NAKAMURA Usaku <usa@ruby-lang.org>. [ruby-dev:30012]
-
-Mon Dec 11 11:58:36 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/digest/sha2/lib/sha2.rb: Moved one level up from under
- the superfluous subdirectory digest/.
-
-Mon Dec 11 11:46:18 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * variable.c (rb_define_const): typo fixed.
-
-Mon Dec 11 09:36:29 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_aset): index double decode problem.
- [ruby-core:09695]
-
-Sat Dec 9 21:39:24 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (ruby_cleanup): keep the exception till after END blocks.
- [ruby-core:09675]
-
-Sat Dec 9 11:22:00 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * 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].
+ * ext/tk/tcltklib.c: shouldn't run the killed thread at callback.
+ [ruby-talk: 227408]
-Thu Dec 7 09:29:02 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+Fri Dec 15 17:21:14 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * lib/weakref.rb (WeakRef::__setobj__): should support
- marshaling. [ruby-talk:228508]
+ * lib/rdoc/ri/ri_options.rb: prevent NameError. [ruby-dev:29597]
- * lib/delegate.rb (Delegator::marshal_load): need to call
- __setobj__.
+Thu Dec 14 23:37:38 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Wed Dec 6 23:56:14 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * dir.c (glob_helper): get rid of possible memory leak.
- * Makefile.in, common.mk (NULLCMD): moved for platforms that empty
- command does not run. fixed: [ruby-dev:29994]
+ * win32/win32.c (cmdglob, rb_w32_cmdvector, rb_w32_opendir,
+ rb_w32_get_environ): not to use GC before initialization.
-Wed Dec 6 17:17:26 2006 WATANABE Hirofumi <eban@ruby-lang.org>
+Wed Dec 6 19:53:41 2006 WATANABE Hirofumi <eban@ruby-lang.org>
* configure.in (SITE_DIR): fixed to emtpy RUBY_SITE_LIB in config.h on
NetBSD. fixed: [ruby-dev:29358]
-Tue Dec 5 00:59:05 2006 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]
-
-Mon Dec 4 10:48:03 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ruby.h (OFFT2NUM): use LONG2NUM() if sizeof(long) equals to
- sizeof(off_t).
-
Mon Dec 4 10:43:46 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* parse.y (dyna_init_gen): dvar initialization only if dvar is
assigned inner block. [ruby-talk:227402]
-Mon Dec 4 08:32:49 2006 Shugo Maeda <shugo@ruby-lang.org>
+Mon Dec 4 10:22:26 2006 URABE Shyouhei <shyouhei@ice.uec.ac.jp>
- * lib/cgi.rb (CGI::QueryExtension::read_multipart): should quote
- boundary. JVN#84798830
-
-Sat Dec 2 07:09:04 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * ext/openssl/ossl_ocsp.c: OpenSSL::OCSP::OSCPError should be
- subclass of OpenSSL::OpenSSLError. [ruby-dev:29980]
-
-Fri Dec 1 17:01:49 2006 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * gc.c (ruby_init_stack): decrease "stack level too deep" in Windows.
- merge from trunk.
-
-Fri Dec 1 16:31:53 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/tcltklib.c: shouldn't run the killed thread at callback.
- [ruby-talk: 227408]
+ * stable version 1.8.5-p2 released.
-Mon Nov 27 17:18:27 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sun Dec 3 17:11:12 2006 Shugo Maeda <shugo@ruby-lang.org>
- * sprintf.c (rb_f_sprintf): need not to truncate string if no
- width specifier given for %s. [ruby-dev:29952]
+ * lib/cgi.rb (CGI::QueryExtension::read_multipart): should quote
+ boundary. JVN#84798830
Sun Nov 26 16:36:46 2006 URABE Shyouhei <shyouhei@ruby-lang.org>
@@ -5363,891 +1368,26 @@ Fri Nov 24 10:17:51 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* bignum.c (bignorm): avoid segmentation. a patch from Hiroyuki
Ito <ZXB01226@nifty.com>. [ruby-list:43012]
-Thu Nov 23 10:38:40 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_mod_define_method): set implicit visibility only when
- it's called for the target class (ruby_cbase).
-
-Wed Nov 22 16:00:49 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/extconf.rb: support --with-X11/--without-X11 option.
-
- * ext/tk/README.tcltklib: add description about --with-X11-* option
- [ruby-talk:225166] and --with-X11/--without-X11 option.
-
- * ext/tk/tkutil/extconf.rb: able to be called manually
- [ruby-talk:225950].
-
-Wed Nov 15 23:22:54 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * file.c (test_grpowned, rb_stat_grpowned): should honor
- supplementary group IDs. [ruby-core:09546]
-
-Thu Nov 9 03:15:22 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (BEGIN_CALLARGS): ruby_block may be NULL even when
- ITER_PRE.
-
-Tue Nov 7 18:34:34 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * 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.
-
-Tue Nov 7 18:05:01 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/lib/tk/itemconfig.rb: minor bug fix.
-
-Mon Nov 6 20:11:20 2006 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/0.9.rb (RSS::Rss): removed needless include.
-
-Mon Nov 6 15:41:55 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * 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.
-
- * ext/tk/lib/tkextlib/tile/treeview.rb : support Tile 0.7.8.
-
- * ext/tk/lib/tkextlib/version.rb : [new] add Tk::Tkextlib_RELEASE_DATE
- to get the information from scripts.
-
- * ext/tk/lib/tk.rb: load 'tkextlib/version.rb', and update RELEASE_DATE
-
- * ext/tk/lib/tkextlib/SUPPORT_STATUS: update.
-
- * ext/tk/sample/editable_listbox.rb: [new] the listbox with editable
- items. It's one of the example about usage of Place geometry manager.
-
- * ext/tk/sample/tktextio.rb: improve the functions of TkTextIO class.
- Those are required by 'irbtkw.rbw'.
-
- * 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.
-
-Sun Nov 5 19:53:49 2006 Tadayoshi Funaba <tadf@dotrb.org>
-
- * lib/date.rb: updated based on date2 3.9.7.
-
-Sat Nov 4 13:13:57 2006 Shugo Maeda <shugo@ruby-lang.org>
-
- * lib/net/imap.rb: accept NOMODSEQ. [ruby-core:9002]
- (backported from HEAD)
-
-Fri Nov 3 00:16:37 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/socket/socket.c (ruby_getnameinfo__aix): AF_INET6 workaround
- for AIX. a patch from Yutaka Kanemoto <kinpoco AT gmail.com>.
- [ruby-dev:29744]
-
Thu Nov 2 15:43:39 2006 NAKAMURA Usaku <usa@ruby-lang.org>
* parse.y (primary): should set NODE even when compstmt is NULL.
merge from trunk. fixed: [ruby-dev:29732]
-Thu Nov 2 14:48:30 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * lib/set.rb (Set#^): Fix XOR operation against a container that
- holds duplicate values. [issue: #6444]
-
-Wed Nov 1 02:41:38 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/digest/lib/digest/hmac.rb (Digest::HMAC::update): Minor
- optimization.
-
- * ext/digest/digest.c (rb_digest_instance_equal): Allow comparing
- a digest instance with another of a different class.
-
-Wed Nov 1 01:05:13 2006 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * eval.c (rb_call0): fixed bug of zsuper with both of opt and rest.
- fixed: [ruby-list:42928]
-
- * test/ruby/test_super.rb: add tests to check above bug.
-
-Tue Oct 31 17:03:21 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * time.c (time_dup): duplicate the class of original time.
- [ruby-core:09357]
-
- * lib/time.rb (Time::make_time, Time::rfc2822, Time::httpdate):
- should respect subclasses. [ruby-core:09357]
-
-Mon Oct 30 23:40:52 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * Makefile.in (miniruby): add XLDFLAGS.
-
- * configure.in (aix): use -bE option for miniruby. [ruby-dev:29698]
-
- * dir.c (glob_helper): get rid of possible memory leak.
-
- * win32/win32.c (cmdglob, rb_w32_cmdvector, rb_w32_opendir,
- rb_w32_get_environ): not to use GC before initialization.
-
-Mon Oct 30 19:29:20 2006 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * bignum.c (rb_big2str0): use better approximation.
-
-Mon Oct 30 18:35:33 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * bignum.c (rb_big2str0): wrong allocation length. a patch from
- U.Nakamura <usa at garbagecollect.jp> [ruby-dev:29710]
-
-Mon Oct 30 12:34:02 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_eval): fix commit miss. [ruby-dev:29707]
-
-Mon Oct 30 12:20:58 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * bignum.c (rb_big2str0): a bug in length adjustment.
-
-Mon Oct 30 11:15:40 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * sprintf.c (rb_str_format): should preserve leading zero
- information for negative %b and %x. [ruby-talk:221347]
-
-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.
-
-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]
-
- * signal.c (Init_signal): avoid duplicated installation of SIGCHLD
- handler.
-
-Sun Oct 22 16:47:56 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * string.c (rb_str_substr): should be infected with only original
- string, but not the shared string. fixed: [ruby-core:09152]
-
- * string.c (rb_str_new4): keep shared string untainted when orignal
- string is tainted. fixed: [ruby-dev:29672]
-
-Sun Oct 22 05:20:34 2006 URABE Shyouhei <shyouhei@ice.uec.ac.jp>
-
- * configure.in: alloca is broken; use C_ALLOCA instead.
- [ruby-dev:29416]
-
-Fri Oct 20 10:47:43 2006 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * lib/mkmf.rb: fixed the bug of handling COMMON_MACROS.
-
-Fri Oct 20 08:42:38 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * common.mk (NULLCMD): dummy command.
-
- * bcc32/Makefile.sub (post-install-*): Borland make cannot ignore
- command-less double-colon rules. [ruby-dev:29676]
-
-Fri Oct 20 00:37:07 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * bcc32/Makefile.sub ($(LIBRUBY_SO)): execute pre-link hook.
-
- * ext/extmk.rb: workaround for Borland make.
-
-Wed Oct 18 23:02:40 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * array.c (rb_ary_shift): shorten copy size. fixed: [ruby-list:42907]
-
- * signal.c (Init_signal): handle SIGTERM. fixed: [ruby-list:42895]
-
- * win32/win32.c (rb_w32_utime): allow NULL to set the current time.
- [ruby-talk:219248]
-
-Wed Oct 18 00:55:33 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (parser_yylex): use particular enums. [ruby-core:09221]
-
-Mon Oct 16 08:30:43 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * mkconfig.rb: *OBJS are not needed for extension libraries.
-
- * {bcc32,wince,win32}/Makefile.sub (config.status): fixed typo,
- missing comma.
-
-Sun Oct 15 01:03:08 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/test/unit/collector/dir.rb (Collector::Dir#collect): append base
- directory but not prepend.
-
- * lib/test/unit/collector/dir.rb (Collector::Dir#collect_file): do not
- join with dot. fixed: [ruby-core:09179]
-
-Sat Oct 14 23:39:50 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (singleton): no need to re-create NODE_SELF() again.
- [ruby-core:09177]
-
-Sat Oct 14 23:25:31 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * 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]
-
- * ext/bigdecimal/bigdecimal.c (VpException): ditto.
-
- * ext/dl/handle.c (rb_dlhandle_initialize): ditto.
-
- * ext/gdbm/gdbm.c (rb_gdbm_fatal): ditto.
-
-Sat Oct 14 08:24:45 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/digest/lib/digest/hmac: Back out the addition of digest/hmac
- for now because the API is too premature for a stable branch.
-
-Sat Oct 14 00:55:08 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * bcc32/Makefile.sub (post-install-ext): no longer needed.
-
- * bcc32/configure.bat: get rid of a quirk of Borland make, which
- sets empty macro in command line to "1".
-
-Fri Oct 13 22:50:43 2006 Tadayoshi Funaba <tadf@dotrb.org>
-
- * lib/date.rb: updated based on date2 3.9.5.
-
-Fri Oct 13 22:33:28 2006 Minero Aoki <aamine@loveruby.net>
-
- * lib/fileutils.rb (FileUtils.cp_r): dereference_root=true is
- default in Ruby 1.8. This line is wrongly removed in last commit.
-
-Fri Oct 13 18:19:31 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * object.c: Class#inherited RDoc added. a patch from Daniel
- Berger <djberg96 at gmail.com> [ruby-core:08942]
-
-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.
@@ -6260,7 +1400,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>
@@ -6587,7 +1727,7 @@ Thu Jul 20 15:07:14 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
Thu Jul 20 00:06:29 2006 Keiju Ishitsuka <keiju@ishitsuka.com>
* lib/irb/completion.rb: support for completion of numeric
- number. [ruby-dev: 29038]
+ number. [ruby-dev: 29038]
Wed Jul 19 23:53:05 2006 Kouhei Sutou <kou@cozmixng.org>
@@ -6701,7 +1841,7 @@ Thu Jul 13 22:23:56 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
Thu Jul 13 20:32:19 2006 Kouhei Sutou <kou@cozmixng.org>
* lib/rss/parser.rb: updated documents by a patch from
- Hugh Sasse <hgs at dmu.ac.uk>. [ruby-core:8194]
+ Hugh Sasse <hgs at dmu.ac.uk>. [ruby-core:8194]
Wed Jul 12 13:54:09 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -9774,8 +4914,8 @@ Sat Sep 17 09:45:26 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
Sat Sep 17 08:35:39 2005 Kouhei Sutou <kou@cozmixng.org>
* lib/rss/maker/base.rb (RSS::Maker::ItemsBase#normalize): fixed
- strange RSS::Maker::Item#max_size behavior.
- Thanks to Kazuhiko <kazuhiko@fdiary.net>.
+ strange RSS::Maker::Item#max_size behavior.
+ Thanks to Kazuhiko <kazuhiko@fdiary.net>.
* test/rss/test_maker_1.0.rb (RSS::TestMaker10#test_items): ditto.
@@ -10533,7 +5673,6 @@ Mon Aug 1 01:17:40 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* test/drb/ut_drb.rb: ditto.
Mon Aug 1 00:07:32 2005 Keiju Ishitsuka <keiju@ruby-lang.org>
-
* lib/irb/context.rb: fix `irb --readline` option. [ruby-list:40955]
Fri Jul 29 09:59:38 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
@@ -11018,7 +6157,6 @@ Fri Jul 1 00:18:40 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
destination object. [ruby-talk:146894]
Thu Jun 30 19:00:21 2005 Keiju Ishitsuka <keiju@ruby-lang.org>
-
* lib/irb/ruby-lex.rb (RubyLex::identify_number): alternative implements
for [ruby-dev:26410]. And support a numeric form of 0d99999.
@@ -11990,6 +7128,7 @@ Sat Apr 9 11:59:57 2005 Kouhei Sutou <kou@cozmixng.org>
- gave a name to 'x'.
- undef_method -> remove_method for avoiding a warning in ruby 1.6.
+
* lib/rss/parser.rb: @@setter -> @@setters.
* lib/rss/parser.rb
@@ -12017,28 +7156,34 @@ Sat Apr 9 11:59:57 2005 Kouhei Sutou <kou@cozmixng.org>
elements. (ex. have childlen elements, have some attributes and
a child element and so on.)
+
* lib/rss/dublincore.rb: supported multiple Dublin Core items.
* lib/rss/maker/dublincore.rb: ditto.
* lib/rss/maker/image.rb: supproted new Dublin Core API.
+
* lib/rss/maker/base.rb: added default current_element implementation.
+
* lib/rss/trackback.rb (RSS::TrackBackUtils.new_with_value_if_need):
moved to RSS::Utils.
* lib/rss/utils.rb (RSS::Utils.new_with_value_if_need):
moved from RSS::TrackBackUtils.
+
* lib/rss/maker/image.rb: fixed invalid argument of
add_need_initialize_variable bug.
* lib/rss/maker/trackback.rb: ditto.
+
* lib/rss/rss.rb (Hash#merge): added for ruby 1.6.
* lib/rss/rss.rb (RSS::BaseModel.date_writer): changed to accept nil
for date value.
+
* test/test_dublincore.rb: added tests for plural accessor and
multiple Dublin Core items.
@@ -12054,6 +7199,7 @@ Sat Apr 9 11:59:57 2005 Kouhei Sutou <kou@cozmixng.org>
* test/rss/test_maker_dc.rb (test_date): added a test for #date=
and #dc_date=.
+
* sample/rss/tdiary_plugin/rss-recent.rb:
new option: @options['rss-recent.use-image-link']:
use image as link instread of text if available.
@@ -13044,7 +8190,7 @@ Wed Feb 2 21:56:01 2005 Kouhei Sutou <kou@cozmixng.org>
Tue Feb 1 22:48:48 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* lib/drb/drb.rb (DRb::DRbObject#respond_to?): check marshal_dump and
- _dump.
+ _dump.
Tue Feb 1 00:20:23 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
@@ -13951,7 +9097,7 @@ Wed Dec 15 18:57:01 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
Wed Dec 15 18:48:42 2004 Shugo Maeda <shugo@ruby-lang.org>
* ext/curses/curses.c (window_subwin): call NUM2INT() before
- GetWINDOW(). (backported from CVS HEAD)
+ GetWINDOW(). (backported from CVS HEAD)
Wed Dec 15 17:03:50 2004 NAKAMURA Usaku <usa@ruby-lang.org>
@@ -14574,7 +9720,7 @@ Thu Nov 18 18:41:08 2004 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
* test/ruby/test_stringchar.rb (test_bang): added.
* string.c (rb_str_upcase_bang, rb_str_capitalize_bang)
- (rb_str_swapcase_bang): missing rb_str_modify(). [ruby-dev:24915]
+ (rb_str_swapcase_bang): missing rb_str_modify(). [ruby-dev:24915]
Thu Nov 18 00:21:15 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -15190,7 +10336,7 @@ Mon Oct 18 15:58:01 2004 NAKAMURA Usaku <usa@ruby-lang.org>
Fri Oct 29 16:34:19 2004 Daiki Ueno <ueno@unixuser.org>
* misc/ruby-mode.el (ruby-parse-partial): Parse the rest of the
- line after opening heredoc identifier. [ruby-dev:24635]
+ line after opening heredoc identifier. [ruby-dev:24635]
Mon Oct 18 07:26:21 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
@@ -15386,7 +10532,7 @@ Mon Oct 4 12:53:45 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
Sun Oct 3 21:20:03 2004 Shugo Maeda <shugo@ruby-lang.org>
* lib/net/imap.rb (TEXT_REGEXP): allow 8-bit characters for the german
- version of Microsoft Exchange Server. (backported from HEAD)
+ version of Microsoft Exchange Server. (backported from HEAD)
* lib/net/imap.rb (RTEXT_REGEXP): ditto.
@@ -15711,6 +10857,7 @@ Sun Sep 12 02:41:58 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tcltklib/tcltklib.c: add TclTkIp#allow_ruby_exit? and
allow_ruby_exit=
+
* ext/tk/lib/multi-tk.rb: ditto.
* ext/tk/lib/remote-tk.rb: ditto.
@@ -16191,9 +11338,9 @@ Sun Jul 18 03:21:42 2004 Akinori MUSHA <knu@iDaemons.org>
Sun Jul 18 03:12:11 2004 Shugo Maeda <shugo@ruby-lang.org>
* lib/net/imap.rb (receive_responses): return if a LOGOUT response
- received. (backported from HEAD)
+ received. (backported from HEAD)
* lib/net/imap.rb (send_string_data): wait command continuation
- requests before sending octet data of literals. (backported from HEAD)
+ requests before sending octet data of literals. (backported from HEAD)
Sat Jul 17 23:54:59 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
@@ -16264,7 +11411,7 @@ Thu Jul 15 23:53:38 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
Thu Jul 15 22:59:48 2004 Shugo Maeda <shugo@ruby-lang.org>
* ext/readline/extconf.rb: added dir_config for curses, ncurses,
- termcap. (backported from HEAD)
+ termcap. (backported from HEAD)
Thu Jul 15 20:29:15 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
@@ -16296,6 +11443,7 @@ Thu Jul 15 10:15:04 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/sample/tkextlib/: add samples of Iwidget and TkTable
+
Wed Jul 14 18:08:37 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl_asn1.c (ossl_asn1cons_to_der): fix type of
@@ -16784,7 +11932,7 @@ Tue Jun 22 21:11:36 2004 Masaki Suketa <masaki.suketa@nifty.ne.jp>
Tue Jun 22 16:47:42 2004 Shugo Maeda <shugo@ruby-lang.org>
* lib/net/ftp.rb (MDTM_REGEXP): fix for demon's ftp server.
- Thanks, Rutger Nijlunsing.
+ Thanks, Rutger Nijlunsing.
Mon Jun 21 10:19:23 2004 NAKAMURA Usaku <usa@ruby-lang.org>
@@ -18772,6 +13920,7 @@ Tue Dec 30 12:30:30 2003 Dave Thomas <dave@pragprog.com>
class and a method have the same name, finding Xxx.abc was trying
to find 'abc' in method 'Xxx', not class 'Xxx'.
+
Tue Dec 30 08:32:32 2003 Dave Thomas <dave@pragprog.com>
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_method):
@@ -18779,6 +13928,7 @@ Tue Dec 30 08:32:32 2003 Dave Thomas <dave@pragprog.com>
def each_entry(&b) Dir.foreach(@path) {|f| yield P.new(f) } end
+
Tue Dec 30 08:32:32 2003 Dave Thomas <dave@pragprog.com>
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_method):
@@ -20684,7 +15834,6 @@ Sat Nov 8 13:49:50 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* configure.in: improvement of pthread check
Sat Nov 8 13:28:46 2003 Takaaki Tateishi <ttate@ttsky.net>
-
* ext/dl/sym.c: Add DL.win32_last_error and DL.last_error.
Thanks, Kaoru Shirai.
@@ -23522,7 +18671,6 @@ Tue Aug 12 02:48:56 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (THREAD_ALLOC): initialize IA64 members.
Mon Aug 11 22:31:50 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-
* lib/debug.rb(debug_command): inspection command should inspect
resulting value even if it's nil. [ruby-dev:21180] by OMAE, jun
<jun66j5@ybb.ne.jp>.
@@ -23723,10 +18871,9 @@ For the changes before 1.8.0, see doc/ChangeLog-1.8.0
Local variables:
add-log-time-format: (lambda ()
(let* ((time (current-time))
- (system-time-locale "C")
(diff (+ (cadr time) 32400))
(lo (% diff 65536))
- (hi (+ (car time) (/ diff 65536))))
+ (hi (+ (car time) (/ diff 65536))))
(format-time-string "%a %b %e %H:%M:%S %Y" (list hi lo) t)))
indent-tabs-mode: t
tab-width: 8
diff --git a/Makefile.in b/Makefile.in
index a37bcf65fb..8fd59babcd 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,5 +1,4 @@
SHELL = /bin/sh
-NULLCMD = :
#### Start of system configuration section. ####
@@ -35,9 +34,6 @@ RIDATADIR = $(DESTDIR)$(datadir)/ri/$(MAJOR).$(MINOR)/system
empty =
OUTFLAG = @OUTFLAG@$(empty)
CFLAGS = @CFLAGS@ @XCFLAGS@ @ARCH_FLAG@
-cflags = @cflags@
-optflags = @optflags@
-debugflags = @debugflags@
CPPFLAGS = -I. -I$(srcdir) @CPPFLAGS@
LDFLAGS = @STATIC@ $(CFLAGS) @LDFLAGS@
EXTLDFLAGS =
@@ -56,8 +52,8 @@ RUBY_SO_NAME=@RUBY_SO_NAME@
EXEEXT = @EXEEXT@
PROGRAM=$(RUBY_INSTALL_NAME)$(EXEEXT)
RUBY = $(RUBY_INSTALL_NAME)
-MINIRUBY = @MINIRUBY@ $(MINIRUBYOPT)
-RUNRUBY = @RUNRUBY@ $(RUNRUBYOPT) --
+MINIRUBY = @MINIRUBY@
+RUNRUBY = @RUNRUBY@
#### End of system configuration section. ####
@@ -89,7 +85,7 @@ ASFLAGS = @ASFLAGS@
OBJEXT = @OBJEXT@
MANTYPE = @MANTYPE@
-INSTALLED_LIST= .installed.list
+PREINSTALL = @PREINSTALL@
#### End of variables
all:
@@ -101,7 +97,7 @@ all:
miniruby$(EXEEXT):
@$(RM) $@
- $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINLIBS) $(MAINOBJ) $(MINIOBJS) $(LIBRUBY_A) $(LIBS) $(OUTFLAG)$@
+ $(PURIFY) $(CC) $(MAINOBJ) $(MINIOBJS) $(LIBRUBY_A) $(LIBS) $(OUTFLAG)$@ $(LDFLAGS) $(MAINLIBS)
$(PROGRAM):
@$(RM) $@
@@ -116,7 +112,6 @@ $(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}' \
@@ -158,12 +153,9 @@ $(srcdir)/configure: $(srcdir)/configure.in
cd $(srcdir) && $(AUTOCONF)
lex.c: keywords
- ( gperf -C -p -j1 -i 1 -g -o -t -N rb_reserved_word -k1,3,$$ $? > $@.tmp && mv $@.tmp $@ ) || \
- if test -f $@; then \
- touch $@ && echo $@ touched.; \
- else \
- cp $(srcdir)/lex.c $@ && echo $@ copied.; \
- fi
+ @-$(RM) $@
+ gperf -p -j1 -i 1 -g -o -t -N rb_reserved_word -k1,3,$$ $? > $@ || \
+ cp "$(srcdir)/$@" .
.y.c:
$(YACC) $<
@@ -184,19 +176,3 @@ distclean-local::
ext/extinit.$(OBJEXT): ext/extinit.c $(SETUP)
$(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(OUTFLAG)$@ -c ext/extinit.c
-
-update-rubyspec:
- if [ -d $(srcdir)/rubyspec ]; then \
- cd $(srcdir)/rubyspec/mspec; \
- git pull; \
- cd ../spec/rubyspec; \
- git pull; \
- else \
- git clone $(MSPEC_GIT_URL) $(srcdir)/rubyspec/mspec; \
- git clone $(RUBYSPEC_GIT_URL) $(srcdir)/rubyspec/spec/rubyspec; \
- fi
-
-test-rubyspec:
- @if [ ! -d $(srcdir)/rubyspec ]; then echo No rubyspec here. make update-rubyspec first.; exit 1; fi
- $(RUNRUBY) $(srcdir)/rubyspec/mspec/bin/mspec -r$(srcdir)/ext/purelib.rb $(srcdir)/rubyspec/spec/rubyspec/$(MAJOR).$(MINOR)
-
diff --git a/NEWS b/NEWS
deleted file mode 100644
index 965ce6de5a..0000000000
--- a/NEWS
+++ /dev/null
@@ -1,638 +0,0 @@
-= NEWS
-
-This document is a list of user visible feature changes made between
-releases except for 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.
-
-* REXML
-
- * REXML::Document.entity_expansion_limit=
-
- New method to set the entity expansion limit. By default the limit is
- set to 10000. See the following URL for details.
-
- http://www.ruby-lang.org/en/news/2008/08/23/dos-vulnerability-in-rexml/
-
-== Changes since the 1.8.6 release
-
-=== Configuration changes
-
-* vendor_ruby directory
-
- A new library directory named `vendor_ruby' is introduced in
- addition to `site_ruby'. The idea is to separate libraries
- installed by the package system (`vendor') from manually (`site')
- installed libraries preventing the former from getting overwritten
- by the latter, while preserving the user option to override vendor
- libraries with site libraries. (`site_ruby' takes precedence over
- `vendor_ruby')
-
- If you are a package maintainer, make each library package configure
- the library passing the `--vendor' option to `extconf.rb' so that
- the library files will get installed under `vendor_ruby'.
-
- You can change the directory locations using configure options such
- as `--with-sitedir=DIR' and `--with-vendordir=DIR'.
-
-=== Global constants
-
-* new constants
-
- * RUBY_COPYRIGHT
- * RUBY_DESCRIPTION
-
-=== Library updates (outstanding ones only)
-
-* new library
-
- * securerandom
-
-* builtin classes
-
- * Array#flatten
- * Array#flatten!
-
- Takes an optional argument that determines the level of recursion
- to flatten.
-
- * Array#eql?
- * Array#hash
- * Array#==
- * Array#<=>
-
- Handle recursive data properly.
-
- * Array#index
- * Array#rindex
-
- Take a block instead of an argument.
-
- * Array#collect!
- * Array#map!
- * Array#each
- * Array#each_index
- * Array#reverse_each
- * Array#reject
- * Array#reject!
- * Array#delete_if
-
- Return an enumerator if no block is given.
-
- Note that #map and #collect still return an array unlike Ruby 1.9
- to keep compatibility.
-
- * Array#pop
- * Array#shift
-
- Take an optional argument specifying the number of elements to
- remove.
-
- * Array#choice
- * Array#combination
- * Array#cycle
- * Array#drop
- * Array#drop_while
- * Array#permutation
- * Array#product
- * Array#shuffle
- * Array#shuffle!
- * Array#take,
- * Array#take_while
-
- New methods.
-
- * Binding#eval
-
- New method.
-
- * Dir#each
- * Dir#foreach
-
- Return an enumerator if no block is given.
-
- * Enumerable::Enumerator
-
- New class for various enumeration defined by the enumerator library.
-
- * Enumerable#each_slice
- * Enumerable#each_cons
- * Object#to_enum
- * Object#enum_for
-
- New methods for various enumeration defined by the enumerator library.
-
- * Enumerable#count
- * Enumerable#cycle
- * Enumerable#drop
- * Enumerable#drop_while
- * Enumerable#find_index
- * Enumerable#first
- * Enumerable#group_by
- * Enumerable#max_by
- * Enumerable#min_by
- * Enumerable#minmax
- * Enumerable#minmax_by
- * Enumerable#none?
- * Enumerable#one?
- * Enumerable#take
- * Enumerable#take_while
-
- New methods.
-
- * Enumerable#find
- * Enumerable#find_all
- * Enumerable#partition
- * Enumerable#reject
- * Enumerable#select
- * Enumerable#sort_by
-
- Return an enumerator if no block is given.
-
- Note that #map and #collect still return an array unlike Ruby 1.9
- to keep compatibility.
-
- * Enumerable#inject
-
- Accepts a binary operator instead of a block.
-
- * Enumerable#reduce
-
- New alias to #inject.
-
- * Hash#eql?
- * Hash#hash
- * Hash#==
-
- Handle recursive data properly.
-
- * Hash#delete_if
- * Hash#each
- * Hash#each_key
- * Hash#each_pair
- * Hash#each_value
- * Hash#reject!
- * Hash#select
- * ENV.delete_if
- * ENV.each
- * ENV.each_key
- * ENV.each_pair
- * ENV.each_value
- * ENV.reject!
- * ENV.select
-
- Return an enumerator if no block is given.
-
- * GC.stress
- * GC.stress=
-
- New methods.
-
- * Integer#ord
- * Integer#odd?
- * Integer#even?
- * Integer#pred
-
- New methods.
-
- * Integer#downto
- * Integer#times
- * Integer#upto
-
- Return an enumerator if no block is given.
-
- * IO#each
- * IO#each_line
- * IO#each_byte
- * IO.foreach
- * ARGF.each
- * ARGF.each_line
- * ARGF.each_byte
-
- Return an enumerator if no block is given.
-
- * IO#bytes
- * IO#chars
- * IO#each_char
- * IO#getbyte
- * IO#lines
- * IO#readbyte
- * ARGF.bytes
- * ARGF.chars
- * ARGF.each_char
- * ARGF.getbyte
- * ARGF.lines
- * ARGF.readbyte
-
- New methods.
-
- * Method#name
- * Method#owner
- * Method#receiver
- * UnboundMethod#name
- * UnboundMethod#owner
-
- New methods.
-
- * Module#class_exec
- * Module#module_exec
-
- New methods.
-
- * Numeric#step
-
- Return an enumerator if no block is given.
-
- * Object#instance_exec
- * Object#tap
-
- New methods.
-
- * ObjectSpace.each_object
-
- Return an enumerator if no block is given.
-
- * Process.exec implemented.
-
- * Range#each
- * Range#step
-
- Return an enumerator if no block is given.
-
- * Regexp.union accepts an array of patterns.
-
- * String#bytesize
-
- New method, returning the size in bytes. (alias length and size)
-
- * String#chars
- * String#each_char
- * String#partition
- * String#rpartition
- * String#start_with?
- * String#end_with?
-
- New methods. These are $KCODE aware unlike #index, #rindex and
- #include?.
-
- * String#each_byte
- * String#each
- * String#each_line
- * String#gsub(pattern)
-
- Return an enumerator if no block is given.
-
- * String#upto
-
- An optional second argument is added to specify if the last value
- should be included.
-
- * StopIteration
-
- New exception class that causes Kernel#loop to stop iteration when
- raised.
-
- * Struct#each
- * Struct#each_pair
-
- Return an enumerator if no block is given.
-
- * Symbol#to_proc
-
- New method.
-
- * __method__
-
- New global function that returns the name of the current method as
- a Symbol.
-
-* enumerator
-
- * Enumerator is now a built-in module. The #next and #rewind
- methods are implemented using the "generator" library. Use with
- care and be aware of the performance loss.
-
-* ipaddr
-
- * New methods
- * IPAddr#<=>
- * IPAddr#succ
-
- IPAddr objects are now comparable and enumerable having these
- methods. This also means that it is possible to have a Range
- object between two IPAddr objects.
-
- * IPAddr#to_range
-
- A new method to create a Range object for the (network) address.
-
- * Type coercion support
- * IPAddr#&
- * IPAddr#|
- * IPAddr#==
- * IPAddr#include?
-
- These methods now accept a string or an integer instead of an
- IPAddr object as the argument.
-
-* net/smtp
-
- * Support SSL/TLS.
-
-* openssl
-
- * New classes
- * OpenSSL::PKey::EC
- * OpenSSL::PKey::EC::Group
- * OpenSSL::PKey::EC::Point
- * OpenSSL::PKey::PKCS5
- * OpenSSL::SSL::Session
-
- * Documentation!
-
- * Various new methods (see documentation).
-
- * Remove redundant module namespace in Cipher, Digest, PKCS7, PKCS12.
- Compatibility classes are provided which will be removed in Ruby 1.9.
-
-* shellwords
-
- * Add methods for escaping shell-unsafe characters:
- * Shellwords.join
- * Shellwords.escape
- * Array#shelljoin
- * String#shellescape
-
- * Add shorthand methods:
- * Shellwords.split (alias shellwords)
- * String#shellsplit
-
-* stringio
-
- * StringIO#getbyte
- * StringIO#readbyte
-
- New methods. (aliases for compatibility with 1.9)
-
- * StringIO#each_char
- * StringIO#chars
-
- New methods.
-
- * StringIO#each
- * StringIO#each_line
- * StringIO#each_byte
-
- Return an enumerator if no block is given.
-
-* tempfile
-
- * Tempfile.open and Tempfile.new now accept a suffix for the
- temporary file to be created. To specify a suffix, pass an array
- of [basename, suffix] as the first argument.
-
- Tempfile.open(['image', 'jpg']) { |tempfile| ... }
-
-* tmpdir
-
- * New method:
-
- * Dir.mktmpdir
-
-* uri
-
- * added LDAPS scheme.
- * Change for RFC3986:
- * FTP
- * URI('ftp://example.com/foo').path #=> 'foo'
- * URI('ftp://example.com/%2Ffoo').path #=> '/foo'
- * URI::FTP.build([nil, 'example.com', nil, '/foo', 'i').to_s #=> 'ftp://example.com/%2Ffoo;type=i'
- * URI merge
- * URI('http://a/b/c/d;p?q').merge('?y') == URI('http://a/b/c/d;p?y')
- * URI('http://a/b/c/d;p?q').merge('/./g') == URI('http://a/g')
- * URI('http://a/b/c/d;p?q').merge('/../g') == URI('http://a/g')
- * URI('http://a/b/c/d;p?q').merge('../../../g') == URI('http://a/g')
- * URI('http://a/b/c/d;p?q').merge('../../../../g') == URI('http://a/g')
-
-* rss
-
- * 0.1.6 -> 0.2.4
-
- * Fix image module URI
-
- * Atom support
-
- * ITunes module support
-
- * Slash module support
-
- * content:encoded with RSS 2.0 support
-
-=== Interpreter Implementation
-
-* passing a block to a Proc [experimental]
-
- This implementation in current shape is known to be buggy/broken,
- especially with nested block invocation. Take this as an
- experimental feature.
-
-* stack trace
-
- On non-SystemStackError exception, full stack trace is shown.
-
-=== Compatibility issues (excluding feature bug fixes)
-
-* String#slice! had some unintentional bugs and they have been fixed
- because either they disagreed with documentation or their respective
- behavior of #slice. Unfortunately, this causes some
- incompatibilities in the following (somewhat rare) cases.
-
- * #slice! no longer expands the array when an out-of-boundary value
- is given.
-
- # Ruby 1.8.6
- a = [1,2]
- a.slice!(4,0) #=> nil
- a #=> [1,2,nil,nil]
-
- # Ruby 1.8.7
- a = [1,2]
- a.slice!(4,0) #=> nil
- a #=> [1,2]
-
- * #slice! no longer raises an exception but returns nil when a
- negative length or out-of-boundary negative position is given.
-
- # Ruby 1.8.6
- a = [1,2]
- a.slice!(1,-1) #=> (raises IndexError)
- a.slice!(-5,1) #=> (raises IndexError)
-
- # Ruby 1.8.7
- a = [1,2]
- a.slice!(1,-1) #=> nil
- a.slice!(-5,1) #=> nil
-
-* String#to_i, String#hex and String#oct no longer accept a sequence
- of underscores (`__') as part of a number.
-
- # Ruby 1.8.6
- '1__0'.to_i #=> 10
- '1__0'.to_i(2) #=> 2 # 0b10
- '1__0'.oct #=> 8 # 010
- '1__0'.hex #=> 16 # 0x10
-
- # Ruby 1.8.7
- '1__0'.to_i #=> 1
- '1__0'.to_i(2) #=> 1
- '1__0'.oct #=> 1
- '1__0'.hex #=> 1
-
- The old behavior was inconsistent with Ruby syntax and considered as
- a bug.
-
-* date
-
- * Date.parse
-
- '##.##.##' (where each '#' is a digit) is now taken as 'YY.MM.DD'
- instead of 'MM.DD.YY'. While the change may confuse you, you can
- always use Date.strptime() when you know what you are dealing
- with.
-
-* stringio
-
- * StringIO#each_byte
-
- The return value changed from nil to self. This is what the
- document says and the same as each_line() does.
-
-* tempfile
-
- * The file name format has changed. No dots are included by default
- in temporary file names any more. See above for how to specify a
- suffix.
-
-* uri
-
- * See above for details.
-
-== Changes since the 1.8.5 release
-
-=== New platforms/build tools support
-
-* IA64 HP-UX
-
-* Visual C++ 8 SP1
-
-* autoconf 2.6x
-
-=== Global constants
-
-* RUBY_PATCHLEVEL
-
- New constant since 1.8.5-p1.
-
-=== Library updates (outstanding ones only)
-
-* 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.
-
-* date
-
- * Updated based on date2 4.0.3.
-
-* digest
-
- * New internal APIs for C and Ruby.
-
- * Support for autoloading.
-
- require 'digest'
-
- # autoloads digest/md5
- md = Digest::MD5.digest("string")
-
- * 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
-
-* nkf
-
- * Updated based on nkf as of 2007-01-28.
-
-* thread
-
- * Replaced with much faster mutex implementation in C. The former
- implementation, which is slow but considered to be stable, is
- available with a configure option `--disable-fastthread'.
-
-* tk
-
- * 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.
-
-* 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.
-
-* date
-
- * Time#to_date and Time#to_datetime are added as private methods.
- They cause name conflict error in ActiveSupport 1.4.1 and prior,
- which comes with Rails 1.2.2 and prior. Updating ActiveSupport
- and/or Rails to the latest versions fixes the problem.
-
-* digest
-
- * The constructor does no longer take an initial string to feed.
- 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")
-
-* fileutils
-
- * A minor implementation change breaks Rake <=0.7.1.
- Updating Rake to 0.7.2 or higher fixes the problem.
-
-* 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.
diff --git a/README b/README
index 1b79781367..cf836415ad 100644
--- a/README
+++ b/README
@@ -29,7 +29,7 @@ The Ruby distribution files can be found in the following FTP site:
The latest source code of this version series can be checked out
through SVN with the following command:
- $ svn co http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8/
+ $ svn co http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8_6/
The trunk of the Ruby source tree can be checked out with the
following command:
@@ -70,10 +70,6 @@ This is what you need to do to compile and install Ruby:
2. Run ./configure, which will generate config.h and Makefile.
- Some C compiler flags may be added by default depending on your
- environment. Specify optflags=.. and warnflags=.. as necessary
- to override them.
-
3. Edit defines.h if you need. Usually this step will not be needed.
4. Remove comment mark(#) before the module names from ext/Setup (or
diff --git a/README.EXT b/README.EXT
index 637b19d25b..e5d39911ca 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 the C type `VALUE'. Each VALUE data
-has its data-type.
+Data in Ruby are represented by 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 converted to a C integer by using the
+some machines), which can be convert to a C integer by using the
FIX2INT() macro. There is also NUM2INT() which converts any Ruby
numbers into C integers. The NUM2INT() macro includes a type check, so
an exception will be raised if the conversion failed. NUM2DBL() can
-be used to retrieve the double float value in the same way.
+be used to retrieve the double float value in same way.
-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.
+To get char* from a VALUE, version 1.7 recommend to use new macros
+StringValue() and StringValuePtr(). StringValue(var) replaces var's
+value to the result of "var.to_str()". StringValuePtr(var) does same
+replacement and returns char* representation of var. These macros
+will skip the replacement if var is a String. Notice that the macros
+requires to take only lvalue as their argument, to change the value
+of var in the replacement.
-In version 1.6 or earlier, STR2CSTR() was used to do 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.
+In version 1.6 or earlier, STR2CSTR() was used to do same thing
+but now it is obsoleted in version 1.7 because of STR2CSTR() has
+a risk of dangling pointer problem in to_str() impliclit conversion.
Other data types have corresponding C structures, e.g. struct RArray
-for T_ARRAY etc. The VALUE of the type which has the corresponding structure
+for T_ARRAY etc. The VALUE of the type which has corresponding structure
can be cast to retrieve the pointer to the struct. The casting macro
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 are given.
+ array. They may dump core if other types 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 doubt you'll need that many.
+which must be less than 17. But I believe you don't need that much. :-)
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 called in the following way:
+defined in Math module. It can be call in the form like:
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 an alias for the method,
+To define alias to 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 a Ruby object
+3.3 Encapsulate C data into 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 checking compilation conditions etc. You
+extconf.rb is the file for check 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
-Normally, the object files list is automatically generated by searching
-source files, but you must define them explicitly if any sources will
+In normal, object files list is automatically generated by searching
+source files, but you need directs 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 be generated, compilation will
+``create_makefile''. The Makefile will not 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 harmless. Prepare it.
+It's no harm. Prepare it.
(6) generate Makefile
@@ -662,11 +662,6 @@ Try generating the Makefile by:
ruby extconf.rb
-If the library should be installed under vendor_ruby directory
-instead of site_ruby directory, use --vendor option as follows.
-
- ruby extconf.rb --vendor
-
You don't need this step if you put the extension library under the ext
directory of the ruby source tree. In that case, compilation of the
interpreter will do this step for you.
@@ -678,12 +673,12 @@ Type
make
to compile your extension. You don't need this step either if you have
-put the extension library under the ext directory of the ruby source tree.
+put 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 adding the directory name in the ext/Setup file so that
+statically by the adding 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
@@ -848,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 the defined variable is read-only.
+rb_define_variable(), except defined variable is read-only.
void rb_define_virtual_variable(const char *name,
VALUE (*getter)(), VALUE (*setter)())
Defines a virtual variable, whose behavior is defined by a pair of C
functions. The getter function is called when the variable is
-referenced. The setter function is called when the variable is set to a
-value. The prototype for getter/setter functions are:
+referred. The setter function is called when the value is set to the
+variable. The prototype for getter/setter functions are:
VALUE getter(ID id)
void setter(VALUE val, ID id)
@@ -1016,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 Start the Interpreter
+** Initialize and Starts the Interpreter
The embedding API functions are below (not needed for extension libraries):
@@ -1036,32 +1031,6 @@ 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:
@@ -1153,7 +1122,7 @@ Returns an array of the added directories ([include_dir, lib_dir]).
pkg_config(pkg)
-Obtains the information for pkg by pkg-config command. The actual
+Obtains the information of pkg by pkg-config command. The actual
command name can be overriden by --with-pkg-config command line
option.
diff --git a/README.EXT.ja b/README.EXT.ja
index 73425c2cdb..30c4d520ba 100644
--- a/README.EXT.ja
+++ b/README.EXT.ja
@@ -765,12 +765,6 @@ Makefile¤ò¼ÂºÝ¤ËÀ¸À®¤¹¤ë¤¿¤á¤Ë¤Ï
¤È¤·¤Æ¤¯¤À¤µ¤¤¡¥
-site_ruby ¥Ç¥£¥ì¥¯¥È¥ê¤Ç¤Ê¤¯¡¢
-vendor_ruby ¥Ç¥£¥ì¥¯¥È¥ê¤Ë¥¤¥ó¥¹¥È¡¼¥ë¤¹¤ë¾ì¹ç¤Ë¤Ï
-°Ê²¼¤Î¤è¤¦¤Ë --vendor ¥ª¥×¥·¥ç¥ó¤ò²Ã¤¨¤Æ¤¯¤À¤µ¤¤¡¥
-
- ruby extconf.rb --vendor
-
¥Ç¥£¥ì¥¯¥È¥ê¤òext°Ê²¼¤ËÍѰդ·¤¿¾ì¹ç¤Ë¤ÏRubyÁ´ÂΤÎmake¤Î»þ¤Ë
¼«Æ°Åª¤ËMakefile¤¬À¸À®¤µ¤ì¤Þ¤¹¤Î¤Ç¡¤¤³¤Î¥¹¥Æ¥Ã¥×¤ÏÉÔÍפǤ¹¡¥
diff --git a/README.ja b/README.ja
index 71ce4ee12c..df8cfc03f4 100644
--- a/README.ja
+++ b/README.ja
@@ -36,7 +36,7 @@ Ruby¤Ï¥Æ¥­¥¹¥È½èÍý´Ø·¸¤ÎǽÎϤʤɤËÍ¥¤ì¡¤Perl¤ÈƱ¤¸¤¯¤é¤¤¶¯ÎÏ
ËÜ¥Ö¥é¥ó¥Á¤ÎRuby¤ÎºÇ¿·¤Î¥½¡¼¥¹¥³¡¼¥É¤Ï¼¡¤Î¥³¥Þ¥ó¥É¤Ç¼èÆÀ¤Ç¤­¤Þ¤¹¡¥
- $ svn co http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8/
+ $ svn co http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8_6/
³«È¯Àèü¤Î¥½¡¼¥¹¥³¡¼¥É¤Ï¼¡¤Î¥³¥Þ¥ó¥É¤Ç¼èÆÀ¤Ç¤­¤Þ¤¹¡¥
@@ -92,10 +92,6 @@ Ruby³ÈÄ¥¥â¥¸¥å¡¼¥ë¤Ë¤Ä¤¤¤ÆÏ䷹礦ruby-ext¥á¡¼¥ê¥ó¥°¥ê¥¹¥È¤È
2. configure¤ò¼Â¹Ô¤·¤ÆMakefile¤Ê¤É¤òÀ¸À®¤¹¤ë
- ´Ä¶­¤Ë¤è¤Ã¤Æ¤Ï¥Ç¥Õ¥©¥ë¥È¤ÎC¥³¥ó¥Ñ¥¤¥éÍÑ¥ª¥×¥·¥ç¥ó¤¬ÉÕ¤­
- ¤Þ¤¹¡¥configure¥ª¥×¥·¥ç¥ó¤Ç optflags=.. warnflags=.. Åù
- ¤Ç¾å½ñ¤­¤Ç¤­¤Þ¤¹¡¥
-
3. (ɬÍפʤé¤Ð)defines.h¤òÊÔ½¸¤¹¤ë
¿ʬ¡¤É¬Í×̵¤¤¤È»×¤¤¤Þ¤¹¡¥
diff --git a/array.c b/array.c
index 89f74d01ff..baae2706e5 100644
--- a/array.c
+++ b/array.c
@@ -2,8 +2,8 @@
array.c -
- $Author$
- $Date$
+ $Author: akr $
+ $Date: 2006/06/24 14:53:36 $
created at: Fri Aug 6 09:46:12 JST 1993
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -20,7 +20,6 @@ VALUE rb_cArray;
static ID id_cmp;
#define ARY_DEFAULT_SIZE 16
-#define ARY_MAX_SIZE (LONG_MAX / sizeof(VALUE))
void
rb_mem_clear(mem, size)
@@ -121,7 +120,7 @@ ary_new(klass, len)
if (len < 0) {
rb_raise(rb_eArgError, "negative array size (or size too big)");
}
- if (len > ARY_MAX_SIZE) {
+ if (len > 0 && len * sizeof(VALUE) <= len) {
rb_raise(rb_eArgError, "array size too big");
}
if (len == 0) len++;
@@ -196,27 +195,6 @@ rb_ary_new4(n, elts)
return ary;
}
-static VALUE
-ary_make_shared(ary)
- VALUE ary;
-{
- if (!FL_TEST(ary, ELTS_SHARED)) {
- NEWOBJ(shared, struct RArray);
- OBJSETUP(shared, rb_cArray, T_ARRAY);
-
- shared->len = RARRAY(ary)->len;
- shared->ptr = RARRAY(ary)->ptr;
- shared->aux.capa = RARRAY(ary)->aux.capa;
- RARRAY(ary)->aux.shared = (VALUE)shared;
- FL_SET(ary, ELTS_SHARED);
- OBJ_FREEZE(shared);
- return (VALUE)shared;
- }
- else {
- return RARRAY(ary)->aux.shared;
- }
-}
-
VALUE
rb_assoc_new(car, cdr)
VALUE car, cdr;
@@ -315,7 +293,7 @@ rb_ary_initialize(argc, argv, ary)
if (len < 0) {
rb_raise(rb_eArgError, "negative array size");
}
- if (len > ARY_MAX_SIZE) {
+ if (len > 0 && len * (long)sizeof(VALUE) <= len) {
rb_raise(rb_eArgError, "array size too big");
}
if (len > RARRAY(ary)->aux.capa) {
@@ -380,9 +358,6 @@ rb_ary_store(ary, idx, val)
idx - RARRAY(ary)->len);
}
}
- else if (idx >= ARY_MAX_SIZE) {
- rb_raise(rb_eIndexError, "index %ld too big", idx);
- }
rb_ary_modify(ary);
if (idx >= RARRAY(ary)->aux.capa) {
@@ -391,10 +366,10 @@ rb_ary_store(ary, idx, val)
if (new_capa < ARY_DEFAULT_SIZE) {
new_capa = ARY_DEFAULT_SIZE;
}
- if (new_capa >= ARY_MAX_SIZE - idx) {
- new_capa = (ARY_MAX_SIZE - idx) / 2;
- }
new_capa += idx;
+ if (new_capa * (long)sizeof(VALUE) <= new_capa) {
+ rb_raise(rb_eArgError, "index too big");
+ }
REALLOC_N(RARRAY(ary)->ptr, VALUE, new_capa);
RARRAY(ary)->aux.capa = new_capa;
}
@@ -409,50 +384,6 @@ rb_ary_store(ary, idx, val)
RARRAY(ary)->ptr[idx] = val;
}
-static VALUE
-ary_shared_array(klass, ary)
- VALUE klass;
- VALUE ary;
-{
- VALUE val = ary_alloc(klass);
-
- ary_make_shared(ary);
- RARRAY(val)->ptr = RARRAY(ary)->ptr;
- RARRAY(val)->len = RARRAY(ary)->len;
- RARRAY(val)->aux.shared = RARRAY(ary)->aux.shared;
- FL_SET(val, ELTS_SHARED);
- return val;
-}
-
-static VALUE
-ary_shared_first(argc, argv, ary, last)
- int argc;
- VALUE *argv;
- VALUE ary;
- int last;
-{
- VALUE nv, result;
- long n;
- long offset = 0;
-
- rb_scan_args(argc, argv, "1", &nv);
- n = NUM2LONG(nv);
- if (n > RARRAY(ary)->len) {
- n = RARRAY(ary)->len;
- }
- else if (n < 0) {
- rb_raise(rb_eArgError, "negative array size");
- }
- if (last) {
- offset = RARRAY(ary)->len - n;
- }
- result = ary_shared_array(rb_cArray, ary);
- RARRAY(result)->ptr += offset;
- RARRAY(result)->len = n;
-
- return result;
-}
-
/*
* call-seq:
* array << obj -> array
@@ -500,6 +431,18 @@ rb_ary_push_m(argc, argv, ary)
return ary;
}
+/*
+ * call-seq:
+ * array.pop -> obj or nil
+ *
+ * Removes the last element from <i>self</i> and returns it, or
+ * <code>nil</code> if the array is empty.
+ *
+ * a = [ "a", "m", "z" ]
+ * a.pop #=> "z"
+ * a #=> ["a", "m"]
+ */
+
VALUE
rb_ary_pop(ary)
VALUE ary;
@@ -507,7 +450,7 @@ rb_ary_pop(ary)
rb_ary_modify_check(ary);
if (RARRAY(ary)->len == 0) return Qnil;
if (!FL_TEST(ary, ELTS_SHARED) &&
- RARRAY(ary)->len * 3 < RARRAY(ary)->aux.capa &&
+ RARRAY(ary)->len * 2 < RARRAY(ary)->aux.capa &&
RARRAY(ary)->aux.capa > ARY_DEFAULT_SIZE) {
RARRAY(ary)->aux.capa = RARRAY(ary)->len * 2;
REALLOC_N(RARRAY(ary)->ptr, VALUE, RARRAY(ary)->aux.capa);
@@ -515,112 +458,54 @@ rb_ary_pop(ary)
return RARRAY(ary)->ptr[--RARRAY(ary)->len];
}
-/*
- * call-seq:
- * array.pop -> obj or nil
- * array.pop(n) -> array
- *
- * Removes the last element from <i>self</i> and returns it, or
- * <code>nil</code> if the array is empty.
- *
- * If a number _n_ is given, returns an array of the last n elements
- * (or less) just like <code>array.slice!(-n, n)</code> does.
- *
- * a = [ "a", "b", "c", "d" ]
- * a.pop #=> "d"
- * a.pop(2) #=> ["b", "c"]
- * a #=> ["a"]
- */
-
static VALUE
-rb_ary_pop_m(argc, argv, ary)
- int argc;
- VALUE *argv;
+ary_make_shared(ary)
VALUE ary;
{
- VALUE result;
+ if (!FL_TEST(ary, ELTS_SHARED)) {
+ NEWOBJ(shared, struct RArray);
+ OBJSETUP(shared, rb_cArray, T_ARRAY);
- if (argc == 0) {
- return rb_ary_pop(ary);
+ shared->len = RARRAY(ary)->len;
+ shared->ptr = RARRAY(ary)->ptr;
+ shared->aux.capa = RARRAY(ary)->aux.capa;
+ RARRAY(ary)->aux.shared = (VALUE)shared;
+ FL_SET(ary, ELTS_SHARED);
+ OBJ_FREEZE(shared);
+ return (VALUE)shared;
}
-
- rb_ary_modify_check(ary);
- result = ary_shared_first(argc, argv, ary, Qtrue);
- RARRAY(ary)->len -= RARRAY(result)->len;
- return result;
-}
-
-VALUE
-rb_ary_shift(ary)
- VALUE ary;
-{
- VALUE top;
-
- rb_ary_modify_check(ary);
- if (RARRAY(ary)->len == 0) return Qnil;
- top = RARRAY(ary)->ptr[0];
- if (!FL_TEST(ary, ELTS_SHARED)) {
- if (RARRAY(ary)->len < ARY_DEFAULT_SIZE) {
- MEMMOVE(RARRAY(ary)->ptr, RARRAY(ary)->ptr+1, VALUE, RARRAY(ary)->len-1);
- RARRAY(ary)->len--;
- return top;
- }
- RARRAY(ary)->ptr[0] = Qnil;
- ary_make_shared(ary);
+ else {
+ return RARRAY(ary)->aux.shared;
}
- RARRAY(ary)->ptr++; /* shift ptr */
- RARRAY(ary)->len--;
-
- return top;
}
/*
* call-seq:
- * array.shift -> obj or nil
- * array.shift(n) -> array
+ * array.shift -> obj or nil
*
* Returns the first element of <i>self</i> and removes it (shifting all
* other elements down by one). Returns <code>nil</code> if the array
* is empty.
- *
- * If a number _n_ is given, returns an array of the first n elements
- * (or less) just like <code>array.slice!(0, n)</code> does.
*
* args = [ "-m", "-q", "filename" ]
- * args.shift #=> "-m"
- * args #=> ["-q", "filename"]
- *
- * args = [ "-m", "-q", "filename" ]
- * args.shift(2) #=> ["-m", "-q"]
- * args #=> ["filename"]
+ * args.shift #=> "-m"
+ * args #=> ["-q", "filename"]
*/
-static VALUE
-rb_ary_shift_m(argc, argv, ary)
- int argc;
- VALUE *argv;
+VALUE
+rb_ary_shift(ary)
VALUE ary;
{
- VALUE result;
- long n;
-
- if (argc == 0) {
- return rb_ary_shift(ary);
- }
+ VALUE top;
rb_ary_modify_check(ary);
- result = ary_shared_first(argc, argv, ary, Qfalse);
- n = RARRAY(result)->len;
- if (FL_TEST(ary, ELTS_SHARED)) {
- RARRAY(ary)->ptr += n;
- RARRAY(ary)->len -= n;
- }
- else {
- MEMMOVE(RARRAY(ary)->ptr, RARRAY(ary)->ptr+n, VALUE, RARRAY(ary)->len-n);
- RARRAY(ary)->len -= n;
- }
+ if (RARRAY(ary)->len == 0) return Qnil;
+ top = RARRAY(ary)->ptr[0];
+ ary_make_shared(ary);
+ RARRAY(ary)->ptr++; /* shift ptr */
+ RARRAY(ary)->len--;
- return result;
+ return top;
}
VALUE
@@ -855,7 +740,17 @@ rb_ary_first(argc, argv, ary)
return RARRAY(ary)->ptr[0];
}
else {
- return ary_shared_first(argc, argv, ary, Qfalse);
+ VALUE nv, result;
+ long n, i;
+
+ rb_scan_args(argc, argv, "01", &nv);
+ n = NUM2LONG(nv);
+ if (n > RARRAY(ary)->len) n = RARRAY(ary)->len;
+ result = rb_ary_new2(n);
+ for (i=0; i<n; i++) {
+ rb_ary_push(result, RARRAY(ary)->ptr[i]);
+ }
+ return result;
}
}
@@ -881,7 +776,17 @@ rb_ary_last(argc, argv, ary)
return RARRAY(ary)->ptr[RARRAY(ary)->len-1];
}
else {
- return ary_shared_first(argc, argv, ary, Qtrue);
+ VALUE nv, result;
+ long n, i;
+
+ rb_scan_args(argc, argv, "01", &nv);
+ n = NUM2LONG(nv);
+ if (n > RARRAY(ary)->len) n = RARRAY(ary)->len;
+ result = rb_ary_new2(n);
+ for (i=RARRAY(ary)->len-n; n--; i++) {
+ rb_ary_push(result, RARRAY(ary)->ptr[i]);
+ }
+ return result;
}
}
@@ -937,41 +842,24 @@ rb_ary_fetch(argc, argv, ary)
/*
* call-seq:
- * array.index(obj) -> int or nil
- * array.index {|item| block} -> int or nil
+ * array.index(obj) -> int or nil
*
- * Returns the index of the first object in <i>self</i> such that is
- * <code>==</code> to <i>obj</i>. If a block is given instead of an
- * argument, returns first object for which <em>block</em> is true.
- * Returns <code>nil</code> if no match is found.
+ * Returns the index of the first object in <i>self</i> such that is
+ * <code>==</code> to <i>obj</i>. Returns <code>nil</code> if
+ * no match is found.
*
* a = [ "a", "b", "c" ]
- * a.index("b") #=> 1
- * a.index("z") #=> nil
- * a.index{|x|x=="b"} #=> 1
- *
- * This is an alias of <code>#find_index</code>.
+ * a.index("b") #=> 1
+ * a.index("z") #=> nil
*/
static VALUE
-rb_ary_index(argc, argv, ary)
- int argc;
- VALUE *argv;
+rb_ary_index(ary, val)
VALUE ary;
-{
VALUE val;
+{
long i;
- if (argc == 0) {
- RETURN_ENUMERATOR(ary, 0, 0);
- for (i=0; i<RARRAY(ary)->len; i++) {
- if (RTEST(rb_yield(RARRAY(ary)->ptr[i]))) {
- return LONG2NUM(i);
- }
- }
- return Qnil;
- }
- rb_scan_args(argc, argv, "01", &val);
for (i=0; i<RARRAY(ary)->len; i++) {
if (rb_equal(RARRAY(ary)->ptr[i], val))
return LONG2NUM(i);
@@ -983,44 +871,29 @@ rb_ary_index(argc, argv, ary)
* call-seq:
* array.rindex(obj) -> int or nil
*
- * Returns the index of the last object in <i>array</i>
- * <code>==</code> to <i>obj</i>. If a block is given instead of an
- * argument, returns first object for which <em>block</em> is
- * true. Returns <code>nil</code> if no match is found.
+ * Returns the index of the last object in <i>array</i>
+ * <code>==</code> to <i>obj</i>. Returns <code>nil</code> if
+ * no match is found.
*
* a = [ "a", "b", "b", "b", "c" ]
- * a.rindex("b") #=> 3
- * a.rindex("z") #=> nil
- * a.rindex{|x|x=="b"} #=> 3
+ * a.rindex("b") #=> 3
+ * a.rindex("z") #=> nil
*/
static VALUE
-rb_ary_rindex(argc, argv, ary)
- int argc;
- VALUE *argv;
+rb_ary_rindex(ary, val)
VALUE ary;
-{
VALUE val;
+{
long i = RARRAY(ary)->len;
- if (argc == 0) {
- RETURN_ENUMERATOR(ary, 0, 0);
- while (i--) {
- if (RTEST(rb_yield(RARRAY(ary)->ptr[i])))
- return LONG2NUM(i);
- if (i > RARRAY(ary)->len) {
- i = RARRAY(ary)->len;
- }
- }
- return Qnil;
- }
- rb_scan_args(argc, argv, "01", &val);
while (i--) {
- if (rb_equal(RARRAY(ary)->ptr[i], val))
- return LONG2NUM(i);
if (i > RARRAY(ary)->len) {
i = RARRAY(ary)->len;
+ continue;
}
+ if (rb_equal(RARRAY(ary)->ptr[i], val))
+ return LONG2NUM(i);
}
return Qnil;
}
@@ -1094,9 +967,6 @@ rb_ary_splice(ary, beg, len, rpl)
rb_ary_modify(ary);
if (beg >= RARRAY(ary)->len) {
- if (beg > ARY_MAX_SIZE - rlen) {
- rb_raise(rb_eIndexError, "index %ld too big", beg);
- }
len = beg + rlen;
if (len >= RARRAY(ary)->aux.capa) {
REALLOC_N(RARRAY(ary)->ptr, VALUE, len);
@@ -1256,7 +1126,6 @@ rb_ary_each(ary)
{
long i;
- RETURN_ENUMERATOR(ary, 0, 0);
for (i=0; i<RARRAY(ary)->len; i++) {
rb_yield(RARRAY(ary)->ptr[i]);
}
@@ -1284,7 +1153,6 @@ rb_ary_each_index(ary)
{
long i;
- RETURN_ENUMERATOR(ary, 0, 0);
for (i=0; i<RARRAY(ary)->len; i++) {
rb_yield(LONG2NUM(i));
}
@@ -1310,10 +1178,8 @@ static VALUE
rb_ary_reverse_each(ary)
VALUE ary;
{
- long len;
+ long len = RARRAY(ary)->len;
- RETURN_ENUMERATOR(ary, 0, 0);
- len = RARRAY(ary)->len;
while (len--) {
rb_yield(RARRAY(ary)->ptr[len]);
if (RARRAY(ary)->len < len) {
@@ -1405,7 +1271,7 @@ rb_ary_join(ary, sep)
case T_STRING:
break;
case T_ARRAY:
- if (tmp == ary || rb_inspecting_p(tmp)) {
+ if (rb_inspecting_p(tmp)) {
tmp = rb_str_new2("[...]");
}
else {
@@ -1860,7 +1726,6 @@ rb_ary_collect_bang(ary)
{
long i;
- RETURN_ENUMERATOR(ary, 0, 0);
rb_ary_modify(ary);
for (i = 0; i < RARRAY(ary)->len; i++) {
rb_ary_store(ary, i, rb_yield(RARRAY(ary)->ptr[i]));
@@ -1945,7 +1810,6 @@ rb_ary_select(ary)
VALUE result;
long i;
- RETURN_ENUMERATOR(ary, 0, 0);
result = rb_ary_new2(RARRAY(ary)->len);
for (i = 0; i < RARRAY(ary)->len; i++) {
if (RTEST(rb_yield(RARRAY(ary)->ptr[i]))) {
@@ -2085,42 +1949,22 @@ rb_ary_slice_bang(argc, argv, ary)
VALUE ary;
{
VALUE arg1, arg2;
- long pos, len, orig_len;
+ long pos, len;
- rb_ary_modify_check(ary);
if (rb_scan_args(argc, argv, "11", &arg1, &arg2) == 2) {
pos = NUM2LONG(arg1);
len = NUM2LONG(arg2);
delete_pos_len:
- if (len < 0) return Qnil;
- orig_len = RARRAY_LEN(ary);
if (pos < 0) {
- pos += orig_len;
- if (pos < 0) return Qnil;
- }
- else if (orig_len < pos) return Qnil;
- if (orig_len < pos + len) {
- len = orig_len - pos;
+ pos = RARRAY(ary)->len + pos;
}
- if (len == 0) return rb_ary_new2(0);
- arg2 = rb_ary_new4(len, RARRAY_PTR(ary)+pos);
- RBASIC(arg2)->klass = rb_obj_class(ary);
- rb_ary_splice(ary, pos, len, Qnil); /* Qundef in 1.9 */
+ arg2 = rb_ary_subseq(ary, pos, len);
+ rb_ary_splice(ary, pos, len, Qnil); /* Qnil/rb_ary_new2(0) */
return arg2;
}
- if (!FIXNUM_P(arg1)) {
- switch (rb_range_beg_len(arg1, &pos, &len, RARRAY_LEN(ary), 0)) {
- case Qtrue:
- /* valid range */
- goto delete_pos_len;
- case Qnil:
- /* invalid range */
- return Qnil;
- default:
- /* not a range */
- break;
- }
+ if (!FIXNUM_P(arg1) && rb_range_beg_len(arg1, &pos, &len, RARRAY(ary)->len, 1)) {
+ goto delete_pos_len;
}
return rb_ary_delete_at(ary, NUM2LONG(arg1));
@@ -2142,7 +1986,6 @@ rb_ary_reject_bang(ary)
{
long i1, i2;
- RETURN_ENUMERATOR(ary, 0, 0);
rb_ary_modify(ary);
for (i1 = i2 = 0; i1 < RARRAY(ary)->len; i1++) {
VALUE v = RARRAY(ary)->ptr[i1];
@@ -2171,7 +2014,6 @@ static VALUE
rb_ary_reject(ary)
VALUE ary;
{
- RETURN_ENUMERATOR(ary, 0, 0);
ary = rb_ary_dup(ary);
rb_ary_reject_bang(ary);
return ary;
@@ -2192,7 +2034,6 @@ static VALUE
rb_ary_delete_if(ary)
VALUE ary;
{
- RETURN_ENUMERATOR(ary, 0, 0);
rb_ary_reject_bang(ary);
return ary;
}
@@ -2416,13 +2257,10 @@ rb_ary_fill(argc, argv, ary)
break;
}
rb_ary_modify(ary);
- if (len < 0) {
- return ary;
- }
- if (beg >= ARY_MAX_SIZE || len > ARY_MAX_SIZE - beg) {
+ end = beg + len;
+ if (end < 0) {
rb_raise(rb_eArgError, "argument too big");
}
- end = beg + len;
if (end > RARRAY(ary)->len) {
if (end >= RARRAY(ary)->aux.capa) {
REALLOC_N(RARRAY(ary)->ptr, VALUE, end);
@@ -2532,7 +2370,7 @@ rb_ary_times(ary, times)
if (len < 0) {
rb_raise(rb_eArgError, "negative argument");
}
- if (ARY_MAX_SIZE/len < RARRAY(ary)->len) {
+ if (LONG_MAX/len < RARRAY(ary)->len) {
rb_raise(rb_eArgError, "argument too big");
}
len *= RARRAY(ary)->len;
@@ -2576,8 +2414,9 @@ rb_ary_assoc(ary, key)
VALUE v;
for (i = 0; i < RARRAY(ary)->len; ++i) {
- v = rb_check_array_type(RARRAY(ary)->ptr[i]);
- if (!NIL_P(v) && RARRAY(v)->len > 0 &&
+ v = RARRAY(ary)->ptr[i];
+ if (TYPE(v) == T_ARRAY &&
+ RARRAY(v)->len > 0 &&
rb_equal(RARRAY(v)->ptr[0], key))
return v;
}
@@ -2615,22 +2454,6 @@ rb_ary_rassoc(ary, value)
return Qnil;
}
-static VALUE recursive_equal _((VALUE, VALUE, int));
-static VALUE
-recursive_equal(ary1, ary2, recur)
- VALUE ary1, ary2;
- int recur;
-{
- long i;
-
- if (recur) return Qfalse;
- for (i=0; i<RARRAY(ary1)->len; i++) {
- if (!rb_equal(rb_ary_elt(ary1, i), rb_ary_elt(ary2, i)))
- return Qfalse;
- }
- return Qtrue;
-}
-
/*
* call-seq:
* array == other_array -> bool
@@ -2649,6 +2472,8 @@ static VALUE
rb_ary_equal(ary1, ary2)
VALUE ary1, ary2;
{
+ long i;
+
if (ary1 == ary2) return Qtrue;
if (TYPE(ary2) != T_ARRAY) {
if (!rb_respond_to(ary2, rb_intern("to_ary"))) {
@@ -2657,20 +2482,8 @@ rb_ary_equal(ary1, ary2)
return rb_equal(ary2, ary1);
}
if (RARRAY(ary1)->len != RARRAY(ary2)->len) return Qfalse;
- return rb_exec_recursive(recursive_equal, ary1, ary2);
-}
-
-static VALUE recursive_eql _((VALUE, VALUE, int));
-static VALUE
-recursive_eql(ary1, ary2, recur)
- VALUE ary1, ary2;
- int recur;
-{
- long i;
-
- if (recur) return Qfalse;
for (i=0; i<RARRAY(ary1)->len; i++) {
- if (!rb_eql(rb_ary_elt(ary1, i), rb_ary_elt(ary2, i)))
+ if (!rb_equal(rb_ary_elt(ary1, i), rb_ary_elt(ary2, i)))
return Qfalse;
}
return Qtrue;
@@ -2688,33 +2501,16 @@ static VALUE
rb_ary_eql(ary1, ary2)
VALUE ary1, ary2;
{
+ long i;
+
if (ary1 == ary2) return Qtrue;
if (TYPE(ary2) != T_ARRAY) return Qfalse;
if (RARRAY(ary1)->len != RARRAY(ary2)->len) return Qfalse;
- return rb_exec_recursive(recursive_eql, ary1, ary2);
-}
-
-static VALUE recursive_hash _((VALUE, VALUE, int));
-static VALUE
-recursive_hash(ary, dummy, recur)
- VALUE ary;
- VALUE dummy;
- int recur;
-{
- long i, h;
- VALUE n;
-
- if (recur) {
- return LONG2FIX(0);
- }
-
- h = RARRAY(ary)->len;
- for (i=0; i<RARRAY(ary)->len; i++) {
- h = (h << 1) | (h<0 ? 1 : 0);
- n = rb_hash(RARRAY(ary)->ptr[i]);
- h ^= NUM2LONG(n);
+ for (i=0; i<RARRAY(ary1)->len; i++) {
+ if (!rb_eql(rb_ary_elt(ary1, i), rb_ary_elt(ary2, i)))
+ return Qfalse;
}
- return LONG2FIX(h);
+ return Qtrue;
}
/*
@@ -2729,7 +2525,16 @@ static VALUE
rb_ary_hash(ary)
VALUE ary;
{
- return rb_exec_recursive(recursive_hash, ary, 0);
+ long i, h;
+ VALUE n;
+
+ h = RARRAY(ary)->len;
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ h = (h << 1) | (h<0 ? 1 : 0);
+ n = rb_hash(RARRAY(ary)->ptr[i]);
+ h ^= NUM2LONG(n);
+ }
+ return LONG2FIX(h);
}
/*
@@ -2761,29 +2566,6 @@ rb_ary_includes(ary, item)
}
-static VALUE recursive_cmp _((VALUE, VALUE, int));
-static VALUE
-recursive_cmp(ary1, ary2, recur)
- VALUE ary1;
- VALUE ary2;
- int recur;
-{
- long i, len;
-
- if (recur) return Qnil;
- len = RARRAY(ary1)->len;
- if (len > RARRAY(ary2)->len) {
- len = RARRAY(ary2)->len;
- }
- for (i=0; i<len; i++) {
- VALUE v = rb_funcall(rb_ary_elt(ary1, i), id_cmp, 1, rb_ary_elt(ary2, i));
- if (v != INT2FIX(0)) {
- return v;
- }
- }
- return Qundef;
-}
-
/*
* call-seq:
* array <=> other_array -> -1, 0, +1
@@ -2808,13 +2590,19 @@ VALUE
rb_ary_cmp(ary1, ary2)
VALUE ary1, ary2;
{
- long len;
- VALUE v;
+ long i, len;
ary2 = to_ary(ary2);
- if (ary1 == ary2) return INT2FIX(0);
- v = rb_exec_recursive(recursive_cmp, ary1, ary2);
- if (v != Qundef) return v;
+ len = RARRAY(ary1)->len;
+ if (len > RARRAY(ary2)->len) {
+ len = RARRAY(ary2)->len;
+ }
+ for (i=0; i<len; i++) {
+ VALUE v = rb_funcall(rb_ary_elt(ary1, i), id_cmp, 1, rb_ary_elt(ary2, i));
+ if (v != INT2FIX(0)) {
+ return v;
+ }
+ }
len = RARRAY(ary1)->len - RARRAY(ary2)->len;
if (len == 0) return INT2FIX(0);
if (len > 0) return INT2FIX(1);
@@ -3054,7 +2842,6 @@ rb_ary_compact(ary)
* array.nitems -> int
*
* Returns the number of non-<code>nil</code> elements in _self_.
- *
* May be zero.
*
* [ 1, nil, 3, nil, 5 ].nitems #=> 3
@@ -3067,691 +2854,110 @@ rb_ary_nitems(ary)
long n = 0;
VALUE *p, *pend;
- for (p = RARRAY(ary)->ptr, pend = p + RARRAY(ary)->len; p < pend; p++) {
+ p = RARRAY(ary)->ptr;
+ pend = p + RARRAY(ary)->len;
+
+ while (p < pend) {
if (!NIL_P(*p)) n++;
+ p++;
}
return LONG2NUM(n);
}
-/*
- * call-seq:
- * array.count -> int
- * array.count(obj) -> int
- * array.count { |item| block } -> int
- *
- * Returns the number of elements. If an argument is given, counts
- * the number of elements which equals to <i>obj</i>. If a block is
- * given, counts the number of elements yielding a true value.
- *
- * ary = [1, 2, 4, 2]
- * ary.count # => 4
- * ary.count(2) # => 2
- * ary.count{|x|x%2==0} # => 3
- *
- */
-
-static VALUE
-rb_ary_count(argc, argv, ary)
- int argc;
- VALUE *argv;
+static long
+flatten(ary, idx, ary2, memo)
VALUE ary;
+ long idx;
+ VALUE ary2, memo;
{
- long n = 0;
-
- if (argc == 0) {
- VALUE *p, *pend;
-
- if (!rb_block_given_p())
- return LONG2NUM(RARRAY_LEN(ary));
-
- for (p = RARRAY_PTR(ary), pend = p + RARRAY_LEN(ary); p < pend; p++) {
- if (RTEST(rb_yield(*p))) n++;
- }
- }
- else {
- VALUE obj, *p, *pend;
+ VALUE id;
+ long i = idx;
+ long n, lim = idx + RARRAY(ary2)->len;
- rb_scan_args(argc, argv, "1", &obj);
- if (rb_block_given_p()) {
- rb_warn("given block not used");
- }
- for (p = RARRAY_PTR(ary), pend = p + RARRAY_LEN(ary); p < pend; p++) {
- if (rb_equal(*p, obj)) n++;
- }
+ id = rb_obj_id(ary2);
+ if (rb_ary_includes(memo, id)) {
+ rb_raise(rb_eArgError, "tried to flatten recursive array");
}
+ rb_ary_push(memo, id);
+ rb_ary_splice(ary, idx, 1, ary2);
+ while (i < lim) {
+ VALUE tmp;
- return LONG2NUM(n);
-}
-
-static VALUE
-flatten(ary, level, modified)
- VALUE ary;
- int level;
- int *modified;
-{
- long i = 0;
- VALUE stack, result, tmp, elt;
- st_table *memo;
- st_data_t id;
-
- stack = ary_new(0, ARY_DEFAULT_SIZE);
- result = ary_new(0, RARRAY_LEN(ary));
- memo = st_init_numtable();
- st_insert(memo, (st_data_t)ary, (st_data_t)Qtrue);
- *modified = 0;
-
- while (1) {
- while (i < RARRAY(ary)->len) {
- elt = RARRAY(ary)->ptr[i++];
- tmp = rb_check_array_type(elt);
- if (RBASIC(result)->klass) {
- rb_raise(rb_eRuntimeError, "flatten reentered");
- }
- if (NIL_P(tmp) || (level >= 0 && RARRAY(stack)->len / 2 >= level)) {
- rb_ary_push(result, elt);
- }
- else {
- *modified = 1;
- id = (st_data_t)tmp;
- if (st_lookup(memo, id, 0)) {
- st_free_table(memo);
- rb_raise(rb_eArgError, "tried to flatten recursive array");
- }
- st_insert(memo, id, (st_data_t)Qtrue);
- rb_ary_push(stack, ary);
- rb_ary_push(stack, LONG2NUM(i));
- ary = tmp;
- i = 0;
- }
- }
- if (RARRAY(stack)->len == 0) {
- break;
+ tmp = rb_check_array_type(rb_ary_elt(ary, i));
+ if (!NIL_P(tmp)) {
+ n = flatten(ary, i, tmp, memo);
+ i += n; lim += n;
}
- id = (st_data_t)ary;
- st_delete(memo, &id, 0);
- tmp = rb_ary_pop(stack);
- i = NUM2LONG(tmp);
- ary = rb_ary_pop(stack);
+ i++;
}
+ rb_ary_pop(memo);
- st_free_table(memo);
-
- RBASIC(result)->klass = rb_class_of(ary);
- return result;
+ return lim - idx - 1; /* returns number of increased items */
}
/*
* call-seq:
* array.flatten! -> array or nil
- * array.flatten!(level) -> array or nil
*
* Flattens _self_ in place.
* Returns <code>nil</code> if no modifications were made (i.e.,
- * <i>array</i> contains no subarrays.) If the optional <i>level</i>
- * argument determines the level of recursion to flatten.
+ * <i>array</i> contains no subarrays.)
*
* a = [ 1, 2, [3, [4, 5] ] ]
* a.flatten! #=> [1, 2, 3, 4, 5]
* a.flatten! #=> nil
* a #=> [1, 2, 3, 4, 5]
- * a = [ 1, 2, [3, [4, 5] ] ]
- * a.flatten!(1) #=> [1, 2, 3, [4, 5]]
*/
static VALUE
-rb_ary_flatten_bang(argc, argv, ary)
- int argc;
- VALUE *argv;
+rb_ary_flatten_bang(ary)
VALUE ary;
{
- int mod = 0, level = -1;
- VALUE result, lv;
+ long i = 0;
+ int mod = 0;
+ VALUE memo = Qnil;
- rb_scan_args(argc, argv, "01", &lv);
- if (!NIL_P(lv)) level = NUM2INT(lv);
- if (level == 0) return ary;
+ while (i<RARRAY(ary)->len) {
+ VALUE ary2 = RARRAY(ary)->ptr[i];
+ VALUE tmp;
- result = flatten(ary, level, &mod);
+ tmp = rb_check_array_type(ary2);
+ if (!NIL_P(tmp)) {
+ if (NIL_P(memo)) {
+ memo = rb_ary_new();
+ }
+ i += flatten(ary, i, tmp, memo);
+ mod = 1;
+ }
+ i++;
+ }
if (mod == 0) return Qnil;
- rb_ary_replace(ary, result);
-
return ary;
}
/*
* call-seq:
* array.flatten -> an_array
- * array.flatten(level) -> an_array
*
* Returns a new array that is a one-dimensional flattening of this
* array (recursively). That is, for every element that is an array,
- * extract its elements into the new array. If the optional
- * <i>level</i> argument determines the level of recursion to flatten.
+ * extract its elements into the new array.
*
* s = [ 1, 2, 3 ] #=> [1, 2, 3]
* t = [ 4, 5, 6, [7, 8] ] #=> [4, 5, 6, [7, 8]]
* a = [ s, t, 9, 10 ] #=> [[1, 2, 3], [4, 5, 6, [7, 8]], 9, 10]
- * a.flatten #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
- * a = [ 1, 2, [3, [4, 5] ] ]
- * a.flatten(1) #=> [1, 2, 3, [4, 5]]
+ * a.flatten #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10
*/
static VALUE
-rb_ary_flatten(argc, argv, ary)
- int argc;
- VALUE *argv;
+rb_ary_flatten(ary)
VALUE ary;
{
- int mod = 0, level = -1;
- VALUE result, lv;
-
- rb_scan_args(argc, argv, "01", &lv);
- if (!NIL_P(lv)) level = NUM2INT(lv);
- if (level == 0) return ary;
-
- result = flatten(ary, level, &mod);
- if (OBJ_TAINTED(ary)) OBJ_TAINT(result);
-
- return result;
-}
-
-/*
- * call-seq:
- * array.shuffle! -> array or nil
- *
- * Shuffles elements in _self_ in place.
- */
-
-
-static VALUE
-rb_ary_shuffle_bang(ary)
- VALUE ary;
-{
- long i = RARRAY(ary)->len;
-
- rb_ary_modify(ary);
- while (i) {
- long j = rb_genrand_real()*i;
- VALUE tmp = RARRAY(ary)->ptr[--i];
- RARRAY(ary)->ptr[i] = RARRAY(ary)->ptr[j];
- RARRAY(ary)->ptr[j] = tmp;
- }
- return ary;
-}
-
-
-/*
- * call-seq:
- * array.shuffle -> an_array
- *
- * Returns a new array with elements of this array shuffled.
- *
- * a = [ 1, 2, 3 ] #=> [1, 2, 3]
- * a.shuffle #=> [2, 3, 1]
- */
-
-static VALUE
-rb_ary_shuffle(VALUE ary)
-{
ary = rb_ary_dup(ary);
- rb_ary_shuffle_bang(ary);
- return ary;
-}
-
-
-/*
- * call-seq:
- * array.choice -> obj
- *
- * Choose a random element from an array.
- */
-
-
-static VALUE
-rb_ary_choice(ary)
- VALUE ary;
-{
- long i, j;
-
- i = RARRAY(ary)->len;
- if (i == 0) return Qnil;
- j = rb_genrand_real()*i;
- return RARRAY(ary)->ptr[j];
-}
-
-
-/*
- * call-seq:
- * ary.cycle {|obj| block }
- * ary.cycle(n) {|obj| block }
- *
- * Calls <i>block</i> for each element repeatedly _n_ times or
- * forever if none or nil is given. If a non-positive number is
- * given or the array is empty, does nothing. Returns nil if the
- * loop has finished without getting interrupted.
- *
- * a = ["a", "b", "c"]
- * a.cycle {|x| puts x } # print, a, b, c, a, b, c,.. forever.
- * a.cycle(2) {|x| puts x } # print, a, b, c, a, b, c.
- *
- */
-
-static VALUE
-rb_ary_cycle(argc, argv, ary)
- int argc;
- VALUE *argv;
- VALUE ary;
-{
- long n, i;
- VALUE nv = Qnil;
-
- rb_scan_args(argc, argv, "01", &nv);
-
- RETURN_ENUMERATOR(ary, argc, argv);
- if (NIL_P(nv)) {
- n = -1;
- }
- else {
- n = NUM2LONG(nv);
- if (n <= 0) return Qnil;
- }
-
- while (RARRAY(ary)->len > 0 && (n < 0 || 0 < n--)) {
- for (i=0; i<RARRAY(ary)->len; i++) {
- rb_yield(RARRAY(ary)->ptr[i]);
- }
- }
- return Qnil;
-}
-
-#define tmpbuf(n, size) rb_str_tmp_new((n)*(size))
-
-/*
- * Recursively compute permutations of r elements of the set [0..n-1].
- * When we have a complete permutation of array indexes, copy the values
- * at those indexes into a new array and yield that array.
- *
- * n: the size of the set
- * r: the number of elements in each permutation
- * p: the array (of size r) that we're filling in
- * index: what index we're filling in now
- * used: an array of booleans: whether a given index is already used
- * values: the Ruby array that holds the actual values to permute
- */
-static void
-permute0(n, r, p, index, used, values)
- long n, r, *p, index;
- int *used;
- VALUE values;
-{
- long i,j;
- for (i = 0; i < n; i++) {
- if (used[i] == 0) {
- p[index] = i;
- if (index < r-1) { /* if not done yet */
- used[i] = 1; /* mark index used */
- permute0(n, r, p, index+1, /* recurse */
- used, values);
- used[i] = 0; /* index unused */
- }
- else {
- /* We have a complete permutation of array indexes */
- /* Build a ruby array of the corresponding values */
- /* And yield it to the associated block */
- VALUE result = rb_ary_new2(r);
- VALUE *result_array = RARRAY(result)->ptr;
- const VALUE *values_array = RARRAY(values)->ptr;
-
- for (j = 0; j < r; j++) result_array[j] = values_array[p[j]];
- RARRAY(result)->len = r;
- rb_yield(result);
- }
- }
- }
-}
-
-/*
- * call-seq:
- * ary.permutation { |p| block } -> array
- * ary.permutation -> enumerator
- * ary.permutation(n) { |p| block } -> array
- * ary.permutation(n) -> enumerator
- *
- * When invoked with a block, yield all permutations of length <i>n</i>
- * of the elements of <i>ary</i>, then return the array itself.
- * If <i>n</i> is not specified, yield all permutations of all elements.
- * The implementation makes no guarantees about the order in which
- * the permutations are yielded.
- *
- * When invoked without a block, return an enumerator object instead.
- *
- * Examples:
- *
- * a = [1, 2, 3]
- * a.permutation.to_a #=> [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
- * a.permutation(1).to_a #=> [[1],[2],[3]]
- * a.permutation(2).to_a #=> [[1,2],[1,3],[2,1],[2,3],[3,1],[3,2]]
- * a.permutation(3).to_a #=> [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
- * a.permutation(0).to_a #=> [[]] # one permutation of length 0
- * a.permutation(4).to_a #=> [] # no permutations of length 4
- */
-
-static VALUE
-rb_ary_permutation(argc, argv, ary)
- int argc;
- VALUE *argv;
- VALUE ary;
-{
- VALUE num;
- long r, n, i;
-
- n = RARRAY(ary)->len; /* Array length */
- RETURN_ENUMERATOR(ary, argc, argv); /* Return enumerator if no block */
- rb_scan_args(argc, argv, "01", &num);
- r = NIL_P(num) ? n : NUM2LONG(num); /* Permutation size from argument */
-
- if (r < 0 || n < r) {
- /* no permutations: yield nothing */
- }
- else if (r == 0) { /* exactly one permutation: the zero-length array */
- rb_yield(rb_ary_new2(0));
- }
- else if (r == 1) { /* this is a special, easy case */
- for (i = 0; i < RARRAY(ary)->len; i++) {
- rb_yield(rb_ary_new3(1, RARRAY(ary)->ptr[i]));
- }
- }
- else { /* this is the general case */
- volatile VALUE t0 = tmpbuf(n,sizeof(long));
- long *p = (long*)RSTRING(t0)->ptr;
- volatile VALUE t1 = tmpbuf(n,sizeof(int));
- int *used = (int*)RSTRING(t1)->ptr;
- VALUE ary0 = ary_make_shared(ary); /* private defensive copy of ary */
-
- for (i = 0; i < n; i++) used[i] = 0; /* initialize array */
-
- permute0(n, r, p, 0, used, ary0); /* compute and yield permutations */
- RB_GC_GUARD(t0);
- RB_GC_GUARD(t1);
- }
+ rb_ary_flatten_bang(ary);
return ary;
}
-static long
-combi_len(n, k)
- long n, k;
-{
- long i, val = 1;
-
- if (k*2 > n) k = n-k;
- if (k == 0) return 1;
- if (k < 0) return 0;
- val = 1;
- for (i=1; i <= k; i++,n--) {
- long m = val;
- val *= n;
- if (val < m) {
- rb_raise(rb_eRangeError, "too big for combination");
- }
- val /= i;
- }
- return val;
-}
-
-/*
- * call-seq:
- * ary.combination(n) { |c| block } -> ary
- * ary.combination(n) -> enumerator
- *
- * When invoked with a block, yields all combinations of length <i>n</i>
- * of elements from <i>ary</i> and then returns <i>ary</i> itself.
- * The implementation makes no guarantees about the order in which
- * the combinations are yielded.
- *
- * When invoked without a block, returns an enumerator object instead.
- *
- * Examples:
- *
- * a = [1, 2, 3, 4]
- * a.combination(1).to_a #=> [[1],[2],[3],[4]]
- * a.combination(2).to_a #=> [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]
- * a.combination(3).to_a #=> [[1,2,3],[1,2,4],[1,3,4],[2,3,4]]
- * a.combination(4).to_a #=> [[1,2,3,4]]
- * a.combination(0).to_a #=> [[]] # one combination of length 0
- * a.combination(5).to_a #=> [] # no combinations of length 5
- *
- */
-
-static VALUE
-rb_ary_combination(ary, num)
- VALUE ary;
- VALUE num;
-{
- long n, i, len;
-
- n = NUM2LONG(num);
- RETURN_ENUMERATOR(ary, 1, &num);
- len = RARRAY(ary)->len;
- if (n < 0 || len < n) {
- /* yield nothing */
- }
- else if (n == 0) {
- rb_yield(rb_ary_new2(0));
- }
- else if (n == 1) {
- for (i = 0; i < len; i++) {
- rb_yield(rb_ary_new3(1, RARRAY(ary)->ptr[i]));
- }
- }
- else {
- volatile VALUE t0 = tmpbuf(n+1, sizeof(long));
- long *stack = (long*)RSTRING(t0)->ptr;
- long nlen = combi_len(len, n);
- volatile VALUE cc = rb_ary_new2(n);
- VALUE *chosen = RARRAY(cc)->ptr;
- long lev = 0;
-
- RBASIC(cc)->klass = 0;
- MEMZERO(stack, long, n);
- stack[0] = -1;
- for (i = 0; i < nlen; i++) {
- chosen[lev] = RARRAY(ary)->ptr[stack[lev+1]];
- for (lev++; lev < n; lev++) {
- chosen[lev] = RARRAY(ary)->ptr[stack[lev+1] = stack[lev]+1];
- }
- rb_yield(rb_ary_new4(n, chosen));
- do {
- stack[lev--]++;
- } while (lev && (stack[lev+1]+n == len+lev+1));
- }
- }
- return ary;
-}
-
-/*
- * call-seq:
- * ary.product(other_ary, ...)
- *
- * Returns an array of all combinations of elements from all arrays.
- * The length of the returned array is the product of the length
- * of ary and the argument arrays
- *
- * [1,2,3].product([4,5]) # => [[1,4],[1,5],[2,4],[2,5],[3,4],[3,5]]
- * [1,2].product([1,2]) # => [[1,1],[1,2],[2,1],[2,2]]
- * [1,2].product([3,4],[5,6]) # => [[1,3,5],[1,3,6],[1,4,5],[1,4,6],
- * # [2,3,5],[2,3,6],[2,4,5],[2,4,6]]
- * [1,2].product() # => [[1],[2]]
- * [1,2].product([]) # => []
- */
-
-static VALUE
-rb_ary_product(argc, argv, ary)
- int argc;
- VALUE *argv;
- VALUE ary;
-{
- int n = argc+1; /* How many arrays we're operating on */
- volatile VALUE t0 = tmpbuf(n, sizeof(VALUE));
- volatile VALUE t1 = tmpbuf(n, sizeof(int));
- VALUE *arrays = (VALUE*)RSTRING(t0)->ptr; /* The arrays we're computing the product of */
- int *counters = (int*)RSTRING(t1)->ptr; /* The current position in each one */
- VALUE result; /* The array we'll be returning */
- long i,j;
- long resultlen = 1;
-
- RBASIC(t0)->klass = 0;
- RBASIC(t1)->klass = 0;
-
- /* initialize the arrays of arrays */
- arrays[0] = ary;
- for (i = 1; i < n; i++) arrays[i] = to_ary(argv[i-1]);
-
- /* initialize the counters for the arrays */
- for (i = 0; i < n; i++) counters[i] = 0;
-
- /* Compute the length of the result array; return [] if any is empty */
- for (i = 0; i < n; i++) {
- long k = RARRAY(arrays[i])->len, l = resultlen;
- if (k == 0) return rb_ary_new2(0);
- resultlen *= k;
- if (resultlen < k || resultlen < l || resultlen / k != l) {
- rb_raise(rb_eRangeError, "too big to product");
- }
- }
-
- /* Otherwise, allocate and fill in an array of results */
- result = rb_ary_new2(resultlen);
- for (i = 0; i < resultlen; i++) {
- int m;
- /* fill in one subarray */
- VALUE subarray = rb_ary_new2(n);
- for (j = 0; j < n; j++) {
- rb_ary_push(subarray, rb_ary_entry(arrays[j], counters[j]));
- }
-
- /* put it on the result array */
- rb_ary_push(result, subarray);
-
- /*
- * Increment the last counter. If it overflows, reset to 0
- * and increment the one before it.
- */
- m = n-1;
- counters[m]++;
- while (m > 0 && counters[m] == RARRAY(arrays[m])->len) {
- counters[m] = 0;
- m--;
- counters[m]++;
- }
- }
-
- return result;
-}
-
-/*
- * call-seq:
- * ary.take(n) => array
- *
- * Returns first n elements from <i>ary</i>.
- *
- * a = [1, 2, 3, 4, 5, 0]
- * a.take(3) # => [1, 2, 3]
- *
- */
-
-static VALUE
-rb_ary_take(obj, n)
- VALUE obj;
- VALUE n;
-{
- long len = NUM2LONG(n);
- if (len < 0) {
- rb_raise(rb_eArgError, "attempt to take negative size");
- }
-
- return rb_ary_subseq(obj, 0, len);
-}
-
-/*
- * call-seq:
- * ary.take_while {|arr| block } => array
- *
- * Passes elements to the block until the block returns nil or false,
- * then stops iterating and returns an array of all prior elements.
- *
- * a = [1, 2, 3, 4, 5, 0]
- * a.take_while {|i| i < 3 } # => [1, 2]
- *
- */
-
-static VALUE
-rb_ary_take_while(ary)
- VALUE ary;
-{
- long i;
-
- RETURN_ENUMERATOR(ary, 0, 0);
- for (i = 0; i < RARRAY(ary)->len; i++) {
- if (!RTEST(rb_yield(RARRAY(ary)->ptr[i]))) break;
- }
- return rb_ary_take(ary, LONG2FIX(i));
-}
-
-/*
- * call-seq:
- * ary.drop(n) => array
- *
- * Drops first n elements from <i>ary</i>, and returns rest elements
- * in an array.
- *
- * a = [1, 2, 3, 4, 5, 0]
- * a.drop(3) # => [4, 5, 0]
- *
- */
-
-static VALUE
-rb_ary_drop(ary, n)
- VALUE ary;
- VALUE n;
-{
- VALUE result;
- long pos = NUM2LONG(n);
- if (pos < 0) {
- rb_raise(rb_eArgError, "attempt to drop negative size");
- }
-
- result = rb_ary_subseq(ary, pos, RARRAY(ary)->len);
- if (result == Qnil) result = rb_ary_new();
- return result;
-}
-
-/*
- * call-seq:
- * ary.drop_while {|arr| block } => array
- *
- * Drops elements up to, but not including, the first element for
- * which the block returns nil or false and returns an array
- * containing the remaining elements.
- *
- * a = [1, 2, 3, 4, 5, 0]
- * a.drop_while {|i| i < 3 } # => [3, 4, 5, 0]
- *
- */
-
-static VALUE
-rb_ary_drop_while(ary)
- VALUE ary;
-{
- long i;
-
- RETURN_ENUMERATOR(ary, 0, 0);
- for (i = 0; i < RARRAY(ary)->len; i++) {
- if (!RTEST(rb_yield(RARRAY(ary)->ptr[i]))) break;
- }
- return rb_ary_drop(ary, LONG2FIX(i));
-}
-
-
/* Arrays are ordered, integer-indexed collections of any object.
* Array indexing starts at 0, as in C or Java. A negative index is
@@ -3790,8 +2996,8 @@ Init_Array()
rb_define_method(rb_cArray, "concat", rb_ary_concat, 1);
rb_define_method(rb_cArray, "<<", rb_ary_push, 1);
rb_define_method(rb_cArray, "push", rb_ary_push_m, -1);
- rb_define_method(rb_cArray, "pop", rb_ary_pop_m, -1);
- rb_define_method(rb_cArray, "shift", rb_ary_shift_m, -1);
+ rb_define_method(rb_cArray, "pop", rb_ary_pop, 0);
+ rb_define_method(rb_cArray, "shift", rb_ary_shift, 0);
rb_define_method(rb_cArray, "unshift", rb_ary_unshift_m, -1);
rb_define_method(rb_cArray, "insert", rb_ary_insert, -1);
rb_define_method(rb_cArray, "each", rb_ary_each, 0);
@@ -3800,9 +3006,8 @@ Init_Array()
rb_define_method(rb_cArray, "length", rb_ary_length, 0);
rb_define_alias(rb_cArray, "size", "length");
rb_define_method(rb_cArray, "empty?", rb_ary_empty_p, 0);
- rb_define_method(rb_cArray, "find_index", rb_ary_index, -1);
- rb_define_method(rb_cArray, "index", rb_ary_index, -1);
- rb_define_method(rb_cArray, "rindex", rb_ary_rindex, -1);
+ rb_define_method(rb_cArray, "index", rb_ary_index, 1);
+ rb_define_method(rb_cArray, "rindex", rb_ary_rindex, 1);
rb_define_method(rb_cArray, "indexes", rb_ary_indexes, -1);
rb_define_method(rb_cArray, "indices", rb_ary_indexes, -1);
rb_define_method(rb_cArray, "join", rb_ary_join_m, -1);
@@ -3846,22 +3051,9 @@ Init_Array()
rb_define_method(rb_cArray, "uniq!", rb_ary_uniq_bang, 0);
rb_define_method(rb_cArray, "compact", rb_ary_compact, 0);
rb_define_method(rb_cArray, "compact!", rb_ary_compact_bang, 0);
- rb_define_method(rb_cArray, "flatten", rb_ary_flatten, -1);
- rb_define_method(rb_cArray, "flatten!", rb_ary_flatten_bang, -1);
+ rb_define_method(rb_cArray, "flatten", rb_ary_flatten, 0);
+ rb_define_method(rb_cArray, "flatten!", rb_ary_flatten_bang, 0);
rb_define_method(rb_cArray, "nitems", rb_ary_nitems, 0);
- rb_define_method(rb_cArray, "count", rb_ary_count, -1);
- rb_define_method(rb_cArray, "shuffle!", rb_ary_shuffle_bang, 0);
- rb_define_method(rb_cArray, "shuffle", rb_ary_shuffle, 0);
- rb_define_method(rb_cArray, "choice", rb_ary_choice, 0);
- rb_define_method(rb_cArray, "cycle", rb_ary_cycle, -1);
- rb_define_method(rb_cArray, "permutation", rb_ary_permutation, -1);
- rb_define_method(rb_cArray, "combination", rb_ary_combination, 1);
- rb_define_method(rb_cArray, "product", rb_ary_product, -1);
-
- rb_define_method(rb_cArray, "take", rb_ary_take, 1);
- rb_define_method(rb_cArray, "take_while", rb_ary_take_while, 0);
- rb_define_method(rb_cArray, "drop", rb_ary_drop, 1);
- rb_define_method(rb_cArray, "drop_while", rb_ary_drop_while, 0);
id_cmp = rb_intern("<=>");
inspect_key = rb_intern("__inspect_key__");
diff --git a/bcc32/Makefile.sub b/bcc32/Makefile.sub
index 713b5c69df..de7a2beeb8 100644
--- a/bcc32/Makefile.sub
+++ b/bcc32/Makefile.sub
@@ -4,12 +4,8 @@ SHELL = $(COMSPEC)
MKFILES = Makefile
#### Start of system configuration section. ####
-!ifndef OS
OS = bccwin32
-!endif
-!if !defined(RT)
-!error RT not defined. Retry from configure pass.
-!endif
+RT = $(OS)
## variables may be overridden by $(compile_dir)/Makefile
!ifndef srcdir
@@ -141,7 +137,7 @@ STACK = 0x2000000
XCFLAGS = -DRUBY_EXPORT -I. -I$(srcdir) -I$(srcdir)/missing
-ARFLAGS = /a /p32
+ARFLAGS = /a
LD = ilink32 -q -Gn
LDSHARED = $(LD)
XLDFLAGS = -Tpe c0x32.obj
@@ -157,8 +153,8 @@ EXEEXT = .exe
PROGRAM=$(RUBY_INSTALL_NAME)$(EXEEXT)
WPROGRAM=$(RUBYW_INSTALL_NAME)$(EXEEXT)
RUBYDEF = $(RUBY_SO_NAME).def
-MINIRUBY = .\miniruby$(EXEEXT) -I$(srcdir)/lib $(MINIRUBYOPT)
-RUNRUBY = .\$(PROGRAM) "$(srcdir)/runruby.rb" --extout="$(EXTOUT)" --
+MINIRUBY = .\miniruby$(EXEEXT)
+RUNRUBY = .\ruby$(EXEEXT) "$(srcdir)/runruby.rb" --extout="$(EXTOUT)" --
ORGLIBPATH = $(LIB)
@@ -173,8 +169,6 @@ PREP = miniruby$(EXEEXT)
OBJEXT = obj
-INSTALLED_LIST= .installed.list
-
WINMAINOBJ = winmain.$(OBJEXT)
MINIOBJS = dmydln.$(OBJEXT)
@@ -201,13 +195,7 @@ rubyw: $(WPROGRAM)
!include $(srcdir)/common.mk
-$(MKFILES): $(srcdir)/bcc32/Makefile.sub $(srcdir)/bcc32/configure.bat $(srcdir)/bcc32/setup.mak
- $(COMSPEC) /C $(srcdir:/=\)\bcc32\configure.bat $(configure_args)
- @echo $(MKFILES) should be updated, re-run $(MAKE).
- @$(MAKE) > nul -q -f &&|
-PHONY: nul
- @exit
-|
+PHONY: Makefile
CONFIG_H = ./.config.h.time
@@ -263,7 +251,6 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/bcc32/Makefile.sub
\#define HAVE_STRTOD 1
\#define HAVE_STRTOL 1
\#define HAVE_STRTOUL 1
-\#define HAVE_VSNPRINTF 1
\#define HAVE_ISNAN 1
\#define HAVE_FINITE 1
\#define HAVE_HYPOT 1
@@ -283,9 +270,6 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/bcc32/Makefile.sub
\#define RSHIFT(x,y) ((x)>>(int)y)
\#define FILE_COUNT level
\#define FILE_READPTR curp
-\#define RUBY_SETJMP(env) _setjmp(env)
-\#define RUBY_LONGJMP(env,val) longjmp(env,val)
-\#define RUBY_JMP_BUF jmp_buf
\#define inline __inline
\#define NEED_IO_SEEK_BETWEEN_RW 1
\#define STACK_GROW_DIRECTION -1
@@ -294,12 +278,9 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/bcc32/Makefile.sub
\#define RUBY_LIB "/lib/ruby/$(MAJOR).$(MINOR)"
\#define RUBY_SITE_LIB "/lib/ruby/site_ruby"
\#define RUBY_SITE_LIB2 "/lib/ruby/site_ruby/$(MAJOR).$(MINOR)"
-\#define RUBY_VENDOR_LIB "/lib/ruby/vendor_ruby"
-\#define RUBY_VENDOR_LIB2 "/lib/ruby/vendor_ruby/$(MAJOR).$(MINOR)"
\#define RUBY_PLATFORM "$(ARCH)-$(OS)"
\#define RUBY_ARCHLIB "/lib/ruby/$(MAJOR).$(MINOR)/$(ARCH)-$(OS)"
\#define RUBY_SITE_ARCHLIB "/lib/ruby/site_ruby/$(MAJOR).$(MINOR)/$(ARCH)-$(OS)"
-\#define RUBY_VENDOR_ARCHLIB "/lib/ruby/vendor_ruby/$(MAJOR).$(MINOR)/$(ARCH)-$(OS)"
|
@exit > $@
@@ -353,8 +334,11 @@ s,@RANLIB@,,;t t
s,@AR@,$(AR),;t t
s,@ARFLAGS@,$(ARFLAGS) ,;t t
s,@LN_S@,$(LN_S),;t t
-s,@SET_MAKE@,MFLAGS = -$$(MAKEFLAGS),;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
@@ -412,7 +396,6 @@ s,@EXPORT_PREFIX@,_,;t t
s,@arch@,$(ARCH)-$(OS),;t t
s,@sitearch@,$(ARCH)-$(OS),;t t
s,@sitedir@,$${prefix}/lib/ruby/site_ruby,;t t
-s,@vendordir@,$${prefix}/lib/ruby/vendor_ruby,;t t
s,@configure_args@,--enable-shared $(configure_args),;t t
s,@configure_input@,$$configure_input,;t t
s,@srcdir@,$(srcdir),;t t
@@ -438,7 +421,6 @@ $(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)
@@ -453,60 +435,19 @@ $(RUBY_INSTALL_NAME).rc $(RUBYW_INSTALL_NAME).rc $(RUBY_SO_NAME).rc: rbconfig.rb
-so_name=$(RUBY_SO_NAME) \
. $(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)
+post-install-ext::
+ $(MINIRUBY) -I$(srcdir)lib -rrbconfig -rfileutils \
+ -e "FileUtils.rm_f(Dir[ARGV[0]+Config::CONFIG['archdir']+'/**/*.tds'])" "$(DESTDIR:\=/)"
clean-local::
- @$(RM) $(WINMAINOBJ) ext\extinit.c ext\extinit.$(OBJEXT) *.tds *.il? $(RUBY_SO_NAME).lib
+ @$(RM) ext\extinit.c ext\extinit.$(OBJEXT) *.tds *.il? $(RUBY_SO_NAME).lib
@$(RM) $(RUBY_INSTALL_NAME).res $(RUBYW_INSTALL_NAME).res $(RUBY_SO_NAME).res
- @$(RM) *.map *.pdb *.ilk *.exp $(RUBYDEF)
distclean-local::
@$(RM) ext\config.cache $(RBCONFIG:/=\)
+ @$(RM) *.map *.pdb *.ilk *.exp $(RUBYDEF)
@$(RM) $(RUBY_INSTALL_NAME).rc $(RUBYW_INSTALL_NAME).rc $(RUBY_SO_NAME).rc
-update-rubyspec:
- @echo SPEC_EXISTS=0 > $@.mk
- @if exist $(srcdir:/=\)\rubyspec\nul echo SPEC_EXISTS=1 >> $@.mk
- @type >> $@.mk &&|
-$()update-rubyspec:
-$() @del $@.mk
-$()!if $$(SPEC_EXISTS)
-$() cd $(srcdir:/=\)\rubyspec\mspec
-$() git pull
-$() cd ..\spec\rubyspec
-$() git pull
-$()!else
-$() git clone $(MSPEC_GIT_URL) $(srcdir)/rubyspec/mspec
-$() git clone $(RUBYSPEC_GIT_URL) $(srcdir)/rubyspec/spec/rubyspec
-$()!endif
-|
- @$(MAKE) -$(MAKEFLAGS)$(MFLAGS) -f $@.mk
-
-test-rubyspec:
- @echo SPEC_EXISTS=0 > $@.mk
- @if exist $(srcdir:/=\)\rubyspec\nul echo SPEC_EXISTS=1 >> $@.mk
- @type >> $@.mk &&|
-$()test-rubyspec:
-$()!if $$(SPEC_EXISTS)
-$() $(RUNRUBY) $(srcdir)/rubyspec/mspec/bin/mspec -r$(srcdir)/ext/purelib.rb $(srcdir)/rubyspec/spec/rubyspec/$(MAJOR).$(MINOR)
-$()!else
-$() @echo No rubyspec here. put rubyspec to srcdir first.
-$() @cd $(srcdir:/=\)\rubyspec
-$()!endif
-|
- @$(MAKE) -$(MAKEFLAGS) -f $@.mk
-
ext/extinit.obj: ext/extinit.c $(SETUP)
$(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -o$@ -c ext/extinit.c
diff --git a/bcc32/configure.bat b/bcc32/configure.bat
index 95575cbc60..123a3f23c8 100755
--- a/bcc32/configure.bat
+++ b/bcc32/configure.bat
@@ -6,110 +6,70 @@
echo> ~tmp~.mak ####
echo>> ~tmp~.mak conf = %0
echo>> ~tmp~.mak $(conf:\=/): nul
-echo>> ~tmp~.mak @del ~setup~.mak
+echo>> ~tmp~.mak @del ~tmp~.mak
echo>> ~tmp~.mak @-$(MAKE) -l$(MAKEFLAGS) -f $(@D)setup.mak \
-if exist pathlist.tmp del pathlist.tmp
-if exist confargs.mk del confargs.mk
:loop
if "%1" == "" goto :end
if "%1" == "--prefix" goto :prefix
-if "%1" == "prefix" goto :prefix
if "%1" == "--srcdir" goto :srcdir
if "%1" == "srcdir" goto :srcdir
if "%1" == "--target" goto :target
if "%1" == "target" goto :target
if "%1" == "--with-static-linked-ext" goto :extstatic
if "%1" == "--program-suffix" goto :suffix
-if "%1" == "RUBY_SUFFIX" goto :suffix
-if "%1" == "--program-name" goto :installname
-if "%1" == "--install-name" goto :installname
-if "%1" == "RUBY_INSTALL_NAME" goto :installname
-if "%1" == "--so-name" goto :soname
-if "%1" == "RUBY_SO_NAME" goto :soname
+if "%1" == "--program-name" goto :progname
if "%1" == "--enable-install-doc" goto :enable-rdoc
if "%1" == "--disable-install-doc" goto :disable-rdoc
if "%1" == "--extout" goto :extout
-if "%1" == "EXTOUT" goto :extout
-if "%1" == "--path" goto :path
if "%1" == "-h" goto :help
if "%1" == "--help" goto :help
- echo>>confargs.tmp %1 \
+ echo>> ~tmp~.mak "%1" \
shift
goto :loop
:srcdir
- echo>> ~tmp~.mak -Dsrcdir=%2 \
- echo>>confargs.tmp --srcdir=%2 \
+ echo>> ~tmp~.mak -D"srcdir=%2" \
shift
shift
goto :loop
:prefix
- echo>> ~tmp~.mak -Dprefix=%2 \
- echo>>confargs.tmp %1=%2 \
+ echo>> ~tmp~.mak -D"prefix=%2" \
shift
shift
goto :loop
:suffix
- echo>>confargs.mk !ifndef RUBY_SUFFIX
- echo>>confargs.mk RUBY_SUFFIX = %2
- echo>>confargs.mk !endif
- echo>>confargs.tmp %1=%2 \
+ echo>> ~tmp~.mak -D"RUBY_SUFFIX=%2" \
shift
shift
goto :loop
:installname
- echo>>confargs.mk !ifndef RUBY_INSTALL_NAME
- echo>>confargs.mk RUBY_INSTALL_NAME = %2
- echo>>confargs.mk !endif
- echo>>confargs.tmp %1=%2 \
+ echo>> ~tmp~.mak -D"RUBY_INSTALL_NAME=%2" \
shift
shift
goto :loop
:soname
- echo>>confargs.mk !ifndef RUBY_SO_NAME
- echo>>confargs.mk RUBY_SO_NAME = %2
- echo>>confargs.mk !endif
- echo>>confargs.tmp %1=%2 \
+ echo>> ~tmp~.mak -D"RUBY_SO_NAME=%2" \
shift
shift
goto :loop
:target
- echo>> ~tmp~.mak %2 \
- echo>>confargs.tmp --target=%2 \
+ echo>> ~tmp~.mak "%2" \
shift
shift
goto :loop
:extstatic
- echo>>confargs.mk !ifndef EXTSTATIC
- echo>>confargs.mk EXTSTATIC = static
- echo>>confargs.mk !endif
- echo>>confargs.tmp %1 \
+ echo>> ~tmp~.mak -D"EXTSTATIC=static" \
shift
goto :loop
:enable-rdoc
- echo>>confargs.mk !ifndef RDOCTARGET
- echo>>confargs.mk RDOCTARGET = install-doc
- echo>>confargs.mk !endif
- echo>>confargs.tmp %1 \
+ echo>> ~tmp~.mak -D"RDOCTARGET=install-doc" \
shift
goto :loop
:disable-rdoc
- echo>>confargs.mk !ifndef RDOCTARGET
- echo>>confargs.mk RDOCTARGET = install-nodoc
- echo>>confargs.mk !endif
- echo>>confargs.tmp %1 \
+ echo>> ~tmp~.mak -D"RDOCTARGET=install-nodoc" \
shift
goto :loop
:extout
- echo>>confargs.mk !ifndef EXTOUT
- echo>>confargs.mk EXTOUT = %2
- echo>>confargs.mk !endif
- echo>>confargs.tmp %1=%2 \
- shift
- shift
-goto :loop
-:path
- echo>>pathlist.tmp %2;\
- echo>>confargs.tmp %1=%2 \
+ echo>> ~tmp~.mak "EXTOUT=%2" \
shift
shift
goto :loop
@@ -123,30 +83,10 @@ goto :loop
echo --target=TARGET configure for TARGET [i386-bccwin32]
echo Optional Package:
echo --with-static-linked-ext link external modules statically
- echo --disable-install-doc install rdoc indexes during install
- del *.tmp
+ echo --enable-install-doc install rdoc indexes during install
del ~tmp~.mak
goto :exit
:end
-echo>> ~tmp~.mak -Dbcc32dir=$(@D)
-if not exist confargs.tmp goto :noconfargs
- echo>>confargs.mk configure_args = \
- type>>confargs.mk confargs.tmp
- echo.>>confargs.mk
- echo>>confargs.mk ####
-:noconfargs
-if not exist pathlist.tmp goto :nopathlist
- echo>>confargs.mk pathlist = \
- type>>confargs.mk pathlist.tmp
- echo.>>confargs.mk
- echo>>confargs.mk ####
- echo>>confargs.mk PATH = $(pathlist:;=/bin;)$(PATH)
- echo>>confargs.mk INCLUDE = $(pathlist:;=/include;)
- echo>>confargs.mk LIB = $(pathlist:;=/lib;)
-:nopathlist
-if exist confargs.mk copy confargs.mk ~setup~.mak > nul
-type>>~setup~.mak ~tmp~.mak
-del *.tmp > nul
-del ~tmp~.mak > nul
-make -s -f ~setup~.mak
+echo>> ~tmp~.mak bcc32dir="$(@D)"
+make -s -f ~tmp~.mak
:exit
diff --git a/bcc32/mkexports.rb b/bcc32/mkexports.rb
index dc523e2541..e34b441e2f 100755..100644
--- a/bcc32/mkexports.rb
+++ b/bcc32/mkexports.rb
@@ -1,7 +1,5 @@
#!./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 483292ed51..b7a2539d0a 100644
--- a/bcc32/setup.mak
+++ b/bcc32/setup.mak
@@ -30,9 +30,7 @@ i586-$(OS): -prologue- -i586- -epilogue-
i686-$(OS): -prologue- -i686- -epilogue-
alpha-$(OS): -prologue- -alpha- -epilogue-
--prologue-: -basic-vars- -version- -system-vars-
-
--basic-vars-: nul
+-prologue-: nul
@echo Creating $(MAKEFILE)
@type > $(MAKEFILE) &&|
\#\#\# Makefile for ruby $(OS) \#\#\#
@@ -42,68 +40,36 @@ $(BANG)endif
$(BANG)ifndef prefix
prefix = $(prefix:\=/)
$(BANG)endif
-|
-!if exist(confargs.mk)
- @type confargs.mk >> $(MAKEFILE)
- @del confargs.mk
+$(BANG)ifndef EXTSTATIC
+EXTSTATIC = $(EXTSTATIC)
+$(BANG)endif
+!if defined(RDOCTARGET)
+$(BANG)ifndef RDOCTARGET
+RDOCTARGET = $(RDOCTARGET)
+$(BANG)endif
!endif
-
--system-vars-: -runtime- -bormm-
-
--bormm-: nul
- @-ilink32 -q -Gn -x usebormm.lib > nul
- @-if exist usebormm.tds $(APPEND) MEMLIB = usebormm.lib
- @if exist usebormm.* del usebormm.*
-
--osname-: nul
- @echo OS = >>$(MAKEFILE)
-
--runtime-: nul
- type > conftest.c &&|
-\#include <stdio.h>
-int main(){printf("");return 0;}
-|
- bcc32 conftest.c cw32i.lib > nul
- tdump conftest.exe < nul > conftest.i
- grep "^Imports from CC" conftest.i > conftest.c
- cpp32 -P- -DFile=\# -DImports=RTNAME -Dfrom== conftest.c > nul
- $(MAKE) > nul -DBANG=$(BANG) -f &&|
--runtime-: nul
-$(BANG)include conftest.i
-RT = $$(RTNAME:.DLL=)
-OS = $$(RT:CC32=)
--runtime-:
- del conftest.*
-$(BANG)if "$$(OS)" == "50"
- echo OS = bccwin32 >> $(MAKEFILE)
-$(BANG)else
- echo OS = bccwin32_$$(OS) >> $(MAKEFILE)
+!if defined(EXTOUT)
+$(BANG)ifndef EXTOUT
+EXTOUT = $(EXTOUT)
$(BANG)endif
+!endif
|
- @echo RT = $$(OS) >> $(MAKEFILE)
+ @type > usebormm.bat &&|
+@echo off
+ilink32 -Gn -x usebormm.lib > nul
+if exist usebormm.tds echo MEMLIB = usebormm.lib
+|
+ @usebormm.bat >> $(MAKEFILE)
+ @del usebormm.*
--version-: nul
@cpp32 -I$(srcdir) -P- -o$(MAKEFILE) > nul &&|
\#include "version.h"
MAJOR = RUBY_VERSION_MAJOR
MINOR = RUBY_VERSION_MINOR
TEENY = RUBY_VERSION_TEENY
-
-BORLANDC = __BORLANDC__
|
- @$(MAKE) > nul -DBANG=$(BANG) -f &&,
--version-: nul
-$(BANG)include $(MAKEFILE)
-$(BANG)include $(MAKEFILE).i
--version-:
+ @type $(MAKEFILE).i >> $(MAKEFILE)
@del $(MAKEFILE).i
- @type >> $(MAKEFILE) &&|
-MAJOR = $$(MAJOR)
-MINOR = $$(MINOR)
-TEENY = $$(TEENY)
-BORLANDC = $$(BORLANDC)
-|
-,
-generic-: nul
!if defined(PROCESSOR_ARCHITECTURE) || defined(PROCESSOR_LEVEL)
@@ -118,6 +84,7 @@ $(BANG)ifndef PROCESSOR_LEVEL
PROCESSOR_LEVEL = $(PROCESSOR_LEVEL)
$(BANG)endif
!endif
+
|
!endif
@@ -150,6 +117,8 @@ $(BANG)endif
-epilogue-: nul
@type >> $(MAKEFILE) &&|
+\# OS = $(OS)
+\# RT = $(RT)
\# 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
@@ -160,4 +129,5 @@ $(BANG)endif
\# EXTLIBS = cw32.lib import32.lib user32.lib kernel32.lib
$(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 7f14aee709..ee9c38aff9 100644
--- a/bignum.c
+++ b/bignum.c
@@ -2,8 +2,8 @@
bignum.c -
- $Author$
- $Date$
+ $Author: shyouhei $
+ $Date: 2006/12/06 10:14:12 $
created at: Fri Jun 10 00:48:55 JST 1994
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -11,10 +11,8 @@
**********************************************************************/
#include "ruby.h"
-#include "rubysig.h"
#include <math.h>
-#include <float.h>
#include <ctype.h>
#ifdef HAVE_IEEEFP_H
#include <ieeefp.h>
@@ -113,52 +111,35 @@ rb_big_2comp(x) /* get 2's complement */
}
static VALUE
-bigtrunc(x)
+bignorm(x)
VALUE x;
{
- long len = RBIGNUM(x)->len;
- BDIGIT *ds = BDIGITS(x);
+ if (FIXNUM_P(x)) {
+ return x;
+ }
+ else if (TYPE(x) == T_BIGNUM) {
+ long len = RBIGNUM(x)->len;
+ BDIGIT *ds = BDIGITS(x);
- if (len == 0) return x;
- while (--len && !ds[len]);
- RBIGNUM(x)->len = ++len;
- return x;
-}
+ while (--len && !ds[len]) ;
+ RBIGNUM(x)->len = ++len;
-static VALUE
-bigfixize(x)
- 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 (len*SIZEOF_BDIGITS <= sizeof(VALUE)) {
+ long num = 0;
+ while (len--) {
+ num = BIGUP(num) + ds[len];
}
- else {
- if (NEGFIXABLE(-(long)num)) return LONG2FIX(-(long)num);
+ if (num >= 0) {
+ if (RBIGNUM(x)->sign) {
+ if (POSFIXABLE(num)) return LONG2FIX(num);
+ }
+ else if (NEGFIXABLE(-(long)num)) return LONG2FIX(-(long)num);
}
}
}
return x;
}
-static VALUE
-bignorm(x)
- VALUE x;
-{
- if (!FIXNUM_P(x) && TYPE(x) == T_BIGNUM) {
- x = bigfixize(bigtrunc(x));
- }
- return x;
-}
-
VALUE
rb_big_norm(x)
VALUE x;
@@ -463,14 +444,7 @@ rb_cstr_to_inum(str, base, badcheck)
break;
}
if (*str == '0') { /* squeeze preceeding 0s */
- int us = 0;
- while ((c = *++str) == '0' || c == '_') {
- if (c == '_') {
- if (++us >= 2)
- break;
- } else
- us = 0;
- }
+ while (*++str == '0');
if (!(c = *str) || ISSPACE(c)) --str;
}
c = *str;
@@ -513,11 +487,10 @@ rb_cstr_to_inum(str, base, badcheck)
for (i=len;i--;) zds[i]=0;
while ((c = *str++) != 0) {
if (c == '_') {
- if (nondigit) {
- if (badcheck) goto bad;
- break;
+ if (badcheck) {
+ if (nondigit) goto bad;
+ nondigit = c;
}
- nondigit = c;
continue;
}
else if ((c = conv_digit(c)) < 0) {
@@ -579,7 +552,7 @@ rb_str_to_inum(str, base, badcheck)
s = p;
}
}
- return rb_cstr_to_inum(s, base, badcheck);
+ return rb_cstr_to_inum(s, base, badcheck);
}
#if HAVE_LONG_LONG
@@ -641,7 +614,7 @@ rb_ll2inum(n)
}
#endif /* HAVE_LONG_LONG */
-
+
VALUE
rb_cstr2inum(str, base)
const char *str;
@@ -660,16 +633,15 @@ rb_str2inum(str, base)
const char ruby_digitmap[] = "0123456789abcdefghijklmnopqrstuvwxyz";
VALUE
-rb_big2str0(x, base, trim)
+rb_big2str(x, base)
VALUE x;
int base;
- int trim;
{
volatile VALUE t;
BDIGIT *ds;
long i, j, hbase;
VALUE ss;
- char *s;
+ char *s, c;
if (FIXNUM_P(x)) {
return rb_fix2str(x, base);
@@ -685,30 +657,30 @@ rb_big2str0(x, base, trim)
switch (base) {
case 2: break;
case 3:
- j = j * 53L / 84 + 1;
+ j = j * 647L / 1024;
break;
case 4: case 5: case 6: case 7:
- j = (j + 1) / 2;
+ j /= 2;
break;
case 8: case 9:
- j = (j + 2) / 3;
+ j /= 3;
break;
case 10: case 11: case 12: case 13: case 14: case 15:
- j = j * 28L / 93 + 1;
+ j = j * 241L / 800;
break;
case 16: case 17: case 18: case 19: case 20: case 21:
case 22: case 23: case 24: case 25: case 26: case 27:
case 28: case 29: case 30: case 31:
- j = (j + 3) / 4;
+ j /= 4;
break;
case 32: case 33: case 34: case 35: case 36:
- j = (j + 4) / 5;
+ j /= 5;
break;
default:
rb_raise(rb_eArgError, "illegal radix %d", base);
break;
}
- j++; /* space for sign */
+ j += 2;
hbase = base * base;
#if SIZEOF_BDIGITS > 2
@@ -717,12 +689,11 @@ rb_big2str0(x, base, trim)
t = rb_big_clone(x);
ds = BDIGITS(t);
- ss = rb_str_new(0, j+1);
+ ss = rb_str_new(0, j);
s = RSTRING(ss)->ptr;
s[0] = RBIGNUM(x)->sign ? '+' : '-';
- TRAP_BEG;
- while (i && j > 1) {
+ while (i && j) {
long k = i;
BDIGIT_DBL num = 0;
@@ -731,44 +702,30 @@ rb_big2str0(x, base, trim)
ds[k] = (BDIGIT)(num / hbase);
num %= hbase;
}
- if (trim && ds[i-1] == 0) i--;
+ if (ds[i-1] == 0) i--;
k = SIZEOF_BDIGITS;
while (k--) {
- s[--j] = ruby_digitmap[num % base];
+ c = (char)(num % base);
+ s[--j] = ruby_digitmap[(int)c];
num /= base;
- if (!trim && j <= 1) break;
- if (trim && i == 0 && num == 0) break;
+ if (i == 0 && num == 0) break;
}
}
- 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;
- }
+ 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);
s[RSTRING(ss)->len] = '\0';
- TRAP_END;
return ss;
}
-VALUE
-rb_big2str(VALUE x, int base)
-{
- return rb_big2str0(x, base, Qtrue);
-}
-
/*
* call-seq:
* big.to_s(base=10) => string
- *
+ *
* Returns a string containing the representation of <i>big</i> radix
* <i>base</i> (2 through 36).
- *
+ *
* 12345654321.to_s #=> "12345654321"
* 12345654321.to_s(2) #=> "1011011111110110111011110000110001"
* 12345654321.to_s(8) #=> "133766736061"
@@ -812,15 +769,15 @@ big2ulong(x, type)
}
unsigned long
-rb_big2ulong_pack(x)
- VALUE x;
-{
+rb_big2ulong_pack(x)
+ VALUE x;
+{
unsigned long num = big2ulong(x, "unsigned long");
if (!RBIGNUM(x)->sign) {
return -num;
}
return num;
-}
+}
unsigned long
rb_big2ulong(x)
@@ -938,8 +895,8 @@ rb_dbl2big(d)
return bignorm(dbl2big(d));
}
-static double
-big2dbl(x)
+double
+rb_big2dbl(x)
VALUE x;
{
double d = 0.0;
@@ -949,30 +906,21 @@ big2dbl(x)
while (i--) {
d = ds[i] + BIGRAD*d;
}
- if (!RBIGNUM(x)->sign) d = -d;
- return d;
-}
-
-double
-rb_big2dbl(x)
- VALUE x;
-{
- double d = big2dbl(x);
-
if (isinf(d)) {
rb_warn("Bignum out of Float range");
d = HUGE_VAL;
}
+ if (!RBIGNUM(x)->sign) d = -d;
return d;
}
/*
* call-seq:
* big.to_f -> float
- *
+ *
* Converts <i>big</i> to a <code>Float</code>. If <i>big</i> doesn't
* fit in a <code>Float</code>, the result is infinity.
- *
+ *
*/
static VALUE
@@ -985,11 +933,11 @@ rb_big_to_f(x)
/*
* call-seq:
* big <=> numeric => -1, 0, +1
- *
+ *
* Comparison---Returns -1, 0, or +1 depending on whether <i>big</i> is
* less than, equal to, or greater than <i>numeric</i>. This is the
* basis for the tests in <code>Comparable</code>.
- *
+ *
*/
static VALUE
@@ -1030,11 +978,11 @@ rb_big_cmp(x, y)
/*
* call-seq:
* big == obj => true or false
- *
+ *
* Returns <code>true</code> only if <i>obj</i> has the same value
* as <i>big</i>. Contrast this with <code>Bignum#eql?</code>, which
* requires <i>obj</i> to be a <code>Bignum</code>.
- *
+ *
* 68719476736 == 68719476736.0 #=> true
*/
@@ -1069,11 +1017,11 @@ rb_big_eq(x, y)
/*
* call-seq:
* big.eql?(obj) => true or false
- *
+ *
* Returns <code>true</code> only if <i>obj</i> is a
* <code>Bignum</code> with the same value as <i>big</i>. Contrast this
* with <code>Bignum#==</code>, which performs type conversions.
- *
+ *
* 68719476736.eql?(68719476736.0) #=> false
*/
@@ -1114,7 +1062,7 @@ rb_big_uminus(x)
* length, the result acts as if it had an infinite number of one
* bits to the left. In hex representations, this is displayed
* as two periods to the left of the digits.
- *
+ *
* sprintf("%X", ~0x1122334455) #=> "..FEEDDCCBBAA"
*/
@@ -1145,7 +1093,7 @@ bigsub(x, y)
BDIGIT *zds;
BDIGIT_DBL_SIGNED num;
long i = RBIGNUM(x)->len;
-
+
/* if x is larger than y, swap */
if (RBIGNUM(x)->len < RBIGNUM(y)->len) {
z = x; x = y; y = z; /* swap x y */
@@ -1166,11 +1114,11 @@ bigsub(x, y)
z = bignew(RBIGNUM(x)->len, z==0);
zds = BDIGITS(z);
- for (i = 0, num = 0; i < RBIGNUM(y)->len; i++) {
+ for (i = 0, num = 0; i < RBIGNUM(y)->len; i++) {
num += (BDIGIT_DBL_SIGNED)BDIGITS(x)[i] - BDIGITS(y)[i];
zds[i] = BIGLO(num);
num = BIGDN(num);
- }
+ }
while (num && i < RBIGNUM(x)->len) {
num += BDIGITS(x)[i];
zds[i++] = BIGLO(num);
@@ -1180,7 +1128,7 @@ bigsub(x, y)
zds[i] = BDIGITS(x)[i];
i++;
}
-
+
return z;
}
@@ -1281,8 +1229,15 @@ rb_big_minus(x, y)
}
}
+/*
+ * call-seq:
+ * big * other => Numeric
+ *
+ * Multiplies big and other, returning the result.
+ */
+
VALUE
-rb_big_mul0(x, y)
+rb_big_mul(x, y)
VALUE x, y;
{
long i, j;
@@ -1311,7 +1266,7 @@ rb_big_mul0(x, y)
zds = BDIGITS(z);
while (j--) zds[j] = 0;
for (i = 0; i < RBIGNUM(x)->len; i++) {
- BDIGIT_DBL dd = BDIGITS(x)[i];
+ BDIGIT_DBL dd = BDIGITS(x)[i];
if (dd == 0) continue;
n = 0;
for (j = 0; j < RBIGNUM(y)->len; j++) {
@@ -1325,21 +1280,7 @@ rb_big_mul0(x, y)
}
}
- 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));
+ return bignorm(z);
}
static void
@@ -1388,7 +1329,7 @@ bigdivrem(x, y, divp, modp)
dd = 0;
q = yds[ny-1];
- while ((q & (1U<<(BITSPERDIG-1))) == 0) {
+ while ((q & (1<<(BITSPERDIG-1))) == 0) {
q <<= 1;
dd++;
}
@@ -1512,6 +1453,9 @@ rb_big_div(x, y)
case T_BIGNUM:
break;
+ case T_FLOAT:
+ return rb_float_new(rb_big2dbl(x) / RFLOAT(y)->value);
+
default:
return rb_num_coerce_bin(x, y);
}
@@ -1554,9 +1498,9 @@ rb_big_modulo(x, y)
/*
* call-seq:
* big.remainder(numeric) => number
- *
+ *
* Returns the remainder after dividing <i>big</i> by <i>numeric</i>.
- *
+ *
* -1234567890987654321.remainder(13731) #=> -6966
* -1234567890987654321.remainder(13731.24) #=> -9906.22531493148
*/
@@ -1582,27 +1526,6 @@ rb_big_remainder(x, y)
return bignorm(z);
}
-static int
-bdigbitsize(BDIGIT x)
-{
- int size = 1;
- int nb = BITSPERDIG / 2;
- BDIGIT bits = (~0 << nb);
-
- if (!x) return 0;
- while (x > 1) {
- if (x & bits) {
- size += nb;
- x >>= nb;
- }
- x &= ~bits;
- nb /= 2;
- bits >>= nb;
- }
-
- return size;
-}
-
static VALUE big_lshift _((VALUE, unsigned long));
static VALUE big_rshift _((VALUE, unsigned long));
@@ -1620,9 +1543,9 @@ static VALUE big_shift(x, n)
/*
* call-seq:
* big.divmod(numeric) => array
- *
+ *
* See <code>Numeric#divmod</code>.
- *
+ *
*/
VALUE
rb_big_divmod(x, y)
@@ -1649,51 +1572,22 @@ rb_big_divmod(x, y)
/*
* call-seq:
* big.quo(numeric) -> float
- * big.fdiv(numeric) -> float
- *
+ *
* Returns the floating point result of dividing <i>big</i> by
* <i>numeric</i>.
- *
+ *
* -1234567890987654321.quo(13731) #=> -89910996357705.5
* -1234567890987654321.quo(13731.24) #=> -89909424858035.7
- *
+ *
*/
static VALUE
rb_big_quo(x, y)
VALUE x, y;
{
- double dx = big2dbl(x);
+ double dx = rb_big2dbl(x);
double dy;
- if (isinf(dx)) {
-#define DBL_BIGDIG ((DBL_MANT_DIG + BITSPERDIG) / BITSPERDIG)
- VALUE z;
- int ex, ey;
-
- ex = (RBIGNUM(bigtrunc(x))->len - 1) * BITSPERDIG;
- ex += bdigbitsize(BDIGITS(x)[RBIGNUM(x)->len - 1]);
- ex -= 2 * DBL_BIGDIG * BITSPERDIG;
- if (ex) x = big_shift(x, ex);
-
- switch (TYPE(y)) {
- case T_FIXNUM:
- y = rb_int2big(FIX2LONG(y));
- case T_BIGNUM: {
- ey = (RBIGNUM(bigtrunc(y))->len - 1) * BITSPERDIG;
- ey += bdigbitsize(BDIGITS(y)[RBIGNUM(y)->len - 1]);
- ey -= DBL_BIGDIG * BITSPERDIG;
- if (ey) y = big_shift(y, ey);
- bignum:
- bigdivrem(x, y, &z, 0);
- return rb_float_new(ldexp(big2dbl(z), ex - ey));
- }
- case T_FLOAT:
- y = dbl2big(ldexp(frexp(RFLOAT(y)->value, &ey), DBL_MANT_DIG));
- ey -= DBL_MANT_DIG;
- goto bignum;
- }
- }
switch (TYPE(y)) {
case T_FIXNUM:
dy = (double)FIX2LONG(y);
@@ -1713,52 +1607,6 @@ rb_big_quo(x, y)
return rb_float_new(dx / dy);
}
-static VALUE
-bigsqr(x)
- VALUE x;
-{
- long len = RBIGNUM(x)->len, k = len / 2, i;
- VALUE a, b, a2, z;
- BDIGIT_DBL num;
-
- if (len < 4000 / BITSPERDIG) {
- return rb_big_mul0(x, x);
- }
-
- a = bignew(len - k, 1);
- MEMCPY(BDIGITS(a), BDIGITS(x) + k, BDIGIT, len - k);
- b = bignew(k, 1);
- MEMCPY(BDIGITS(b), BDIGITS(x), BDIGIT, k);
-
- a2 = bigtrunc(bigsqr(a));
- z = bigsqr(b);
- REALLOC_N(RBIGNUM(z)->digits, BDIGIT, (len = 2 * k + RBIGNUM(a2)->len) + 1);
- while (RBIGNUM(z)->len < 2 * k) BDIGITS(z)[RBIGNUM(z)->len++] = 0;
- MEMCPY(BDIGITS(z) + 2 * k, BDIGITS(a2), BDIGIT, RBIGNUM(a2)->len);
- RBIGNUM(z)->len = len;
- a2 = bigtrunc(rb_big_mul0(a, b));
- len = RBIGNUM(a2)->len;
- TRAP_BEG;
- for (i = 0, num = 0; i < len; i++) {
- num += (BDIGIT_DBL)BDIGITS(z)[i + k] + ((BDIGIT_DBL)BDIGITS(a2)[i] << 1);
- BDIGITS(z)[i + k] = BIGLO(num);
- num = BIGDN(num);
- }
- TRAP_END;
- if (num) {
- len = RBIGNUM(z)->len;
- for (i += k; i < len && num; ++i) {
- num += (BDIGIT_DBL)BDIGITS(z)[i];
- BDIGITS(z)[i] = BIGLO(num);
- num = BIGDN(num);
- }
- if (num) {
- BDIGITS(z)[RBIGNUM(z)->len++] = BIGLO(num);
- }
- }
- return bigtrunc(z);
-}
-
/*
* call-seq:
* big ** exponent #=> numeric
@@ -1778,7 +1626,7 @@ rb_big_pow(x, y)
{
double d;
long yy;
-
+
if (y == INT2FIX(0)) return INT2FIX(1);
switch (TYPE(y)) {
case T_FLOAT:
@@ -1793,8 +1641,7 @@ rb_big_pow(x, y)
case T_FIXNUM:
yy = FIX2LONG(y);
if (yy > 0) {
- VALUE z = 0;
- long mask;
+ VALUE z = x;
const long BIGLEN_LIMIT = 1024*1024 / SIZEOF_BDIGITS;
if ((RBIGNUM(x)->len > BIGLEN_LIMIT) ||
@@ -1803,11 +1650,14 @@ rb_big_pow(x, y)
d = (double)yy;
break;
}
- for (mask = FIXNUM_MAX + 1; mask; mask >>= 1) {
- if (z) z = bigtrunc(bigsqr(z));
- if (yy & mask) {
- z = z ? bigtrunc(rb_big_mul0(z, x)) : x;
+ for (;;) {
+ yy -= 1;
+ if (yy == 0) break;
+ while (yy % 2 == 0) {
+ yy /= 2;
+ x = rb_big_mul(x, x);
}
+ z = rb_big_mul(z, x);
}
return bignorm(z);
}
@@ -2032,7 +1882,7 @@ rb_big_lshift(x, y)
if (!NIL_P(t)) return t;
neg = 1;
}
- shift = big2ulong(y, "long");
+ shift = big2ulong(y, "long", Qtrue);
break;
}
y = rb_to_int(y);
@@ -2101,7 +1951,7 @@ rb_big_rshift(x, y)
else {
neg = 1;
}
- shift = big2ulong(y, "long");
+ shift = big2ulong(y, "long", Qtrue);
break;
}
y = rb_to_int(y);
@@ -2136,10 +1986,6 @@ 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;
@@ -2159,20 +2005,20 @@ big_rshift(x, shift)
/*
* call-seq:
* big[n] -> 0, 1
- *
+ *
* Bit Reference---Returns the <em>n</em>th bit in the (assumed) binary
* representation of <i>big</i>, where <i>big</i>[0] is the least
* significant bit.
- *
+ *
* a = 9**15
* 50.downto(0) do |n|
* print a[n]
* end
- *
+ *
* <em>produces:</em>
- *
+ *
* 000101110110100000111000011110010100111100010111001
- *
+ *
*/
static VALUE
@@ -2180,39 +2026,29 @@ rb_big_aref(x, y)
VALUE x, y;
{
BDIGIT *xds;
- BDIGIT_DBL num;
- unsigned long shift;
- long i, s1, s2;
+ int shift;
+ long s1, s2;
if (TYPE(y) == T_BIGNUM) {
- if (!RBIGNUM(y)->sign)
+ if (!RBIGNUM(y)->sign || RBIGNUM(x)->sign)
return INT2FIX(0);
- if (RBIGNUM(bigtrunc(y))->len > SIZEOF_LONG/SIZEOF_BDIGITS) {
- out_of_range:
- return RBIGNUM(x)->sign ? INT2FIX(0) : INT2FIX(1);
- }
- shift = big2ulong(y, "long");
- }
- else {
- i = NUM2LONG(y);
- if (i < 0) return INT2FIX(0);
- shift = (VALUE)i;
+ return INT2FIX(1);
}
+ shift = NUM2INT(y);
+ if (shift < 0) return INT2FIX(0);
s1 = shift/BITSPERDIG;
s2 = shift%BITSPERDIG;
- if (s1 >= RBIGNUM(x)->len) goto out_of_range;
if (!RBIGNUM(x)->sign) {
- xds = BDIGITS(x);
- i = 0; num = 1;
- while (num += ~xds[i], ++i <= s1) {
- num = BIGDN(num);
- }
+ if (s1 >= RBIGNUM(x)->len) return INT2FIX(1);
+ x = rb_big_clone(x);
+ get2comp(x);
}
else {
- num = BDIGITS(x)[s1];
+ if (s1 >= RBIGNUM(x)->len) return INT2FIX(0);
}
- if (num & ((BDIGIT_DBL)1<<s2))
+ xds = BDIGITS(x);
+ if (xds[s1] & (1<<s2))
return INT2FIX(1);
return INT2FIX(0);
}
@@ -2263,9 +2099,9 @@ rb_big_coerce(x, y)
/*
* call-seq:
* big.abs -> aBignum
- *
+ *
* Returns the absolute value of <i>big</i>.
- *
+ *
* -1234567890987654321.abs #=> 1234567890987654321
*/
@@ -2293,7 +2129,7 @@ rb_big_rand(max, rand_buf)
}
v = bignew(len,1);
len--;
- BDIGITS(v)[len] = BDIGITS(max)[len] * rand_buf[len];
+ BDIGITS(v)[len] = BDIGITS(max)[len] * rand_buf[len];
while (len--) {
BDIGITS(v)[len] = ((BDIGIT)~0) * rand_buf[len];
}
@@ -2304,10 +2140,10 @@ rb_big_rand(max, rand_buf)
/*
* call-seq:
* big.size -> integer
- *
+ *
* Returns the number of bytes in the machine representation of
* <i>big</i>.
- *
+ *
* (256**10 - 1).size #=> 12
* (256**20 - 1).size #=> 20
* (256**40 - 1).size #=> 40
@@ -2327,15 +2163,15 @@ rb_big_size(big)
* Fixnum. When a calculation involving
* Bignum objects returns a result that will fit in a
* Fixnum, the result is automatically converted.
- *
+ *
* For the purposes of the bitwise operations and <code>[]</code>, a
* Bignum is treated as if it were an infinite-length
* bitstring with 2's complement representation.
- *
+ *
* While Fixnum values are immediate, Bignum
* objects are not---assignment and parameter passing work with
* references to objects, not the objects themselves.
- *
+ *
*/
void
@@ -2356,7 +2192,6 @@ Init_Bignum()
rb_define_method(rb_cBignum, "modulo", rb_big_modulo, 1);
rb_define_method(rb_cBignum, "remainder", rb_big_remainder, 1);
rb_define_method(rb_cBignum, "quo", rb_big_quo, 1);
- rb_define_method(rb_cBignum, "fdiv", rb_big_quo, 1);
rb_define_method(rb_cBignum, "**", rb_big_pow, 1);
rb_define_method(rb_cBignum, "&", rb_big_and, 1);
rb_define_method(rb_cBignum, "|", rb_big_or, 1);
diff --git a/bin/irb b/bin/irb
index f277bc4b69..13474a932b 100644
--- a/bin/irb
+++ b/bin/irb
@@ -2,8 +2,8 @@
#
# irb.rb - intaractive ruby
# $Release Version: 0.9.5 $
-# $Revision$
-# $Date$
+# $Revision: 1.2.2.1 $
+# $Date: 2005/04/19 19:24:56 $
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
diff --git a/bin/rdoc b/bin/rdoc
index fe619137fd..d08ce838f6 100644
--- a/bin/rdoc
+++ b/bin/rdoc
@@ -6,7 +6,7 @@
# Copyright (c) 2003 Dave Thomas
# Released under the same terms as Ruby
#
-# $Revision$
+# $Revision: 1.1 $
## Transitional Hack ####
#
diff --git a/class.c b/class.c
index 80f57a1622..ca2516d5a1 100644
--- a/class.c
+++ b/class.c
@@ -2,8 +2,8 @@
class.c -
- $Author$
- $Date$
+ $Author: nobu $
+ $Date: 2005/09/28 14:42:46 $
created at: Tue Aug 10 15:05:44 JST 1993
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -62,10 +62,10 @@ clone_method(mid, body, data)
NODE *fbody = body->nd_body;
if (fbody && nd_type(fbody) == NODE_SCOPE) {
- NODE *cref = (NODE*)fbody->nd_rval;
-
- if (cref) cref = cref->nd_next;
- fbody = rb_copy_node_scope(fbody, NEW_CREF(data->klass, cref));
+ 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));
return ST_CONTINUE;
@@ -409,6 +409,9 @@ 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 bf49aade4a..3584b83e35 100644
--- a/common.mk
+++ b/common.mk
@@ -1,20 +1,13 @@
bin: $(PROGRAM) $(WPROGRAM)
-lib: $(LIBRUBY)
-dll: $(LIBRUBY_SO)
+lib: $(LIBRUBY);
+dll: $(LIBRUBY_SO);
-RUBYLIB = -
-RUBYOPT = -
-
-SPEC_GIT_BASE = git://github.com/rubyspec
-MSPEC_GIT_URL = $(SPEC_GIT_BASE)/mspec.git
-RUBYSPEC_GIT_URL = $(SPEC_GIT_BASE)/rubyspec.git
+RUBYOPT =
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)
@@ -28,7 +21,6 @@ OBJS = array.$(OBJEXT) \
dir.$(OBJEXT) \
dln.$(OBJEXT) \
enum.$(OBJEXT) \
- enumerator.$(OBJEXT) \
error.$(OBJEXT) \
eval.$(OBJEXT) \
file.$(OBJEXT) \
@@ -61,25 +53,13 @@ OBJS = array.$(OBJEXT) \
$(MISSING)
SCRIPT_ARGS = --dest-dir="$(DESTDIR)" \
- --extout="$(EXTOUT)" \
+ --make="$(MAKE)" \
--mflags="$(MFLAGS)" \
--make-flags="$(MAKEFLAGS)"
-EXTMK_ARGS = $(SCRIPT_ARGS) --extension $(EXTS) --extstatic $(EXTSTATIC) --
-INSTRUBY_ARGS = $(SCRIPT_ARGS) \
- --data-mode=$(INSTALL_DATA_MODE) \
- --prog-mode=$(INSTALL_PROG_MODE) \
- --installed-list $(INSTALLED_LIST)
-INSTALL_PROG_MODE = 0755
-INSTALL_DATA_MODE = 0644
-
-PRE_LIBRUBY_UPDATE = $(MINIRUBY) -e 'ARGV[1] or File.unlink(ARGV[0]) rescue nil' -- \
- $(LIBRUBY_EXTS) $(LIBRUBY_SO_UPDATE)
-
-TESTSDIR = $(srcdir)/test
-TESTWORKDIR = testwork
+EXTMK_ARGS = $(SCRIPT_ARGS) --extout="$(EXTOUT)" --extension $(EXTS) --extstatic $(EXTSTATIC) --
all: $(MKFILES) $(PREP) $(RBCONFIG) $(LIBRUBY)
- @$(MINIRUBY) $(srcdir)/ext/extmk.rb --make="$(MAKE)" $(EXTMK_ARGS)
+ @$(MINIRUBY) $(srcdir)/ext/extmk.rb $(EXTMK_ARGS)
prog: $(PROGRAM) $(WPROGRAM)
miniruby$(EXEEXT): config.status $(LIBRUBY_A) $(MAINOBJ) $(MINIOBJS) $(OBJS) $(DMYEXT)
@@ -88,10 +68,7 @@ $(PROGRAM): $(LIBRUBY) $(MAINOBJ) $(OBJS) $(EXTOBJS) $(SETUP) $(PREP)
$(LIBRUBY_A): $(OBJS) $(DMYEXT) $(ARCHFILE)
-$(LIBRUBY_SO): $(OBJS) $(DLDOBJS) $(LIBRUBY_A) $(PREP) $(LIBRUBY_SO_UPDATE)
-
-$(LIBRUBY_EXTS):
- @exit > $@
+$(LIBRUBY_SO): $(OBJS) $(DLDOBJS) $(LIBRUBY_A) $(PREP)
$(STATIC_RUBY)$(EXEEXT): $(MAINOBJ) $(DLDOBJS) $(EXTOBJS) $(LIBRUBY_A)
@$(RM) $@
@@ -103,201 +80,64 @@ ruby.imp: $(OBJS)
install: install-nodoc $(RDOCTARGET)
install-all: install-nodoc install-doc
-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 --make="$(MAKE)" $(INSTRUBY_ARGS) --mantype="$(MANTYPE)"
-post-install-nodoc:: post-install-local post-install-ext
-
+install-nodoc: install-local install-ext
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 --make="$(MAKE)" $(INSTRUBY_ARGS) --install=local --mantype="$(MANTYPE)"
-loadpath: $(PREP)
- $(MINIRUBY) -e 'p $$:'
+install-ext: pre-install-ext do-install-ext post-install-ext
-post-install-local:: post-install-bin post-install-lib post-install-man
+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-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 --make="$(MAKE)" $(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 --make="$(MAKE)" $(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 --make="$(MAKE)" $(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 --make="$(MAKE)" $(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 --make="$(MAKE)" $(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 --make="$(MAKE)" $(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 --make="$(MAKE)" $(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 --make="$(MAKE)" $(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 --make="$(MAKE)" $(INSTRUBY_ARGS) --mantype="$(MANTYPE)"
-post-no-install-nodoc:: post-no-install-local post-no-install-ext
+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)"
+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: 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 --make="$(MAKE)" $(INSTRUBY_ARGS) --install=local --mantype="$(MANTYPE)"
-post-no-install-local:: post-no-install-bin post-no-install-lib post-no-install-man
-
+no-install-local: $(RBCONFIG)
+ $(MINIRUBY) $(srcdir)/instruby.rb -n $(SCRIPT_ARGS) --mantype="$(MANTYPE)"
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 --make="$(MAKE)" $(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 --make="$(MAKE)" $(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 --make="$(MAKE)" $(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 --make="$(MAKE)" $(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 --make="$(MAKE)" $(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 --make="$(MAKE)" $(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 --make="$(MAKE)" $(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 --make="$(MAKE)" $(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 --make="$(MAKE)" $(INSTRUBY_ARGS) --install=rdoc --rdoc-output="$(RDOCOUT)"
-post-install-doc::
- @$(NULLCMD)
+no-install-ext: $(RBCONFIG)
+ $(MINIRUBY) $(srcdir)/ext/extmk.rb -n $(EXTMK_ARGS) install
-rdoc: $(PROGRAM) PHONY
+install-doc: pre-install-doc do-install-doc post-install-doc
+do-install-doc: $(PROGRAM)
@echo Generating RDoc documentation
- $(RUNRUBY) "$(srcdir)/bin/rdoc" --all --ri --op "$(RDOCOUT)" "$(srcdir)"
-
-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 --make="$(MAKE)" $(INSTRUBY_ARGS) --install=rdoc --rdoc-output="$(RDOCOUT)"
-post-no-install-doc::
- @$(NULLCMD)
+ $(RUNRUBY) "$(srcdir)/bin/rdoc" --all --ri --op "$(RIDATADIR)" "$(srcdir)"
-CLEAR_INSTALLED_LIST = clear-installed-list
+pre-install: pre-install-local pre-install-ext
+pre-install-local:: PHONY
+ $(PREINSTALL)
+pre-install-ext:: PHONY
+pre-install-doc:: PHONY
-install-prereq: $(CLEAR_INSTALLED_LIST)
-
-clear-installed-list:
- @exit > $(INSTALLED_LIST)
+post-install: post-install-local post-install-ext
+post-install-local:: PHONY
+post-install-ext:: PHONY
+post-install-doc:: PHONY
clean: clean-ext clean-local
clean-local::
- @$(RM) $(OBJS) $(MINIOBJS) $(MAINOBJ) $(LIBRUBY_A) $(LIBRUBY_SO) $(LIBRUBY) $(LIBRUBY_ALIASES)
- @$(RM) $(PROGRAM) $(WPROGRAM) miniruby$(EXEEXT) dmyext.$(OBJEXT) $(ARCHFILE) .*.time
- @$(RM) y.tab.c y.output
+ @$(RM) $(OBJS) $(MAINOBJ) $(WINMAINOBJ) $(LIBRUBY_A) $(LIBRUBY_SO) $(LIBRUBY) $(LIBRUBY_ALIASES)
+ @$(RM) $(PROGRAM) $(WPROGRAM) miniruby$(EXEEXT) dmyext.$(OBJEXT) $(ARCHFILE)
clean-ext:
- @-$(MINIRUBY) $(srcdir)/ext/extmk.rb --make="$(MAKE)" $(EXTMK_ARGS) clean
+ @-$(MINIRUBY) $(srcdir)/ext/extmk.rb $(EXTMK_ARGS) clean
distclean: distclean-ext distclean-local
distclean-local:: clean-local
@$(RM) $(MKFILES) config.h rbconfig.rb
@$(RM) config.cache config.log config.status
- @$(RM) *~ *.bak *.stackdump core *.core gmon.out $(PREP)
+ @$(RM) *~ *.bak *.stackdump core *.core gmon.out y.tab.c y.output $(PREP)
distclean-ext:
- @-$(MINIRUBY) $(srcdir)/ext/extmk.rb --make="$(MAKE)" $(EXTMK_ARGS) distclean
+ @-$(MINIRUBY) $(srcdir)/ext/extmk.rb $(EXTMK_ARGS) distclean
-realclean:: realclean-ext realclean-local
-realclean-local:: distclean-local
+realclean:: distclean
@$(RM) parse.c lex.c
-realclean-ext::
- @-$(MINIRUBY) $(srcdir)/ext/extmk.rb --make="$(MAKE)" $(EXTMK_ARGS) realclean
check: test test-all
@@ -305,10 +145,10 @@ test: miniruby$(EXEEXT) $(RBCONFIG) $(PROGRAM) PHONY
@$(MINIRUBY) $(srcdir)/rubytest.rb
test-all:
- $(RUNRUBY) "$(srcdir)/test/runner.rb" --basedir="$(TESTSDIR)" --runner=$(TESTUI) $(TESTS)
+ $(RUNRUBY) -C "$(srcdir)/test" runner.rb --runner=$(TESTUI) $(TESTS)
extconf:
- $(MINIRUBY) -run -e mkdir -- -p "$(EXTCONFDIR)"
+ $(MINIRUBY) -I$(srcdir)/lib -run -e mkdir -- -p "$(EXTCONFDIR)"
$(RUNRUBY) -C "$(EXTCONFDIR)" $(EXTCONF) $(EXTCONFARGS)
$(RBCONFIG): $(srcdir)/mkconfig.rb config.status $(PREP)
@@ -349,8 +189,6 @@ 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"
@@ -362,8 +200,7 @@ array.$(OBJEXT): {$(VPATH)}array.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
{$(VPATH)}util.h {$(VPATH)}st.h
bignum.$(OBJEXT): {$(VPATH)}bignum.c {$(VPATH)}ruby.h config.h \
- {$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
- {$(VPATH)}rubysig.h
+ {$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h
class.$(OBJEXT): {$(VPATH)}class.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
{$(VPATH)}rubysig.h {$(VPATH)}node.h {$(VPATH)}st.h
@@ -375,13 +212,13 @@ dir.$(OBJEXT): {$(VPATH)}dir.c {$(VPATH)}ruby.h config.h \
dln.$(OBJEXT): {$(VPATH)}dln.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
{$(VPATH)}dln.h
-dmydln.$(OBJEXT): {$(VPATH)}dmydln.c dln.$(OBJEXT)
+dmydln.$(OBJEXT): {$(VPATH)}dmydln.c {$(VPATH)}dln.c {$(VPATH)}ruby.h \
+ config.h {$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
+ {$(VPATH)}dln.h
dmyext.$(OBJEXT): {$(VPATH)}dmyext.c
enum.$(OBJEXT): {$(VPATH)}enum.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
{$(VPATH)}node.h {$(VPATH)}util.h
-enumerator.$(OBJEXT): {$(VPATH)}enumerator.c {$(VPATH)}ruby.h config.h \
- {$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h
error.$(OBJEXT): {$(VPATH)}error.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
{$(VPATH)}env.h {$(VPATH)}st.h
diff --git a/compar.c b/compar.c
index 1488b2c65d..3cd3216b77 100644
--- a/compar.c
+++ b/compar.c
@@ -2,8 +2,8 @@
compar.c -
- $Author$
- $Date$
+ $Author: dave $
+ $Date: 2003/12/19 00:01:18 $
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 d922bd20da..849b10ab73 100644
--- a/configure.in
+++ b/configure.in
@@ -44,20 +44,10 @@ fi
GNU_LD=$rb_cv_prog_gnu_ld
AC_SUBST(GNU_LD)])
-unset GREP_OPTIONS
rb_version=`grep RUBY_VERSION $srcdir/version.h`
MAJOR=`expr "$rb_version" : '#define RUBY_VERSION "\([0-9][0-9]*\)\.[0-9][0-9]*\.[0-9][0-9]*"'`
MINOR=`expr "$rb_version" : '#define RUBY_VERSION "[0-9][0-9]*\.\([0-9][0-9]*\)\.[0-9][0-9]*"'`
TEENY=`expr "$rb_version" : '#define RUBY_VERSION "[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\)"'`
-if test "$MAJOR" = ""; then
- AC_MSG_ERROR(could not determine MAJOR number from version.h)
-fi
-if test "$MINOR" = ""; then
- AC_MSG_ERROR(could not determine MINOR number from version.h)
-fi
-if test "$TEENY" = ""; then
- AC_MSG_ERROR(could not determine TEENY number from version.h)
-fi
AC_SUBST(MAJOR)
AC_SUBST(MINOR)
AC_SUBST(TEENY)
@@ -85,7 +75,6 @@ AC_CANONICAL_TARGET
target_os=`echo $target_os | sed 's/linux-gnu$/linux/;s/linux-gnu/linux-/'`
ac_install_sh='' # unusable for extension libraries.
-ifelse(currently,disabled, [
dnl checks for fat-binary
AC_ARG_ENABLE(fat-binary,
[ --enable-fat-binary=ARCHS
@@ -139,7 +128,6 @@ if test "$fat_binary" != no; then
done
AC_DEFINE(NEXT_FAT_BINARY)
fi
-], [fat_binary=no])
case $target_cpu in
i?86) frame_address=yes;;
@@ -161,11 +149,6 @@ 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
@@ -246,12 +229,7 @@ else
fi
dnl check for large file stuff
-mv confdefs.h confdefs1.h
-: > confdefs.h
AC_SYS_LARGEFILE
-mv confdefs.h largefile.h
-mv confdefs1.h confdefs.h
-cat largefile.h >> confdefs.h
AC_CHECK_TYPES([long long, off_t])
@@ -308,42 +286,16 @@ if test "$rb_cv_stdarg" = yes; then
AC_DEFINE(HAVE_STDARG_PROTOTYPES)
fi
-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_CACHE_CHECK([for noreturn], rb_cv_noreturn,
+[rb_cv_noreturn=x
+for mac in "x __attribute__ ((noreturn))" "__declspec(noreturn) x" x; do
AC_TRY_COMPILE(
- [#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)
+ [#define NORETURN(x) $mac
+NORETURN(void exit(int x));],
+ [],
+ [rb_cv_noreturn="$mac"; break])
+done])
+AC_DEFINE_UNQUOTED([NORETURN(x)], $rb_cv_noreturn)
AC_CACHE_CHECK([for RUBY_EXTERN], rb_cv_ruby_extern,
[rb_cv_ruby_extern=no
@@ -372,32 +324,12 @@ 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*) ;;
openstep*) ;;
rhapsody*) ;;
-darwin*) LIBS="-lobjc $LIBS"
- CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE"
- AC_TRY_CPP([#include <AvailabilityMacros.h>
- #if MAC_OS_X_VERSION_MAX_ALLOWED <= 1040
- #error pre OS X 10.4
- [!<===== pre OS X 10.4 =====>]
- #endif
- ],
- [
- test "x$target_cpu" = xpowerpc && ac_cv_header_ucontext_h=no
- ],
- [
- AC_DEFINE(BROKEN_SETREUID, 1)
- AC_DEFINE(BROKEN_SETREGID, 1)
- ])
- ;;
+darwin*) LIBS="-lobjc $LIBS";;
hpux*) LIBS="-lm $LIBS"
ac_cv_c_inline=no;;
human*) ac_cv_func_getpgrp_void=yes
@@ -438,7 +370,6 @@ 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;;
@@ -446,11 +377,8 @@ 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_DEFINE(BROKEN_SETREUID, 1)
- AC_DEFINE(BROKEN_SETREGID, 1)
ac_cv_sizeof_rlim_t=8;;
freebsd*) LIBS="-lm $LIBS"
AC_CACHE_CHECK([whether -lxpg4 has to be linked],
@@ -501,7 +429,6 @@ esac
AC_CHECK_LIB(crypt, crypt)
AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
-AC_CHECK_LIB(rt, clock_gettime) # GNU/Linux
case "$target_cpu" in
alpha*) case "$target_os"::"$GCC" in
@@ -546,41 +473,10 @@ AC_STRUCT_ST_RDEV
dnl Checks for library functions.
AC_TYPE_GETGROUPS
AC_TYPE_SIGNAL
-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_ALLOCA
AC_FUNC_MEMCMP
AC_FUNC_FSEEKO
AC_CHECK_FUNCS(ftello)
-
-# http://sources.redhat.com/ml/libc-hacker/2005-08/msg00008.html
-# Debian GNU/Linux Etch's libc6.1 2.3.6.ds1-13etch5 has this problem.
-# Debian GNU/Linux Lenny's libc6.1 2.7-10 has no problem.
-AC_CACHE_CHECK(for broken erfc of glibc-2.3.6 on IA64, rb_cv_broken_glibc_ia64_erfc,
- [AC_TRY_RUN([
-#include <math.h>
-int
-main()
-{
- erfc(10000.0);
- return 0;
-}
-],
- rb_cv_broken_glibc_ia64_erfc=no,
- rb_cv_broken_glibc_ia64_erfc=yes,
- rb_cv_broken_glibc_ia64_erfc=no)])
-case $rb_cv_broken_glibc_ia64_erfc in
- yes) ac_cv_func_erf=no;;
-esac
-
AC_REPLACE_FUNCS(dup2 memmove strcasecmp strncasecmp strerror strftime\
strchr strstr strtoul crypt flock vsnprintf\
isnan finite isinf hypot acosh erf)
@@ -591,59 +487,9 @@ AC_CHECK_FUNCS(fmod killpg wait4 waitpid syscall chroot fsync getcwd eaccess\
lchown lchmod getpgrp setpgrp getpgid setpgid initgroups\
getgroups setgroups getpriority getrlimit setrlimit sysconf\
group_member dlopen sigprocmask\
- sigaction sigsetjmp _setjmp _longjmp setsid telldir seekdir fchmod\
+ sigaction _setjmp setsid telldir seekdir fchmod\
mktime timegm gettimeofday\
cosh sinh tanh round setuid setgid setenv unsetenv)
-
-AC_CACHE_CHECK(for __builtin_setjmp, ac_cv_func___builtin_setjmp,
-[AC_TRY_LINK([@%:@include <setjmp.h>
- jmp_buf jb; void t(v) int v; {__builtin_longjmp(jb, v);}],
- [__builtin_setjmp(jb);],
- [ac_cv_func___builtin_setjmp=yes],
- [ac_cv_func___builtin_setjmp=no])
-])
-
-test x$ac_cv_func__longjmp = xno && ac_cv_func__setjmp=no
-
-AC_MSG_CHECKING(for setjmp type)
-AC_ARG_WITH(setjmp-type,
- [ --with-setjmp-type select setjmp type], [
- case $withval in
- __builtin_setjmp) setjmp_prefix=__builtin_;;
- _setjmp) setjmp_prefix=_;;
- sigsetjmp) setjmp_prefix=sig;;
- setjmp) setjmp_prefix=;;
- '') unset setjmp_prefix;;
- *) AC_MSG_ERROR(invalid setjmp type: $withval);;
- esac], [unset setjmp_prefix])
-if test ${setjmp_prefix+set}; then
- if test "${setjmp_prefix}" && eval test '$ac_cv_func_'${setjmp_prefix}setjmp = no; then
- AC_MSG_ERROR(${setjmp_prefix}setjmp is not available)
- fi
-elif test "$ac_cv_func___builtin_setjmp" = yes; then
- setjmp_prefix=__builtin_
-elif test "$ac_cv_func__setjmp" = yes; then
- setjmp_prefix=_
-elif test "$ac_cv_func_sigsetjmp" = yes; then
- case $target_os in
- solaris*|cygwin*)
- setjmp_prefix=;;
- *)
- setjmp_prefix=sig;;
- esac
-else
- setjmp_prefix=
-fi
-if test x$setjmp_prefix = xsig; then
- setjmp_sigmask=yes
-else
- unset setjmp_sigmask
-fi
-AC_MSG_RESULT(${setjmp_prefix}setjmp)
-AC_DEFINE_UNQUOTED([RUBY_SETJMP(env)], [${setjmp_prefix}setjmp(env${setjmp_sigmask+,0})])
-AC_DEFINE_UNQUOTED([RUBY_LONGJMP(env,val)], [${setjmp_prefix}longjmp(env,val)])
-AC_DEFINE_UNQUOTED(RUBY_JMP_BUF, ${setjmp_sigmask+${setjmp_prefix}}jmp_buf)
-
AC_ARG_ENABLE(setreuid,
[ --enable-setreuid use setreuid()/setregid() according to need even if obsolete.],
[use_setreuid=$enableval])
@@ -672,23 +518,15 @@ 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([
-#ifndef _XOPEN_SOURCE
-#define _XOPEN_SOURCE 1
-#endif
-$2
-;
-const volatile void *volatile t;],
+ AC_TRY_COMPILE([#define _XOPEN_SOURCE 1
+ $2
+ const volatile void *volatile t;],
[t = &(&$1)[0];],
[for t in $3; do
- AC_TRY_COMPILE([
-#ifndef _XOPEN_SOURCE
-#define _XOPEN_SOURCE 1
-#endif
-$2
-;
-extern $t $1;
-const volatile void *volatile t;],
+ 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])])
@@ -696,13 +534,13 @@ 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])
+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
+ 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>],
+ [AC_TRY_COMPILE([#include <time.h>],
[(void)timezone(0, 0);],
[rb_cv_func_timezone_void=no],
[rb_cv_func_timezone_void=yes])]
@@ -792,21 +630,6 @@ 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
@@ -1039,7 +862,7 @@ if test x"$enable_pthread" = xyes; then
fi
fi
if test x"$ac_cv_header_ucontext_h" = xyes; then
- if test x"$rb_with_pthread" = xyes; then
+ if test x"$target_cpu" = xia64 -o x"$rb_with_pthread" = xyes; then
AC_CHECK_FUNCS(getcontext setcontext)
fi
fi
@@ -1138,23 +961,11 @@ if test "$with_dln_a_out" != yes; then
esac
fi
-
- AC_ARG_ENABLE(rpath,
- [ --disable-rpath embed run path into extension libraries.],
- [enable_rpath=$enableval], [enable_rpath="$rb_cv_binary_elf"])
- if test "$enable_rpath" = yes; then
- LIBPATHFLAG=" -L%1\$-s"
- RPATHFLAG=" ${linker_flag}-R%1\$-s"
- fi
-
case "$target_os" in
hpux*) DLDFLAGS="$DLDFLAGS -E"
: ${LDSHARED='ld -b'}
XLDFLAGS="$XLDFLAGS -Wl,-E"
: ${LIBPATHENV=SHLIB_PATH}
- if test "$rb_cv_prog_gnu_ld" = no; then
- RPATHFLAG=' +b %1$-s'
- fi
rb_cv_dlopen=yes;;
solaris*) if test "$GCC" = yes; then
: ${LDSHARED='$(CC) -shared'}
@@ -1218,13 +1029,14 @@ if test "$with_dln_a_out" != yes; then
: ${LIBPATHENV=DYLD_LIBRARY_PATH}
rb_cv_dlopen=yes ;;
aix*) if test "$GCC" = yes; then
- : ${LDSHARED='$(CC) -shared'}
- else
- : ${LDSHARED='$(CC)'}
- fi
- LDSHARED="$LDSHARED ${linker_flag}-G"
- DLDFLAGS='-eInit_$(TARGET)'
- XLDFLAGS="${linker_flag}-bE:ruby.imp ${linker_flag}-brtl"
+ : ${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
: ${ARCHFILE="ruby.imp"}
TRY_LINK='$(CC) $(LDFLAGS) -oconftest $(INCFLAGS) -I$(hdrdir) $(CPPFLAGS)'
TRY_LINK="$TRY_LINK"' $(CFLAGS) $(src) $(LIBPATH) $(LOCAL_LIBS) $(LIBS)'
@@ -1253,7 +1065,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-image-base,--enable-auto-import,--export-all"
+ DLDFLAGS="${DLDFLAGS} -Wl,--enable-auto-import,--export-all"
: ${LIBPATHENV=""}
rb_cv_dlopen=yes ;;
hiuxmpp) : ${LDSHARED='ld -r'} ;;
@@ -1264,6 +1076,18 @@ if test "$with_dln_a_out" != yes; then
*) : ${LDSHARED='ld'} ;;
esac
AC_MSG_RESULT($rb_cv_dlopen)
+
+ AC_ARG_ENABLE(rpath,
+ [ --disable-rpath embed run path into extension libraries.],
+ [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
+ fi
fi
AC_SUBST(LINK_SO)
AC_SUBST(LIBPATHFLAG)
@@ -1297,24 +1121,30 @@ 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;;
- nextstep*|openstep*|rhapsody*|darwin*)
- DLEXT=bundle;;
- os2-emx*) DLEXT=dll;;
- cygwin*|mingw*)
- DLEXT=so DLEXT2=dll;;
- *) DLEXT=so;;
+ 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");;
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
@@ -1423,10 +1253,9 @@ if test x"$cross_compiling" = xyes; then
PREP=fake.rb
RUNRUBY='$(MINIRUBY) -I`cd $(srcdir)/lib; pwd`'
else
- MINIRUBY='./miniruby$(EXEEXT) -I$(srcdir)/lib'
- MINIRUBY="$MINIRUBY"' -I$(EXTOUT)/common -I./- -r$(srcdir)/ext/purelib.rb'
+ MINIRUBY='./miniruby$(EXEEXT)'
PREP='miniruby$(EXEEXT)'
- RUNRUBY='$(MINIRUBY) $(srcdir)/runruby.rb --extout=$(EXTOUT)'
+ RUNRUBY='$(MINIRUBY) $(srcdir)/runruby.rb --extout=$(EXTOUT) --'
fi
AC_SUBST(MINIRUBY)
AC_SUBST(PREP)
@@ -1513,8 +1342,14 @@ if test "$enable_shared" = 'yes'; then
LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).sl.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).sl'
;;
aix*)
- LIBRUBY_DLDFLAGS="${linker_flag}-bnoentry $XLDFLAGS"
- LIBRUBYARG_SHARED='-L${libdir} -l${RUBY_SO_NAME}'
+ 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'
SOLIBS='-lm -lc'
;;
beos*)
@@ -1531,17 +1366,21 @@ if test "$enable_shared" = 'yes'; then
LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).$(MAJOR).$(MINOR).dylib lib$(RUBY_SO_NAME).dylib'
;;
interix*)
- LIBRUBYARG_SHARED='-L. -L${libdir} -l$(RUBY_SO_NAME)'
+ LIBRUBYARG_SHARED='-L${libdir} -L. -l$(RUBY_SO_NAME)'
;;
*)
;;
esac
fi
if test "$enable_rpath" = yes; then
- LIBRUBYARG_SHARED="${linker_flag}-R ${linker_flag}\$(libdir) -L\$(libdir) $LIBRUBYARG_SHARED"
+ 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
fi
-LDFLAGS="-L. $LDFLAGS"
+XLDFLAGS="$XLDFLAGS -L."
AC_SUBST(ARCHFILE)
dnl build rdoc index if requested
@@ -1577,7 +1416,6 @@ case "$target_os" in
;;
darwin*)
CFLAGS="$CFLAGS -pipe -fno-common"
- MINIOBJS=dmydln.o
;;
os2-emx)
CFLAGS="$CFLAGS -DOS2 -Zmts"
@@ -1600,7 +1438,7 @@ case "$target_os" in
rm -f /tmp/main.o
CFLAGS="$CFLAGS -std"
fi
- ;;
+ ;;
beos*)
case "$target_cpu" in
powerpc*)
@@ -1648,6 +1486,9 @@ 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
@@ -1656,13 +1497,6 @@ case "$build_os" in
*msdosdjgpp*) FIRSTMAKEFILE=GNUmakefile:djgpp/GNUmakefile.in;;
esac
-CPPFLAGS="$CPPFLAGS "'$(DEFS)'
-test -z "$CFLAGS" || CFLAGS="$CFLAGS "; CFLAGS="$CFLAGS"'${cflags}'
-test -z "$CPPFLAGS" || CPPFLAGS="$CPPFLAGS "; CPPFLAGS="$CPPFLAGS"'${cppflags}'
-AC_SUBST(cppflags, [])dnl
-AC_SUBST(cflags, ['${optflags} ${debugflags}'])dnl
-AC_SUBST(optflags)dnl
-AC_SUBST(debugflags)dnl
AC_SUBST(XCFLAGS)dnl
AC_SUBST(XLDFLAGS)dnl
AC_SUBST(LIBRUBY_LDSHARED)
@@ -1687,6 +1521,7 @@ 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`"
@@ -1707,53 +1542,37 @@ case "$target_os" in
rubyw_install_name="$RUBYW_INSTALL_NAME"
;;
esac
-RUBY_LIB_PREFIX=`eval echo \\"${libdir}/ruby\\"`
-
-AC_ARG_WITH(sitedir,
- [ --with-sitedir=DIR site libraries in DIR [[LIBDIR/ruby/site_ruby]]],
- [sitedir=$withval],
- [sitedir='${libdir}/ruby/site_ruby'])
-SITE_DIR=`eval echo \\"${sitedir}\\"`
-
case "$target_os" in
cygwin*|mingw*|*djgpp*|os2-emx*)
- RUBY_LIB_PREFIX="`eval echo "$RUBY_LIB_PREFIX" | sed 's|^NONE/|/|;s|^'"$prefix"'/|/|'`"
- RUBY_SITE_LIB_PATH="`eval echo "$SITE_DIR" | sed 's|^NONE/|/|;s|^'"$prefix"'/|/|'`"
+ RUBY_LIB_PREFIX="/lib/ruby"
;;
*)
- RUBY_LIB_PREFIX="`eval echo \\"$RUBY_LIB_PREFIX\\" | sed 's|^NONE/|'"$prefix"'/|'`"
- RUBY_SITE_LIB_PATH="`eval echo \\"$SITE_DIR\\" | sed 's|^NONE/|'"$prefix"'/|'`"
+ RUBY_LIB_PREFIX="${prefix}/lib/ruby"
;;
esac
RUBY_LIB_PATH="${RUBY_LIB_PREFIX}/${MAJOR}.${MINOR}"
-RUBY_SITE_LIB_PATH2="${RUBY_SITE_LIB_PATH}/${MAJOR}.${MINOR}"
-AC_DEFINE_UNQUOTED(RUBY_LIB, "${RUBY_LIB_PATH}")
-AC_DEFINE_UNQUOTED(RUBY_SITE_LIB, "${RUBY_SITE_LIB_PATH}")
-AC_DEFINE_UNQUOTED(RUBY_SITE_LIB2, "${RUBY_SITE_LIB_PATH2}")
-
-AC_ARG_WITH(vendordir,
- [ --with-vendordir=DIR vendor libraries in DIR [[LIBDIR/ruby/vendor_ruby]]],
- [vendordir=$withval],
- [vendordir='${libdir}/ruby/vendor_ruby'])
-VENDOR_DIR=`eval echo \\"${vendordir}\\"`
+AC_ARG_WITH(sitedir,
+ [ --with-sitedir=DIR site libraries in DIR [PREFIX/lib/ruby/site_ruby]],
+ [sitedir=$withval],
+ [sitedir='${prefix}/lib/ruby/site_ruby'])
+SITE_DIR=`eval echo \\"${sitedir}\\"`
case "$target_os" in
cygwin*|mingw*|*djgpp*|os2-emx*)
- RUBY_VENDOR_LIB_PATH="`eval echo "$VENDOR_DIR" | sed 's|^NONE/|/|;s|^'"$prefix"'/|/|'`"
- ;;
+ RUBY_SITE_LIB_PATH="`expr "$SITE_DIR" : "$prefix\(/.*\)"`" ||
+ RUBY_SITE_LIB_PATH="$SITE_DIR";;
*)
- RUBY_VENDOR_LIB_PATH="`eval echo \\"$VENDOR_DIR\\" | sed 's|^NONE/|'"$prefix"'/|'`"
- ;;
+ RUBY_SITE_LIB_PATH="$SITE_DIR";;
esac
-RUBY_VENDOR_LIB_PATH2="${RUBY_VENDOR_LIB_PATH}/${MAJOR}.${MINOR}"
+RUBY_SITE_LIB_PATH2="${RUBY_SITE_LIB_PATH}/${MAJOR}.${MINOR}"
-AC_DEFINE_UNQUOTED(RUBY_VENDOR_LIB, "${RUBY_VENDOR_LIB_PATH}")
-AC_DEFINE_UNQUOTED(RUBY_VENDOR_LIB2, "${RUBY_VENDOR_LIB_PATH2}")
+AC_DEFINE_UNQUOTED(RUBY_LIB, "${RUBY_LIB_PATH}")
+AC_DEFINE_UNQUOTED(RUBY_SITE_LIB, "${RUBY_SITE_LIB_PATH}")
+AC_DEFINE_UNQUOTED(RUBY_SITE_LIB2, "${RUBY_SITE_LIB_PATH2}")
AC_SUBST(arch)dnl
AC_SUBST(sitearch)dnl
AC_SUBST(sitedir)dnl
-AC_SUBST(vendordir)dnl
configure_args=$ac_configure_args
AC_SUBST(configure_args)dnl
@@ -1766,8 +1585,6 @@ if test "$fat_binary" != no ; then
AC_DEFINE_UNQUOTED(RUBY_SITE_THIN_ARCHLIB,
"${RUBY_SITE_LIB_PATH}/" __ARCHITECTURE__ "-${target_os}")
- AC_DEFINE_UNQUOTED(RUBY_VENDOR_THIN_ARCHLIB,
- "${RUBY_VENDOR_LIB_PATH}/" __ARCHITECTURE__ "-${target_os}")
AC_DEFINE_UNQUOTED(RUBY_PLATFORM, __ARCHITECTURE__ "-${target_os}")
else
arch="${target_cpu}-${target_os}"
@@ -1775,13 +1592,12 @@ else
fi
case "$target_os" in
- mingw*) sitearch="$target_cpu-$rb_cv_msvcrt" ;;
+ mingw*) sitearch="i386-$rb_cv_msvcrt" ;;
*) sitearch="${arch}" ;;
esac
AC_DEFINE_UNQUOTED(RUBY_ARCHLIB, "${RUBY_LIB_PATH}/${arch}")
AC_DEFINE_UNQUOTED(RUBY_SITE_ARCHLIB, "${RUBY_SITE_LIB_PATH2}/${sitearch}")
-AC_DEFINE_UNQUOTED(RUBY_VENDOR_ARCHLIB, "${RUBY_VENDOR_LIB_PATH2}/${sitearch}")
AC_ARG_WITH(search-path,
[ --with-search-path=DIR specify the additional search path],
@@ -1818,15 +1634,12 @@ else
echo "creating config.h"
tr -d '\015' < confdefs.h > config.h
fi
-tr -d '\015' < largefile.h > confdefs.h
-rm largefile.h
+: > confdefs.h
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
- } >> confmk$$.tmp && mv -f confmk$$.tmp Makefile],
-[RUBY_INSTALL_NAME=$RUBY_INSTALL_NAME EXEEXT=$EXEEXT])
+} >> Makefile], [RUBY_INSTALL_NAME=$RUBY_INSTALL_NAME EXEEXT=$EXEEXT])
AC_OUTPUT
diff --git a/defines.h b/defines.h
index f39097fea4..ae1277a6bf 100644
--- a/defines.h
+++ b/defines.h
@@ -2,8 +2,8 @@
defines.h -
- $Author$
- $Date$
+ $Author: nobu $
+ $Date: 2005/10/25 16:59:57 $
created at: Wed May 18 00:21:44 JST 1994
************************************************/
@@ -102,16 +102,6 @@ void xfree _((void*));
#endif
#endif
-#if defined(__NeXT__) || defined(__APPLE__)
-/* Do not trust WORDS_BIGENDIAN from configure since -arch compiler flag may
- result in a different endian. Instead trust __BIG_ENDIAN__ and
- __LITTLE_ENDIAN__ which are set correctly by -arch. */
-#undef WORDS_BIGENDIAN
-#ifdef __BIG_ENDIAN__
-#define WORDS_BIGENDIAN
-#endif
-#endif
-
#ifdef __NeXT__
/* NextStep, OpenStep, Rhapsody */
#ifndef S_IRUSR
@@ -165,6 +155,13 @@ void xfree _((void*));
#ifndef S_ISREG
#define S_ISREG(mode) (((mode) & (0170000)) == (0100000))
#endif
+/* Do not trust WORDS_BIGENDIAN from configure since -arch compiler flag may
+ result in a different endian. Instead trust __BIG_ENDIAN__ and
+ __LITTLE_ENDIAN__ which are set correctly by -arch. */
+#undef WORDS_BIGENDIAN
+#ifdef __BIG_ENDIAN__
+#define WORDS_BIGENDIAN
+#endif
#ifndef __APPLE__
/* NextStep, OpenStep (but not Rhapsody) */
#ifndef GETPGRP_VOID
@@ -227,10 +224,13 @@ flush_register_windows(void)
;
}
# 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()
+#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()
#else
# define FLUSH_REGISTER_WINDOWS ((void)0)
#endif
diff --git a/dir.c b/dir.c
index 710299e7b6..0798b3f76f 100644
--- a/dir.c
+++ b/dir.c
@@ -2,8 +2,8 @@
dir.c -
- $Author$
- $Date$
+ $Author: shyouhei $
+ $Date: 2006/12/14 14:50:13 $
created at: Wed Jan 5 09:51:01 JST 1994
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -89,261 +89,153 @@ 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 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? */
+#ifndef CharNext /* defined as CharNext[AW] on Windows. */
+# if defined(DJGPP)
+# define CharNext(p) ((p) + mblen(p, MB_CUR_MAX))
+# else
+# define CharNext(p) ((p) + 1)
+# endif
#endif
- if (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 */
- }
- }
+#if defined DOSISH
+#define isdirsep(c) ((c) == '/' || (c) == '\\')
+#else
+#define isdirsep(c) ((c) == '/')
#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 *
-bracket(p, s, flags)
- const char *p; /* pattern (next to '[') */
- const char *s; /* string */
+range(pat, test, flags)
+ const char *pat;
+ int test;
int flags;
{
- const int nocase = flags & FNM_CASEFOLD;
- const int escape = !(flags & FNM_NOESCAPE);
+ int not, ok = 0;
+ int nocase = flags & FNM_CASEFOLD;
+ int escape = !(flags & FNM_NOESCAPE);
- int ok = 0, not = 0;
+ not = *pat == '!' || *pat == '^';
+ if (not)
+ pat++;
- if (*p == '!' || *p == '^') {
- not = 1;
- p++;
- }
+ test = downcase(test);
- while (*p != ']') {
- const char *t1 = p;
- if (escape && *t1 == '\\')
- t1++;
- if (!*t1)
+ while (*pat != ']') {
+ int cstart, cend;
+ if (escape && *pat == '\\')
+ pat++;
+ cstart = cend = *pat++;
+ if (!cstart)
return NULL;
- p = Next(t1);
- if (p[0] == '-' && p[1] != ']') {
- const char *t2 = p + 1;
- if (escape && *t2 == '\\')
- t2++;
- if (!*t2)
+ if (*pat == '-' && pat[1] != ']') {
+ pat++;
+ if (escape && *pat == '\\')
+ pat++;
+ cend = *pat++;
+ if (!cend)
return NULL;
- p = Next(t2);
- if (!ok && Compare(t1, s) <= 0 && Compare(s, t2) <= 0)
- ok = 1;
}
- else
- if (!ok && Compare(t1, s) == 0)
- ok = 1;
+ if (downcase(cstart) <= test && test <= downcase(cend))
+ ok = 1;
}
-
- return ok == not ? NULL : (char *)p + 1;
+ return ok == not ? NULL : (char *)pat + 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);
-
+#define ISDIRSEP(c) (pathname && isdirsep(c))
+#define PERIOD(s) (period && *(s) == '.' && \
+ ((s) == string || ISDIRSEP((s)[-1])))
static int
-fnmatch_helper(pcur, scur, flags)
- const char **pcur; /* pattern */
- const char **scur; /* string */
+fnmatch(pat, string, flags)
+ const char *pat;
+ const char *string;
int flags;
{
- const int period = !(flags & FNM_DOTMATCH);
- const int pathname = flags & FNM_PATHNAME;
- const int escape = !(flags & FNM_NOESCAPE);
- const int nocase = flags & FNM_CASEFOLD;
-
- const char *ptmp = 0;
- const char *stmp = 0;
+ 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 char *p = *pcur;
- const char *s = *scur;
+ while ((c = *pat++) != '\0') {
+ switch (c) {
+ case '?':
+ if (!*s || ISDIRSEP(*s) || PERIOD(s))
+ return FNM_NOMATCH;
+ s++;
+ break;
+ case '*':
+ while ((c = *pat++) == '*')
+ ;
- if (period && *s == '.' && *UNESCAPE(p) != '.') /* leading period */
- RETURN(FNM_NOMATCH);
+ if (PERIOD(s))
+ return FNM_NOMATCH;
- while (1) {
- switch (*p) {
- case '*':
- do { p++; } while (*p == '*');
- if (ISEND(UNESCAPE(p))) {
- p = UNESCAPE(p);
- RETURN(0);
+ if (!c) {
+ if (pathname && *rb_path_next(s))
+ return FNM_NOMATCH;
+ else
+ return 0;
}
- if (ISEND(s))
- RETURN(FNM_NOMATCH);
- ptmp = p;
- stmp = s;
- continue;
-
- case '?':
- if (ISEND(s))
- RETURN(FNM_NOMATCH);
- p++;
- Inc(s);
- continue;
-
- case '[': {
- const char *t;
- if (ISEND(s))
- RETURN(FNM_NOMATCH);
- if ((t = bracket(p + 1, s, flags)) != 0) {
- p = t;
- Inc(s);
- continue;
+ else if (ISDIRSEP(c)) {
+ s = rb_path_next(s);
+ if (*s) {
+ s++;
+ break;
+ }
+ return FNM_NOMATCH;
}
- goto failed;
- }
- }
-
- /* 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)
+ 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;
- }
- /* failed : try next recursion */
- if (ptmp && stmp && !(period && *stmp == '.')) {
- while (*stmp && *stmp != '/') Inc(stmp);
- if (*stmp) {
- p = ptmp;
- stmp++;
- s = stmp;
- continue;
- }
+ else if (ISDIRSEP(*s))
+ break;
+ s++;
}
return FNM_NOMATCH;
+
+ 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 (escape
+#if defined DOSISH
+ && *pat && strchr("*?[]\\", *pat)
+#endif
+ ) {
+ c = *pat;
+ if (!c)
+ c = '\\';
+ else
+ pat++;
+ }
+ /* FALLTHROUGH */
+
+ default:
+#if defined DOSISH
+ if (ISDIRSEP(c) && isdirsep(*s))
+ ;
+ else
+#endif
+ if(downcase(c) != downcase(*s))
+ return FNM_NOMATCH;
+ s++;
+ break;
}
}
- else
- return fnmatch_helper(&p, &s, flags);
+ return !*s ? 0 : FNM_NOMATCH;
}
VALUE rb_cDir;
@@ -463,29 +355,6 @@ 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;
-
- Data_Get_Struct(dir, struct dir_data, dirp);
- if (dirp->path) {
- const 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.
@@ -499,7 +368,7 @@ dir_path(dir)
{
struct dir_data *dirp;
- Data_Get_Struct(dir, struct dir_data, dirp);
+ GetDIR(dir, dirp);
if (!dirp->path) return Qnil;
return rb_str_new2(dirp->path);
}
@@ -562,7 +431,6 @@ dir_each(dir)
struct dir_data *dirp;
struct dirent *dp;
- RETURN_ENUMERATOR(dir, 0, 0);
GetDIR(dir, dirp);
rewinddir(dirp->dir);
for (dp = readdir(dirp->dir); dp != NULL; dp = readdir(dirp->dir)) {
@@ -670,9 +538,6 @@ 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;
@@ -694,6 +559,9 @@ 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;
@@ -951,252 +819,109 @@ sys_warning_1(mesg)
rb_sys_warning("%s", mesg);
}
-#define GLOB_VERBOSE (1UL << (sizeof(int) * CHAR_BIT - 1))
+#define GLOB_VERBOSE (1U << (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, flags)
- const char *s;
+has_magic(s, send, flags)
+ const char *s, *send;
int flags;
{
- const int escape = !(flags & FNM_NOESCAPE);
- const int nocase = flags & FNM_CASEFOLD;
-
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) {
+ while ((c = *p++) != '\0') {
switch (c) {
- case '*':
case '?':
- case '[':
- return 1;
+ case '*':
+ return Qtrue;
- case '\\':
- if (escape && !(c = *p++))
- return 0;
+ case '[': /* Only accept an open brace if there is a close */
+ open++; /* brace to match it. Bracket expressions must be */
+ continue; /* complete, according to Posix.2 */
+ case ']':
+ if (open)
+ return Qtrue;
continue;
+ case '\\':
+ if (escape && *p++ == '\0')
+ return Qfalse;
+ break;
+
default:
if (!FNM_SYSCASE && ISALPHA(c) && nocase)
- return 1;
+ return Qtrue;
}
- p = Next(p-1);
+ if (send && p >= send) break;
}
-
- return 0;
+ return Qfalse;
}
-/* Find separator in globbing pattern. */
-static char *
-find_dirsep(const char *s, int flags)
+static char*
+extract_path(p, pend)
+ const char *p, *pend;
{
- const int escape = !(flags & FNM_NOESCAPE);
-
- register const char *p = s;
- register char c;
- int open = 0;
-
- while ((c = *p++) != 0) {
- switch (c) {
- case '[':
- open = 1;
- continue;
- case ']':
- open = 0;
- continue;
+ 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;
+ }
- case '/':
- if (!open)
- return (char *)p-1;
- continue;
+ return alloc;
+}
- case '\\':
- if (escape && !(c = *p++))
- return (char *)p-1;
- continue;
- }
+static char*
+extract_elem(path)
+ const char *path;
+{
+ const char *pend;
- p = Next(p-1);
- }
+ pend = strchr(path, '/');
+ if (!pend) pend = path + strlen(path);
- return (char *)p-1;
+ return extract_path(path, pend);
}
-/* Remove escaping backslashes */
static void
remove_backslashes(p)
char *p;
{
+ char *pend = p + strlen(p);
char *t = p;
- char *s = p;
- while (*p) {
+ while (p < pend) {
if (*p == '\\') {
- 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;
- }
+ if (++p == pend) break;
}
- *tail = tmp;
- tail = &tmp->next;
- }
-
- tmp = GLOB_ALLOC(struct glob_pattern);
- if (!tmp) {
- error:
- *tail = 0;
- glob_free_pattern(list);
- return 0;
+ *t++ = *p++;
}
- tmp->type = dirsep ? MATCH_DIR : MATCH_ALL;
- tmp->str = 0;
- *tail = tmp;
- tmp->next = 0;
-
- return list;
+ *t = '\0';
}
-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
@@ -1221,239 +946,235 @@ glob_func_caller(val)
#define glob_call_func(func, path, arg) (*func)(path, 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 _((const char *path, const char *sub, int flags, int (*func)(const char *,VALUE), VALUE arg));
static int
-glob_helper(path, dirsep, exist, isdir, beg, end, flags, func, arg)
+glob_helper(path, sub, flags, func, arg)
const char *path;
- 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;
+ const char *sub;
int flags;
- ruby_glob_func *func;
+ int (*func) _((const char *, VALUE));
VALUE arg;
{
struct stat st;
+ const char *p, *m;
int status = 0;
- 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 {
- exist = NO;
- isdir = NO;
- }
- }
- if (match_dir && isdir == UNKNOWN) {
- if (do_stat(path, &st, flags) == 0) {
- exist = YES;
- isdir = S_ISDIR(st.st_mode) ? YES : NO;
+ 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;
}
else {
- exist = NO;
- isdir = NO;
+ remove_backslashes(newpath);
+ p = path = newpath;
}
}
- if (match_all && exist == YES) {
+ if (lstat(path, &st) == 0) {
status = glob_call_func(func, path, arg);
- if (status) return status;
}
- 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;
+ 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 (newpath) free(newpath);
+ return status;
}
- 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) {
+ 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) {
status = -1;
break;
}
- 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
- }
+ if (path == p) dir = ".";
+ else dir = base;
- new_beg = new_end = GLOB_ALLOC_N(struct glob_pattern *, (end - beg) * 2);
- if (!new_beg) {
+ magic = extract_elem(p);
+ if (!magic) {
status = -1;
break;
}
-
- 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 */
+ 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;
}
- if (p->type == PLAIN || p->type == MAGICAL) {
- if (fnmatch(p->str, dp->d_name, flags) == 0)
- *new_end++ = p->next;
+ dirp = opendir(dir);
+ if (dirp == NULL) {
+ sys_warning(dir);
+ free(base);
+ free(magic);
+ break;
}
}
+ else {
+ free(base);
+ free(magic);
+ break;
+ }
- status = glob_helper(buf, 1, YES, new_isdir, new_beg, new_end, flags, func, arg);
- free(buf);
- free(new_beg);
- if (status) break;
- }
-
- 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;
- }
- strcpy(name, (*cur)->str);
- if (escape) remove_backslashes(name);
+#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
- new_beg = new_end = GLOB_ALLOC_N(struct glob_pattern *, end - beg);
- if (!new_beg) {
- free(name);
- status = -1;
- 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;
}
- *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;
+ 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;
}
-
- buf = join_path(path, dirsep, name);
- free(name);
- if (!buf) {
- free(new_beg);
- 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);
+ }
+ }
+ next_elem:
+ tmp = link;
+ link = link->next;
+ free(tmp->path);
+ free(tmp);
}
- status = glob_helper(buf, 1, UNKNOWN, UNKNOWN, new_beg, new_end, flags, func, arg);
- free(buf);
- free(new_beg);
- if (status) break;
+ break;
}
}
-
- free(copy_beg);
+ p = m;
}
-
+ if (buf) free(buf);
+ if (newpath) free(newpath);
return status;
}
-static int
-ruby_glob0(path, flags, func, arg)
+int
+ruby_glob(path, flags, func, arg)
const char *path;
int flags;
- ruby_glob_func *func;
+ int (*func) _((const char *, VALUE));
VALUE arg;
{
- struct glob_pattern *list;
- const char *root, *start;
- char *buf;
- int n;
- int status;
-
- start = root = path;
flags |= FNM_SYSCASE;
-#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;
+ return glob_helper(path, 0, flags & ~GLOB_VERBOSE, func, arg);
}
int
-ruby_glob(path, flags, func, arg)
+ruby_globi(path, flags, func, arg)
const char *path;
int flags;
- ruby_glob_func *func;
+ int (*func) _((const char *, VALUE));
VALUE arg;
{
- return ruby_glob0(path, flags & ~GLOB_VERBOSE, func, arg);
+ return glob_helper(path, 0, flags | FNM_CASEFOLD, func, arg);
}
static int rb_glob_caller _((const char *, VALUE));
@@ -1483,11 +1204,8 @@ rb_glob2(path, flags, func, arg)
args.func = func;
args.v = arg;
- if (flags & FNM_SYSCASE) {
- rb_warning("Dir.glob() ignores File::FNM_CASEFOLD");
- }
-
- return ruby_glob0(path, flags | GLOB_VERBOSE, rb_glob_caller, (VALUE)&args);
+ flags |= FNM_SYSCASE;
+ return glob_helper(path, 0, flags | GLOB_VERBOSE, rb_glob_caller, (VALUE)&args);
}
void
@@ -1497,10 +1215,19 @@ rb_glob(path, func, arg)
VALUE arg;
{
int status = rb_glob2(path, 0, func, arg);
- if (status) GLOB_JUMP_TAG(status);
+ 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);
}
-static void push_pattern _((const char* path, VALUE ary));
static void
push_pattern(path, ary)
const char *path;
@@ -1509,196 +1236,155 @@ push_pattern(path, ary)
rb_ary_push(ary, rb_tainted_str_new2(path));
}
-int
-ruby_brace_expand(str, flags, func, arg)
+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;
const char *str;
int flags;
- ruby_glob_func *func;
- VALUE arg;
{
- 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;
+ char *buf = 0;
+ char *b, *newbuf;
+ const char *s, *p, *t;
+ const char *lbrace, *rbrace;
+ int nest = 0;
+ int status = 0;
+ s = p = str;
+ lbrace = rbrace = 0;
while (*p) {
- if (*p == '{' && nest++ == 0) {
+ if (*p == '{') {
lbrace = p;
+ break;
}
- if (*p == '}' && --nest <= 0) {
+ p++;
+ }
+ while (*p) {
+ if (*p == '{') nest++;
+ if (*p == '}' && --nest == 0) {
rbrace = p;
break;
}
- if (*p == '\\' && escape) {
- if (!*++p) break;
- }
- Inc(p);
+ p++;
}
if (lbrace && rbrace) {
- char *buf = GLOB_ALLOC_N(char, strlen(s) + 1);
- long shift;
-
- if (!buf) return -1;
- memcpy(buf, s, lbrace-s);
- shift = (lbrace-s);
+ int len = strlen(s);
p = lbrace;
- 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;
+ while (*p != '}') {
+ t = p + 1;
+ for (p = t; *p!='}' && *p!=','; p++) {
+ /* skip inner braces */
+ if (*p == '{') {
+ nest = 1;
+ while (*++p != '}' || --nest) {
+ if (*p == '{') nest++;
+ }
}
- Inc(p);
}
- memcpy(buf+shift, t, p-t);
- strcpy(buf+shift+(p-t), rbrace+1);
- status = ruby_brace_expand(buf, flags, func, arg);
+ 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);
if (status) break;
}
- free(buf);
}
- else if (!lbrace && !rbrace) {
- status = (*func)(s, arg);
+ else {
+ status = push_globs(ary, str, flags);
}
+ if (buf) free(buf);
return status;
}
-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);
-}
+#define isdelim(c) ((c)=='\0')
static VALUE
-rb_push_glob(str, flags) /* '\0' is delimiter */
+rb_push_glob(str, flags)
VALUE str;
int flags;
{
- long offset = 0;
+ const char *p, *pend, *buf;
+ int nest, maxnest;
+ int status = 0;
+ int noescape = flags & FNM_NOESCAPE;
VALUE ary;
ary = rb_ary_new();
SafeStringValue(str);
-
- 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 = 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;
+ }
p++;
- offset = p - RSTRING(str)->ptr;
+ }
+ 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 */
}
-
- 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];
- SafeStringValue(str);
- status = push_glob(ary, RSTRING(str)->ptr, flags);
- if (status) GLOB_JUMP_TAG(status);
+ if (status) GLOB_JUMP_TAG(status);
+ if (rb_block_given_p()) {
+ rb_ary_each(ary);
+ return Qnil;
}
-
return ary;
}
/*
* call-seq:
- * Dir[ array ] => array
- * Dir[ string [, string ...] ] => array
+ * Dir[ string ] => array
*
* Equivalent to calling
- * <code>Dir.glob(</code><i>array,</i><code>0)</code> and
- * <code>Dir.glob([</code><i>string,...</i><code>],0)</code>.
+ * <em>dir</em>.<code>glob(</code><i>string,</i><code>0)</code>.
*
*/
static VALUE
-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);
- }
+dir_s_aref(obj, str)
+ VALUE obj, str;
+{
+ return rb_push_glob(str, 0);
+}
/*
* call-seq:
- * Dir.glob( pattern, [flags] ) => array
- * Dir.glob( pattern, [flags] ) {| filename | block } => nil
+ * Dir.glob( string, [flags] ) => array
+ * Dir.glob( string, [flags] ) {| filename | block } => nil
*
- * 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)
+ * 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.
*
* <code>*</code>:: Matches any file. Can be restricted by
* other values in the glob. <code>*</code>
@@ -1753,7 +1439,7 @@ dir_s_glob(argc, argv, obj)
VALUE *argv;
VALUE obj;
{
- VALUE str, rflags, ary;
+ VALUE str, rflags;
int flags;
if (rb_scan_args(argc, argv, "11", &str, &rflags) == 2)
@@ -1761,20 +1447,7 @@ dir_s_glob(argc, argv, obj)
else
flags = 0;
- 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;
+ return rb_push_glob(str, flags);
}
static VALUE
@@ -1815,7 +1488,6 @@ dir_foreach(io, dirname)
{
VALUE dir;
- RETURN_ENUMERATOR(io, 1, &dirname);
dir = dir_open_dir(dirname);
rb_ensure(dir_each, dir, dir_close, dir);
return Qnil;
@@ -1862,8 +1534,6 @@ 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+.
@@ -1876,52 +1546,31 @@ dir_entries(io, dirname)
* parameters. The same glob pattern and flags are used by
* <code>Dir::glob</code>.
*
- * 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('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
*
- * pattern = '*' '/' '*'
- * File.fnmatch(pattern, 'dave/.profile', File::FNM_PATHNAME) #=> false
- * File.fnmatch(pattern, 'dave/.profile', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> 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 = '**' '/' '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
+ * File.fnmatch('*', '.profile') #=> false
+ * File.fnmatch('*', '.profile', File::FNM_DOTMATCH) #=> true
+ * File.fnmatch('*', 'dave/.profile') #=> true
+ * File.fnmatch('*', 'dave/.profile', File::FNM_DOTMATCH) #=> true
+ * File.fnmatch('*', 'dave/.profile', File::FNM_PATHNAME) #=> false
+ * File.fnmatch('* / FIXME *', 'dave/.profile', File::FNM_PATHNAME) #=> false
+ * STRICT = File::FNM_PATHNAME | File::FNM_DOTMATCH
+ * File.fnmatch('* / FIXME *', 'dave/.profile', STRICT) #=> true
*/
static VALUE
file_s_fnmatch(argc, argv, obj)
@@ -1972,7 +1621,6 @@ Init_Dir()
rb_define_method(rb_cDir,"initialize", dir_initialize, 1);
rb_define_method(rb_cDir,"path", dir_path, 0);
- rb_define_method(rb_cDir,"inspect", dir_inspect, 0);
rb_define_method(rb_cDir,"read", dir_read, 0);
rb_define_method(rb_cDir,"each", dir_each, 0);
rb_define_method(rb_cDir,"rewind", dir_rewind, 0);
@@ -1992,7 +1640,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 5ba25b6415..f665ce4712 100644
--- a/dln.c
+++ b/dln.c
@@ -2,8 +2,8 @@
dln.c -
- $Author$
- $Date$
+ $Author: matz $
+ $Date: 2006/08/07 03:43:39 $
created at: Tue Jan 18 17:05:06 JST 1994
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -81,28 +81,19 @@ char *getenv();
# include "macruby_private.h"
#endif
-#if defined(__APPLE__) && defined(__MACH__) /* Mac OS X */
-# if defined(HAVE_DLOPEN)
- /* Mac OS X with dlopen (10.3 or later) */
-# define MACOSX_DLOPEN
-# else
-# define MACOSX_DYLD
-# endif
-#endif
-
#ifdef __BEOS__
# include <image.h>
#endif
#ifndef NO_DLN_LOAD
-#if defined(HAVE_DLOPEN) && !defined(USE_DLN_A_OUT) && !defined(_AIX) && !defined(MACOSX_DYLD) && !defined(_UNICOSMP)
+#if defined(HAVE_DLOPEN) && !defined(USE_DLN_A_OUT) && !defined(_AIX) && !defined(__APPLE__) && !defined(_UNICOSMP)
/* dynamic load with dlopen() */
# define USE_DLN_DLOPEN
#endif
#ifndef FUNCNAME_PATTERN
-# if defined(__hp9000s300) || (defined(__NetBSD__) && !defined(__ELF__)) || defined(__BORLANDC__) || (defined(__FreeBSD__) && !defined(__ELF__)) || (defined(__OpenBSD__) && !defined(__ELF__)) || defined(NeXT) || defined(__WATCOMC__) || defined(MACOSX_DYLD)
+# if defined(__hp9000s300) || (defined(__NetBSD__) && !defined(__ELF__)) || defined(__BORLANDC__) || (defined(__FreeBSD__) && !defined(__ELF__)) || (defined(__OpenBSD__) && !defined(__ELF__)) || defined(NeXT) || defined(__WATCOMC__) || defined(__APPLE__)
# define FUNCNAME_PATTERN "_Init_%s"
# else
# define FUNCNAME_PATTERN "Init_%s"
@@ -645,7 +636,7 @@ load_1(fd, disp, need_init)
long disp;
const char *need_init;
{
- static const char *libc = LIBC_NAME;
+ static char *libc = LIBC_NAME;
struct exec hdr;
struct relocation_info *reloc = NULL;
long block = 0;
@@ -1150,7 +1141,7 @@ dln_sym(name)
#endif
#endif
#else
-#ifdef MACOSX_DYLD
+#ifdef __APPLE__
#include <mach-o/dyld.h>
#endif
#endif
@@ -1412,7 +1403,7 @@ dln_load(file)
}
#endif /* _AIX */
-#if defined(NeXT) || defined(MACOSX_DYLD)
+#if defined(NeXT) || defined(__APPLE__)
#define DLN_DEFINED
/*----------------------------------------------------
By SHIROYAMA Takayuki Psi@fortune.nest.or.jp
@@ -1536,7 +1527,7 @@ dln_load(file)
}
#endif /* __BEOS__*/
-#ifdef __MACOS__ /* Mac OS 9 or before */
+#ifdef __MACOS__
# define DLN_DEFINED
{
OSErr err;
@@ -1689,31 +1680,31 @@ static char fbuf[MAXPATHLEN];
static char *
dln_find_1(fname, path, exe_flag)
- const char *fname;
- const char *path;
+ char *fname;
+ char *path;
int exe_flag; /* non 0 if looking for executable. */
{
- register const char *dp;
- register const char *ep;
+ register char *dp;
+ register char *ep;
register char *bp;
struct stat st;
#ifdef __MACOS__
const char* mac_fullpath;
#endif
- if (!fname) return (char *)fname;
- if (fname[0] == '/') return (char *)fname;
+ if (!fname) return fname;
+ if (fname[0] == '/') return fname;
if (strncmp("./", fname, 2) == 0 || strncmp("../", fname, 3) == 0)
- return (char *)fname;
- if (exe_flag && strchr(fname, '/')) return (char *)fname;
+ return fname;
+ if (exe_flag && strchr(fname, '/')) return fname;
#ifdef DOSISH
- if (fname[0] == '\\') return (char *)fname;
+ if (fname[0] == '\\') return fname;
# ifdef DOSISH_DRIVE_LETTER
- if (strlen(fname) > 2 && fname[1] == ':') return (char *)fname;
+ if (strlen(fname) > 2 && fname[1] == ':') return fname;
# endif
if (strncmp(".\\", fname, 2) == 0 || strncmp("..\\", fname, 3) == 0)
- return (char *)fname;
- if (exe_flag && strchr(fname, '\\')) return (char *)fname;
+ return fname;
+ if (exe_flag && strchr(fname, '\\')) return fname;
#endif
for (dp = path;; dp = ++ep) {
diff --git a/dln.h b/dln.h
index 182cf9f9f4..3d52ea2827 100644
--- a/dln.h
+++ b/dln.h
@@ -2,8 +2,8 @@
dln.h -
- $Author$
- $Date$
+ $Author: michal $
+ $Date: 2003/01/16 07:34:01 $
created at: Wed Jan 19 16:53:09 JST 1994
Copyright (C) 1993-2003 Yukihiro Matsumoto
diff --git a/doc/NEWS-1.8.0 b/doc/NEWS
index b4445fa59f..b4445fa59f 100644
--- a/doc/NEWS-1.8.0
+++ b/doc/NEWS
diff --git a/doc/forwardable.rd b/doc/forwardable.rd
index 7272c374b6..f9c8234761 100644
--- a/doc/forwardable.rd
+++ b/doc/forwardable.rd
@@ -1,8 +1,8 @@
-- forwardable.rb
$Release Version: 1.1 $
- $Revision$
- $Date$
+ $Revision: 1.2 $
+ $Date: 2001/05/07 23:52:57 $
Original version by Tosh
=begin
diff --git a/doc/forwardable.rd.ja b/doc/forwardable.rd.ja
index d928fddc5e..a56823dd1a 100644
--- a/doc/forwardable.rd.ja
+++ b/doc/forwardable.rd.ja
@@ -1,7 +1,7 @@
-- forwatable.rb
$Release Version: 1.1 $
- $Revision$
- $Date$
+ $Revision: 1.1 $
+ $Date: 2001/07/19 05:42:06 $
=begin
= Forwardable
diff --git a/doc/irb/irb-tools.rd.ja b/doc/irb/irb-tools.rd.ja
index 64d9ab29c8..38145576dc 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$
- $Date$
+ $Revision: 1.1 $
+ $Date: 2001/07/19 05:42:06 $
by Keiju ISHITSUKA(Nihon Rational Co.,Ltd.)
=begin
diff --git a/doc/irb/irb.rd b/doc/irb/irb.rd
index a42cd46680..f56e8b60e0 100644
--- a/doc/irb/irb.rd
+++ b/doc/irb/irb.rd
@@ -1,7 +1,7 @@
irb -- interactive ruby
$Release Version: 0.9 $
- $Revision$
- $Date$
+ $Revision: 1.6 $
+ $Date: 2003/07/31 16:34:07 $
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 338dcc644e..aa3c0e13aa 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$
- $Date$
+ $Revision: 1.3.2.1 $
+ $Date: 2005/04/19 19:24:56 $
by Keiju ISHITSUKA(keiju@ruby-lang.org)
=begin
= irb¤È¤Ï?
diff --git a/doc/shell.rd b/doc/shell.rd
index 02ee1b020a..ae6855cbd8 100644
--- a/doc/shell.rd
+++ b/doc/shell.rd
@@ -1,7 +1,7 @@
-- shell.rb
$Release Version: 0.6.0 $
- $Revision$
- $Date$
+ $Revision: 1.2 $
+ $Date: 2001/05/17 10:09:49 $
by Keiju ISHITSUKA(keiju@ishitsuka.com)
=begin
diff --git a/doc/shell.rd.ja b/doc/shell.rd.ja
index 073e71ea42..aab9e5c7d2 100644
--- a/doc/shell.rd.ja
+++ b/doc/shell.rd.ja
@@ -1,7 +1,7 @@
-- shell.rb
$Release Version: 0.6.0 $
- $Revision$
- $Date$
+ $Revision: 1.1 $
+ $Date: 2001/07/19 05:42:06 $
by Keiju ISHITSUKA(keiju@ishitsuka.com)
=begin
diff --git a/enum.c b/enum.c
index df35c2fe03..112a5f820b 100644
--- a/enum.c
+++ b/enum.c
@@ -2,8 +2,8 @@
enum.c -
- $Author$
- $Date$
+ $Author: drbrain $
+ $Date: 2006/06/15 01:24:40 $
created at: Fri Oct 1 15:15:19 JST 1993
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -15,43 +15,7 @@
#include "util.h"
VALUE rb_mEnumerable;
-static ID id_each, id_eqq, id_cmp, id_size;
-
-struct iter_method_arg {
- VALUE obj;
- ID mid;
- int argc;
- VALUE *argv;
-};
-
-static VALUE iterate_method _((VALUE obj));
-static VALUE
-iterate_method(obj)
- VALUE obj;
-{
- struct iter_method_arg *arg;
-
- arg = (struct iter_method_arg *)obj;
- return rb_funcall2(arg->obj, arg->mid, arg->argc, arg->argv);
-}
-
-VALUE
-rb_block_call(obj, mid, argc, argv, bl_proc, data2)
- VALUE obj;
- ID mid;
- int argc;
- VALUE *argv;
- VALUE (*bl_proc) (ANYARGS);
- VALUE data2;
-{
- struct iter_method_arg arg;
-
- arg.obj = obj;
- arg.mid = mid;
- arg.argc = argc;
- arg.argv = argv;
- return rb_iterate(iterate_method, (VALUE)&arg, bl_proc, data2);
-}
+static ID id_each, id_eqq, id_cmp;
VALUE
rb_each(obj)
@@ -84,18 +48,18 @@ grep_iter_i(i, arg)
* call-seq:
* enum.grep(pattern) => array
* enum.grep(pattern) {| obj | block } => array
- *
+ *
* Returns an array of every element in <i>enum</i> for which
* <code>Pattern === element</code>. If the optional <em>block</em> is
* supplied, each matching element is passed to it, and the block's
* result is stored in the output array.
- *
+ *
* (1..100).grep 38..44 #=> [38, 39, 40, 41, 42, 43, 44]
* c = IO.constants
* c.grep(/SEEK/) #=> ["SEEK_END", "SEEK_SET", "SEEK_CUR"]
* res = c.grep(/SEEK/) {|v| IO.const_get(v) }
* res #=> [2, 0, 1]
- *
+ *
*/
static VALUE
@@ -109,99 +73,10 @@ enum_grep(obj, pat)
arg[1] = ary;
rb_iterate(rb_each, obj, rb_block_given_p() ? grep_iter_i : grep_i, (VALUE)arg);
-
+
return ary;
}
-static VALUE count_i _((VALUE, VALUE));
-static VALUE
-count_i(i, memop)
- VALUE i, memop;
-{
- VALUE *memo = (VALUE*)memop;
-
- if (rb_equal(i, memo[1])) {
- memo[0]++;
- }
- return Qnil;
-}
-
-static VALUE count_iter_i _((VALUE, VALUE));
-static VALUE
-count_iter_i(i, memop)
- VALUE i, memop;
-{
- VALUE *memo = (VALUE*)memop;
-
- if (RTEST(rb_yield(i))) {
- memo[0]++;
- }
- return Qnil;
-}
-
-static VALUE count_all_i _((VALUE, VALUE));
-static VALUE
-count_all_i(i, memop)
- VALUE i, memop;
-{
- VALUE *memo = (VALUE*)memop;
-
- memo[0]++;
- return Qnil;
-}
-
-/*
- * call-seq:
- * enum.count => int
- * enum.count(item) => int
- * enum.count {| obj | block } => int
- *
- * Returns the number of items in <i>enum</i>, where #size is called
- * if it responds to it, otherwise the items are counted through
- * enumeration. If an argument is given, counts the number of items
- * in <i>enum</i>, for which equals to <i>item</i>. If a block is
- * given, counts the number of elements yielding a true value.
- *
- * ary = [1, 2, 4, 2]
- * ary.count # => 4
- * ary.count(2) # => 2
- * ary.count{|x|x%2==0} # => 3
- *
- */
-
-static VALUE
-enum_count(argc, argv, obj)
- int argc;
- VALUE *argv;
- VALUE obj;
-{
- VALUE memo[2]; /* [count, condition value] */
- rb_block_call_func *func;
-
- if (argc == 0) {
- if (rb_block_given_p()) {
- func = count_iter_i;
- }
- else {
- if (rb_respond_to(obj, id_size)) {
- return rb_funcall(obj, id_size, 0, 0);
- }
- func = count_all_i;
- }
- }
- else {
- rb_scan_args(argc, argv, "1", &memo[1]);
- if (rb_block_given_p()) {
- rb_warn("given block not used");
- }
- func = count_i;
- }
-
- memo[0] = 0;
- rb_block_call(obj, id_each, 0, 0, func, (VALUE)&memo);
- return INT2NUM(memo[0]);
-}
-
static VALUE
find_i(i, memo)
VALUE i;
@@ -218,15 +93,15 @@ find_i(i, memo)
* call-seq:
* enum.detect(ifnone = nil) {| obj | block } => obj or nil
* enum.find(ifnone = nil) {| obj | block } => obj or nil
- *
+ *
* Passes each entry in <i>enum</i> to <em>block</em>. Returns the
* first for which <em>block</em> is not <code>false</code>. If no
* object matches, calls <i>ifnone</i> and returns its result when it
* is specified, or returns <code>nil</code>
- *
+ *
* (1..10).detect {|i| i % 5 == 0 and i % 7 == 0 } #=> nil
* (1..100).detect {|i| i % 5 == 0 and i % 7 == 0 } #=> 35
- *
+ *
*/
static VALUE
@@ -239,7 +114,6 @@ enum_find(argc, argv, obj)
VALUE if_none;
rb_scan_args(argc, argv, "01", &if_none);
- RETURN_ENUMERATOR(obj, argc, argv);
rb_iterate(rb_each, obj, find_i, (VALUE)&memo);
if (memo != Qundef) {
return memo;
@@ -250,81 +124,6 @@ enum_find(argc, argv, obj)
return Qnil;
}
-static VALUE find_index_i _((VALUE, VALUE));
-static VALUE
-find_index_i(i, memop)
- VALUE i;
- VALUE memop;
-{
- VALUE *memo = (VALUE*)memop;
-
- if (rb_equal(i, memo[2])) {
- memo[0] = UINT2NUM(memo[1]);
- rb_iter_break();
- }
- memo[1]++;
- return Qnil;
-}
-
-static VALUE find_index_iter_i _((VALUE, VALUE));
-static VALUE
-find_index_iter_i(i, memop)
- VALUE i;
- VALUE memop;
-{
- VALUE *memo = (VALUE*)memop;
-
- if (RTEST(rb_yield(i))) {
- memo[0] = UINT2NUM(memo[1]);
- rb_iter_break();
- }
- memo[1]++;
- return Qnil;
-}
-
-/*
- * call-seq:
- * enum.find_index(value) => int or nil
- * enum.find_index {| obj | block } => int or nil
- *
- * Compares each entry in <i>enum</i> with <em>value</em> or passes
- * to <em>block</em>. Returns the index for the first for which the
- * evaluated value is non-false. If no object matches, returns
- * <code>nil</code>
- *
- * (1..10).find_index {|i| i % 5 == 0 and i % 7 == 0 } #=> nil
- * (1..100).find_index {|i| i % 5 == 0 and i % 7 == 0 } #=> 34
- * (1..100).find_index(50) #=> 49
- *
- */
-
-static VALUE
-enum_find_index(argc, argv, obj)
- int argc;
- VALUE *argv;
- VALUE obj;
-{
- VALUE memo[3]; /* [return value, current index, condition value] */
- rb_block_call_func *func;
-
- if (argc == 0) {
- RETURN_ENUMERATOR(obj, 0, 0);
- func = find_index_iter_i;
- }
- else {
- rb_scan_args(argc, argv, "1", &memo[2]);
- if (rb_block_given_p()) {
- rb_warn("given block not used");
- }
- func = find_index_i;
- }
-
- memo[0] = Qnil;
- memo[1] = 0;
- rb_block_call(obj, id_each, 0, 0, func, (VALUE)memo);
- return memo[0];
-}
-
static VALUE
find_all_i(i, ary)
VALUE i, ary;
@@ -339,13 +138,13 @@ find_all_i(i, ary)
* call-seq:
* enum.find_all {| obj | block } => array
* enum.select {| obj | block } => array
- *
+ *
* Returns an array containing all elements of <i>enum</i> for which
* <em>block</em> is not <code>false</code> (see also
* <code>Enumerable#reject</code>).
- *
+ *
* (1..10).find_all {|i| i % 3 == 0 } #=> [3, 6, 9]
- *
+ *
*/
static VALUE
@@ -353,8 +152,7 @@ enum_find_all(obj)
VALUE obj;
{
VALUE ary = rb_ary_new();
-
- RETURN_ENUMERATOR(obj, 0, 0);
+
rb_iterate(rb_each, obj, find_all_i, ary);
return ary;
@@ -373,12 +171,12 @@ reject_i(i, ary)
/*
* call-seq:
* enum.reject {| obj | block } => array
- *
+ *
* Returns an array for all elements of <i>enum</i> for which
* <em>block</em> is false (see also <code>Enumerable#find_all</code>).
- *
+ *
* (1..10).reject {|i| i % 3 == 0 } #=> [1, 2, 4, 5, 7, 8, 10]
- *
+ *
*/
static VALUE
@@ -386,8 +184,7 @@ enum_reject(obj)
VALUE obj;
{
VALUE ary = rb_ary_new();
-
- RETURN_ENUMERATOR(obj, 0, 0);
+
rb_iterate(rb_each, obj, reject_i, ary);
return ary;
@@ -415,13 +212,13 @@ collect_all(i, ary)
* call-seq:
* enum.collect {| obj | block } => array
* enum.map {| obj | block } => array
- *
+ *
* Returns a new array with the results of running <em>block</em> once
* for every element in <i>enum</i>.
- *
+ *
* (1..4).collect {|i| i*i } #=> [1, 4, 9, 16]
* (1..4).collect { "cat" } #=> ["cat", "cat", "cat", "cat"]
- *
+ *
*/
static VALUE
@@ -439,135 +236,80 @@ enum_collect(obj)
* call-seq:
* enum.to_a => array
* enum.entries => array
- *
+ *
* Returns an array containing the items in <i>enum</i>.
- *
+ *
* (1..7).to_a #=> [1, 2, 3, 4, 5, 6, 7]
* { 'a'=>1, 'b'=>2, 'c'=>3 }.to_a #=> [["a", 1], ["b", 2], ["c", 3]]
*/
static VALUE
-enum_to_a(argc, argv, obj)
- int argc;
- VALUE *argv;
+enum_to_a(obj)
VALUE obj;
{
VALUE ary = rb_ary_new();
- rb_block_call(obj, id_each, argc, argv, collect_all, ary);
+ rb_iterate(rb_each, obj, collect_all, ary);
return ary;
}
-static VALUE inject_i _((VALUE, VALUE));
-static VALUE
-inject_i(i, p)
- VALUE i;
- VALUE p;
-{
- VALUE *memo = (VALUE *)p;
- if (memo[0] == Qundef) {
- memo[0] = i;
- }
- else {
- memo[0] = rb_yield_values(2, memo[0], i);
- }
- return Qnil;
-}
-
-static VALUE inject_op_i _((VALUE, VALUE));
static VALUE
-inject_op_i(i, p)
+inject_i(i, memo)
VALUE i;
- VALUE p;
+ VALUE *memo;
{
- VALUE *memo = (VALUE *)p;
-
- if (memo[0] == Qundef) {
- memo[0] = i;
+ if (*memo == Qundef) {
+ *memo = i;
}
else {
- memo[0] = rb_funcall(memo[0], (ID)memo[1], 1, i);
+ *memo = rb_yield_values(2, *memo, i);
}
return Qnil;
}
/*
* call-seq:
- * enum.inject(initial, sym) => obj
- * enum.inject(sym) => obj
* enum.inject(initial) {| memo, obj | block } => obj
* enum.inject {| memo, obj | block } => obj
- *
- * enum.reduce(initial, sym) => obj
- * enum.reduce(sym) => obj
- * enum.reduce(initial) {| memo, obj | block } => obj
- * enum.reduce {| memo, obj | block } => obj
- *
- * Combines all elements of <i>enum</i> by applying a binary
- * operation, specified by a block or a symbol that names a
- * method or operator.
- *
- * If you specify a block, then for each element in <i>enum<i>
- * the block is passed an accumulator value (<i>memo</i>) and the element.
- * If you specify a symbol instead, then each element in the collection
- * will be passed to the named method of <i>memo</i>.
- * In either case, the result becomes the new value for <i>memo</i>.
- * At the end of the iteration, the final value of <i>memo</i> is the
- * return value fo the method.
- *
- * If you do not explicitly specify an <i>initial</i> value for <i>memo</i>,
- * then uses the first element of collection is used as the initial value
- * of <i>memo</i>.
- *
- * Examples:
- *
+ *
+ * Combines the elements of <i>enum</i> by applying the block to an
+ * accumulator value (<i>memo</i>) and each element in turn. At each
+ * step, <i>memo</i> is set to the value returned by the block. The
+ * first form lets you supply an initial value for <i>memo</i>. The
+ * second form uses the first element of the collection as a the
+ * initial value (and skips that element while iterating).
+ *
* # Sum some numbers
- * (5..10).reduce(:+) #=> 45
- * # Same using a block and inject
- * (5..10).inject {|sum, n| sum + n } #=> 45
+ * (5..10).inject {|sum, n| sum + n } #=> 45
* # Multiply some numbers
- * (5..10).reduce(1, :*) #=> 151200
- * # Same using a block
- * (5..10).inject(1) {|product, n| product * n } #=> 151200
+ * (5..10).inject(1) {|product, n| product * n } #=> 151200
+ *
* # find the longest word
* longest = %w{ cat sheep bear }.inject do |memo,word|
* memo.length > word.length ? memo : word
* end
- * longest #=> "sheep"
- *
+ * longest #=> "sheep"
+ *
+ * # find the length of the longest word
+ * longest = %w{ cat sheep bear }.inject(0) do |memo,word|
+ * memo >= word.length ? memo : word.length
+ * end
+ * longest #=> 5
+ *
*/
+
static VALUE
enum_inject(argc, argv, obj)
int argc;
- VALUE *argv;
- VALUE obj;
+ VALUE *argv, obj;
{
- VALUE memo[2];
- rb_block_call_func *iter = inject_i;
-
- switch (rb_scan_args(argc, argv, "02", &memo[0], &memo[1])) {
- case 0:
- memo[0] = Qundef;
- break;
- case 1:
- if (rb_block_given_p()) {
- break;
- }
- memo[1] = (VALUE)rb_to_id(memo[0]);
- memo[0] = Qundef;
- iter = inject_op_i;
- break;
- case 2:
- if (rb_block_given_p()) {
- rb_warning("given block not used");
- }
- memo[1] = (VALUE)rb_to_id(memo[1]);
- iter = inject_op_i;
- break;
- }
- rb_block_call(obj, id_each, 0, 0, iter, (VALUE)memo);
- if (memo[0] == Qundef) return Qnil;
- return memo[0];
+ VALUE memo = Qundef;
+
+ if (rb_scan_args(argc, argv, "01", &memo) == 0)
+ memo = Qundef;
+ rb_iterate(rb_each, obj, inject_i, (VALUE)&memo);
+ if (memo == Qundef) return Qnil;
+ return memo;
}
static VALUE
@@ -586,13 +328,13 @@ partition_i(i, ary)
/*
* call-seq:
* enum.partition {| obj | block } => [ true_array, false_array ]
- *
+ *
* Returns two arrays, the first containing the elements of
* <i>enum</i> for which the block evaluates to true, the second
* containing the rest.
- *
+ *
* (1..6).partition {|i| (i&1).zero?} #=> [[2, 4, 6], [1, 3, 5]]
- *
+ *
*/
static VALUE
@@ -601,8 +343,6 @@ enum_partition(obj)
{
VALUE ary[2];
- RETURN_ENUMERATOR(obj, 0, 0);
-
ary[0] = rb_ary_new();
ary[1] = rb_ary_new();
rb_iterate(rb_each, obj, partition_i, (VALUE)ary);
@@ -610,111 +350,11 @@ enum_partition(obj)
return rb_assoc_new(ary[0], ary[1]);
}
-static VALUE
-group_by_i(i, hash)
- VALUE i;
- VALUE hash;
-{
- VALUE group = rb_yield(i);
- VALUE values;
-
- values = rb_hash_aref(hash, group);
- if (NIL_P(values)) {
- values = rb_ary_new3(1, i);
- rb_hash_aset(hash, group, values);
- }
- else {
- rb_ary_push(values, i);
- }
- return Qnil;
-}
-
-/*
- * call-seq:
- * enum.group_by {| obj | block } => a_hash
- *
- * Returns a hash, which keys are evaluated result from the
- * block, and values are arrays of elements in <i>enum</i>
- * corresponding to the key.
- *
- * (1..6).group_by {|i| i%3} #=> {0=>[3, 6], 1=>[1, 4], 2=>[2, 5]}
- *
- */
-
-static VALUE
-enum_group_by(obj)
- VALUE obj;
-{
- VALUE hash;
-
- RETURN_ENUMERATOR(obj, 0, 0);
-
- hash = rb_hash_new();
- rb_block_call(obj, id_each, 0, 0, group_by_i, hash);
-
- return hash;
-}
-
-static VALUE
-first_i(i, ary)
- VALUE i;
- VALUE *ary;
-{
- if (NIL_P(ary[0])) {
- ary[1] = i;
- rb_iter_break();
- }
- else {
- long n = NUM2LONG(ary[0]);
-
- if (n <= 0) {
- rb_iter_break();
- }
- rb_ary_push(ary[1], i);
- n--;
- ary[0] = INT2NUM(n);
- }
- return Qnil;
-}
-
-/*
- * call-seq:
- * enum.first -> obj or nil
- * enum.first(n) -> an_array
- *
- * Returns the first element, or the first +n+ elements, of the enumerable.
- * If the enumerable is empty, the first form returns <code>nil</code>, and the
- * second form returns an empty array.
- *
- */
-
-static VALUE
-enum_first(argc, argv, obj)
- int argc;
- VALUE *argv;
- VALUE obj;
-{
- VALUE n, ary[2];
-
- if (argc == 0) {
- ary[0] = ary[1] = Qnil;
- }
- else {
- rb_scan_args(argc, argv, "01", &n);
- ary[0] = n;
- ary[1] = rb_ary_new2(NUM2LONG(n));
- }
- rb_block_call(obj, id_each, 0, 0, first_i, (VALUE)ary);
-
- return ary[1];
-}
-
-
/*
* call-seq:
* enum.sort => array
* enum.sort {| a, b | block } => array
- *
+ *
* Returns an array containing the items in <i>enum</i> sorted,
* either according to their own <code><=></code> method, or by using
* the results of the supplied block. The block should return -1, 0, or
@@ -722,7 +362,7 @@ enum_first(argc, argv, obj)
* Ruby 1.8, the method <code>Enumerable#sort_by</code> implements a
* built-in Schwartzian Transform, useful when key computation or
* comparison is expensive..
- *
+ *
* %w(rhea kea flea).sort #=> ["flea", "kea", "rhea"]
* (1..10).sort {|a,b| b <=> a} #=> [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
*/
@@ -731,7 +371,7 @@ static VALUE
enum_sort(obj)
VALUE obj;
{
- return rb_ary_sort(enum_to_a(0, 0, obj));
+ return rb_ary_sort(enum_to_a(obj));
}
static VALUE
@@ -751,70 +391,65 @@ sort_by_i(i, ary)
}
static int
-sort_by_cmp(aa, bb, data)
+sort_by_cmp(aa, bb)
NODE **aa, **bb;
- void *data;
{
VALUE a = aa[0]->u1.value;
VALUE b = bb[0]->u1.value;
- VALUE ary = (VALUE)data;
- if (RBASIC(ary)->klass) {
- rb_raise(rb_eRuntimeError, "sort_by reentered");
- }
return rb_cmpint(rb_funcall(a, id_cmp, 1, b), a, b);
}
/*
* call-seq:
* enum.sort_by {| obj | block } => array
- *
+ *
* Sorts <i>enum</i> using a set of keys generated by mapping the
* values in <i>enum</i> through the given block.
- *
+ *
* %w{ apple pear fig }.sort_by {|word| word.length}
#=> ["fig", "pear", "apple"]
- *
+ *
* The current implementation of <code>sort_by</code> generates an
* array of tuples containing the original collection element and the
* mapped value. This makes <code>sort_by</code> fairly expensive when
* the keysets are simple
- *
+ *
* require 'benchmark'
* include Benchmark
- *
+ *
* a = (1..100000).map {rand(100000)}
- *
+ *
* bm(10) do |b|
* b.report("Sort") { a.sort }
* b.report("Sort by") { a.sort_by {|a| a} }
* end
- *
+ *
* <em>produces:</em>
- *
+ *
* user system total real
* Sort 0.180000 0.000000 0.180000 ( 0.175469)
* Sort by 1.980000 0.040000 2.020000 ( 2.013586)
- *
+ *
* However, consider the case where comparing the keys is a non-trivial
* operation. The following code sorts some files on modification time
* using the basic <code>sort</code> method.
- *
+ *
* files = Dir["*"]
* sorted = files.sort {|a,b| File.new(a).mtime <=> File.new(b).mtime}
* sorted #=> ["mon", "tues", "wed", "thurs"]
- *
+ *
* This sort is inefficient: it generates two new <code>File</code>
* objects during every comparison. A slightly better technique is to
* use the <code>Kernel#test</code> method to generate the modification
* times directly.
- *
+ *
* files = Dir["*"]
* sorted = files.sort { |a,b|
* test(?M, a) <=> test(?M, b)
* }
* sorted #=> ["mon", "tues", "wed", "thurs"]
- *
+ *
* This still generates many unnecessary <code>Time</code> objects. A
* more efficient technique is to cache the sort keys (modification
* times in this case) before the sort. Perl users often call this
@@ -822,14 +457,14 @@ sort_by_cmp(aa, bb, data)
* construct a temporary array, where each element is an array
* containing our sort key along with the filename. We sort this array,
* and then extract the filename from the result.
- *
+ *
* sorted = Dir["*"].collect { |f|
* [test(?M, f), f]
* }.sort.collect { |f| f[1] }
* sorted #=> ["mon", "tues", "wed", "thurs"]
- *
+ *
* This is exactly what <code>sort_by</code> does internally.
- *
+ *
* sorted = Dir["*"].sort_by {|f| test(?M, f)}
* sorted #=> ["mon", "tues", "wed", "thurs"]
*/
@@ -841,8 +476,6 @@ enum_sort_by(obj)
VALUE ary;
long i;
- RETURN_ENUMERATOR(obj, 0, 0);
-
if (TYPE(obj) == T_ARRAY) {
ary = rb_ary_new2(RARRAY(obj)->len);
}
@@ -852,8 +485,7 @@ enum_sort_by(obj)
RBASIC(ary)->klass = 0;
rb_iterate(rb_each, obj, sort_by_i, ary);
if (RARRAY(ary)->len > 1) {
- qsort(RARRAY(ary)->ptr, RARRAY(ary)->len, sizeof(VALUE),
- sort_by_cmp, (void *)ary);
+ qsort(RARRAY(ary)->ptr, RARRAY(ary)->len, sizeof(VALUE), sort_by_cmp, 0);
}
if (RBASIC(ary)->klass) {
rb_raise(rb_eRuntimeError, "sort_by reentered");
@@ -866,11 +498,11 @@ enum_sort_by(obj)
}
static VALUE
-all_i(i, memo)
+all_iter_i(i, memo)
VALUE i;
VALUE *memo;
{
- if (!RTEST(i)) {
+ if (!RTEST(rb_yield(i))) {
*memo = Qfalse;
rb_iter_break();
}
@@ -878,28 +510,32 @@ all_i(i, memo)
}
static VALUE
-all_iter_i(i, memo)
+all_i(i, memo)
VALUE i;
VALUE *memo;
{
- return all_i(rb_yield(i), memo);
+ if (!RTEST(i)) {
+ *memo = Qfalse;
+ rb_iter_break();
+ }
+ return Qnil;
}
/*
* call-seq:
* enum.all? [{|obj| block } ] => true or false
- *
+ *
* Passes each element of the collection to the given block. The method
* returns <code>true</code> if the block never returns
* <code>false</code> or <code>nil</code>. If the block is not given,
* Ruby adds an implicit block of <code>{|obj| obj}</code> (that is
* <code>all?</code> will return <code>true</code> only if none of the
* collection members are <code>false</code> or <code>nil</code>.)
- *
+ *
* %w{ ant bear cat}.all? {|word| word.length >= 3} #=> true
* %w{ ant bear cat}.all? {|word| word.length >= 4} #=> false
* [ nil, true, 99 ].all? #=> false
- *
+ *
*/
static VALUE
@@ -913,11 +549,11 @@ enum_all(obj)
}
static VALUE
-any_i(i, memo)
+any_iter_i(i, memo)
VALUE i;
VALUE *memo;
{
- if (RTEST(i)) {
+ if (RTEST(rb_yield(i))) {
*memo = Qtrue;
rb_iter_break();
}
@@ -925,17 +561,21 @@ any_i(i, memo)
}
static VALUE
-any_iter_i(i, memo)
+any_i(i, memo)
VALUE i;
VALUE *memo;
{
- return any_i(rb_yield(i), memo);
+ if (RTEST(i)) {
+ *memo = Qtrue;
+ rb_iter_break();
+ }
+ return Qnil;
}
/*
* call-seq:
* enum.any? [{|obj| block } ] => true or false
- *
+ *
* Passes each element of the collection to the given block. The method
* returns <code>true</code> if the block ever returns a value other
* than <code>false</code> or <code>nil</code>. If the block is not
@@ -943,11 +583,11 @@ any_iter_i(i, memo)
* is <code>any?</code> will return <code>true</code> if at least one
* of the collection members is not <code>false</code> or
* <code>nil</code>.
- *
+ *
* %w{ ant bear cat}.any? {|word| word.length >= 3} #=> true
* %w{ ant bear cat}.any? {|word| word.length >= 4} #=> true
* [ nil, true, 99 ].any? #=> true
- *
+ *
*/
static VALUE
@@ -961,105 +601,6 @@ enum_any(obj)
}
static VALUE
-one_i(i, memo)
- VALUE i;
- VALUE *memo;
-{
- if (RTEST(i)) {
- if (*memo == Qundef) {
- *memo = Qtrue;
- }
- else if (*memo == Qtrue) {
- *memo = Qfalse;
- rb_iter_break();
- }
- }
- return Qnil;
-}
-
-static VALUE
-one_iter_i(i, memo)
- VALUE i;
- VALUE *memo;
-{
- return one_i(rb_yield(i), memo);
-}
-
-/*
- * call-seq:
- * enum.one? [{|obj| block }] => true or false
- *
- * Passes each element of the collection to the given block. The method
- * returns <code>true</code> if the block returns <code>true</code>
- * exactly once. If the block is not given, <code>one?</code> will return
- * <code>true</code> only if exactly one of the collection members is
- * true.
- *
- * %w{ant bear cat}.one? {|word| word.length == 4} #=> true
- * %w{ant bear cat}.one? {|word| word.length > 4} #=> false
- * %w{ant bear cat}.one? {|word| word.length < 4} #=> false
- * [ nil, true, 99 ].one? #=> false
- * [ nil, true, false ].one? #=> true
- *
- */
-
-static VALUE
-enum_one(obj)
- VALUE obj;
-{
- VALUE result = Qundef;
-
- rb_block_call(obj, id_each, 0, 0, rb_block_given_p() ? one_iter_i : one_i, (VALUE)&result);
- if (result == Qundef) return Qfalse;
- return result;
-}
-
-static VALUE
-none_i(i, memo)
- VALUE i;
- VALUE *memo;
-{
- if (RTEST(i)) {
- *memo = Qfalse;
- rb_iter_break();
- }
- return Qnil;
-}
-
-static VALUE
-none_iter_i(i, memo)
- VALUE i;
- VALUE *memo;
-{
- return none_i(rb_yield(i), memo);
-}
-
-/*
- * call-seq:
- * enum.none? [{|obj| block }] => true or false
- *
- * Passes each element of the collection to the given block. The method
- * returns <code>true</code> if the block never returns <code>true</code>
- * for all elements. If the block is not given, <code>none?</code> will return
- * <code>true</code> only if none of the collection members is true.
- *
- * %w{ant bear cat}.none? {|word| word.length == 5} #=> true
- * %w{ant bear cat}.none? {|word| word.length >= 4} #=> false
- * [].none? #=> true
- * [nil].none? #=> true
- * [nil,false].none? #=> true
- */
-static VALUE
-enum_none(obj)
- VALUE obj;
-{
- VALUE result = Qtrue;
-
- rb_block_call(obj, id_each, 0, 0, rb_block_given_p() ? none_iter_i : none_i, (VALUE)&result);
- return result;
-}
-
-static VALUE
min_i(i, memo)
VALUE i;
VALUE *memo;
@@ -1102,11 +643,11 @@ min_ii(i, memo)
* call-seq:
* enum.min => obj
* enum.min {| a,b | block } => obj
- *
+ *
* Returns the object in <i>enum</i> with the minimum value. The
* first form assumes all objects implement <code>Comparable</code>;
* the second uses the block to return <em>a <=> b</em>.
- *
+ *
* a = %w(albatross dog horse)
* a.min #=> "albatross"
* a.min {|a,b| a.length <=> b.length } #=> "dog"
@@ -1127,11 +668,11 @@ enum_min(obj)
* call-seq:
* enum.max => obj
* enum.max {| a,b | block } => obj
- *
+ *
* Returns the object in <i>enum</i> with the maximum value. The
* first form assumes all objects implement <code>Comparable</code>;
* the second uses the block to return <em>a <=> b</em>.
- *
+ *
* a = %w(albatross dog horse)
* a.max #=> "horse"
* a.max {|a,b| a.length <=> b.length } #=> "albatross"
@@ -1179,15 +720,15 @@ max_ii(i, memo)
* call-seq:
* enum.max => obj
* enum.max {|a,b| block } => obj
- *
+ *
* Returns the object in _enum_ with the maximum value. The
* first form assumes all objects implement <code>Comparable</code>;
* the second uses the block to return <em>a <=> b</em>.
- *
+ *
* a = %w(albatross dog horse)
* a.max #=> "horse"
* a.max {|a,b| a.length <=> b.length } #=> "albatross"
- */
+ */
static VALUE
enum_max(obj)
@@ -1201,240 +742,6 @@ enum_max(obj)
}
static VALUE
-minmax_i(i, memo)
- VALUE i;
- VALUE *memo;
-{
- int n;
-
- if (memo[0] == Qundef) {
- memo[0] = i;
- memo[1] = i;
- }
- else {
- n = rb_cmpint(rb_funcall(i, id_cmp, 1, memo[0]), i, memo[0]);
- if (n < 0) {
- memo[0] = i;
- }
- n = rb_cmpint(rb_funcall(i, id_cmp, 1, memo[1]), i, memo[1]);
- if (n > 0) {
- memo[1] = i;
- }
- }
- return Qnil;
-}
-
-static VALUE
-minmax_ii(i, memo)
- VALUE i;
- VALUE *memo;
-{
- int n;
-
- if (memo[0] == Qundef) {
- memo[0] = i;
- memo[1] = i;
- }
- else {
- VALUE ary = memo[2];
-
- RARRAY(ary)->ptr[0] = i;
- RARRAY(ary)->ptr[1] = memo[0];
- n = rb_cmpint(rb_yield(ary), i, memo[0]);
- if (n < 0) {
- memo[0] = i;
- }
- RARRAY(ary)->ptr[0] = i;
- RARRAY(ary)->ptr[1] = memo[1];
- n = rb_cmpint(rb_yield(ary), i, memo[1]);
- if (n > 0) {
- memo[1] = i;
- }
- }
- return Qnil;
-}
-
-/*
- * call-seq:
- * enum.minmax => [min,max]
- * enum.minmax {|a,b| block } => [min,max]
- *
- * Returns two elements array which contains the minimum and the
- * maximum value in the enumerable. The first form assumes all
- * objects implement <code>Comparable</code>; the second uses the
- * block to return <em>a <=> b</em>.
- *
- * a = %w(albatross dog horse)
- * a.minmax #=> ["albatross", "horse"]
- * a.minmax {|a,b| a.length <=> b.length } #=> ["dog", "albatross"]
- */
-
-static VALUE
-enum_minmax(obj)
- VALUE obj;
-{
- VALUE result[3];
- VALUE ary = rb_ary_new3(2, Qnil, Qnil);
-
- result[0] = Qundef;
- if (rb_block_given_p()) {
- result[2] = ary;
- rb_block_call(obj, id_each, 0, 0, minmax_ii, (VALUE)result);
- }
- else {
- rb_block_call(obj, id_each, 0, 0, minmax_i, (VALUE)result);
- }
- if (result[0] != Qundef) {
- RARRAY(ary)->ptr[0] = result[0];
- RARRAY(ary)->ptr[1] = result[1];
- }
- return ary;
-}
-
-static VALUE
-min_by_i(i, memo)
- VALUE i;
- VALUE *memo;
-{
- VALUE v;
-
- v = rb_yield(i);
- if (memo[0] == Qundef) {
- memo[0] = v;
- memo[1] = i;
- }
- else if (rb_cmpint(rb_funcall(v, id_cmp, 1, memo[0]), v, memo[0]) < 0) {
- memo[0] = v;
- memo[1] = i;
- }
- return Qnil;
-}
-
-/*
- * call-seq:
- * enum.min_by {| obj| block } => obj
- *
- * Returns the object in <i>enum</i> that gives the minimum
- * value from the given block.
- *
- * a = %w(albatross dog horse)
- * a.min_by {|x| x.length } #=> "dog"
- */
-
-static VALUE
-enum_min_by(obj)
- VALUE obj;
-{
- VALUE memo[2];
-
- RETURN_ENUMERATOR(obj, 0, 0);
-
- memo[0] = Qundef;
- memo[1] = Qnil;
- rb_block_call(obj, id_each, 0, 0, min_by_i, (VALUE)memo);
- return memo[1];
-}
-
-static VALUE
-max_by_i(i, memo)
- VALUE i;
- VALUE *memo;
-{
- VALUE v;
-
- v = rb_yield(i);
- if (memo[0] == Qundef) {
- memo[0] = v;
- memo[1] = i;
- }
- else if (rb_cmpint(rb_funcall(v, id_cmp, 1, memo[0]), v, memo[0]) > 0) {
- memo[0] = v;
- memo[1] = i;
- }
- return Qnil;
-}
-
-/*
- * call-seq:
- * enum.max_by {| obj| block } => obj
- *
- * Returns the object in <i>enum</i> that gives the maximum
- * value from the given block.
- *
- * a = %w(albatross dog horse)
- * a.max_by {|x| x.length } #=> "albatross"
- */
-
-static VALUE
-enum_max_by(obj)
- VALUE obj;
-{
- VALUE memo[2];
-
- RETURN_ENUMERATOR(obj, 0, 0);
-
- memo[0] = Qundef;
- memo[1] = Qnil;
- rb_block_call(obj, id_each, 0, 0, max_by_i, (VALUE)memo);
- return memo[1];
-}
-
-static VALUE
-minmax_by_i(i, memo)
- VALUE i;
- VALUE *memo;
-{
- VALUE v;
-
- v = rb_yield(i);
- if (memo[0] == Qundef) {
- memo[0] = v;
- memo[1] = v;
- memo[2] = i;
- memo[3] = i;
- }
- else {
- if (rb_cmpint(rb_funcall(v, id_cmp, 1, memo[0]), v, memo[0]) < 0) {
- memo[0] = v;
- memo[2] = i;
- }
- if (rb_cmpint(rb_funcall(v, id_cmp, 1, memo[1]), v, memo[1]) > 0) {
- memo[1] = v;
- memo[3] = i;
- }
- }
- return Qnil;
-}
-
-/*
- * call-seq:
- * enum.minmax_by {| obj| block } => [min, max]
- *
- * Returns two elements array array containing the objects in
- * <i>enum</i> that gives the minimum and maximum values respectively
- * from the given block.
- *
- * a = %w(albatross dog horse)
- * a.minmax_by {|x| x.length } #=> ["dog", "albatross"]
- */
-
-static VALUE
-enum_minmax_by(obj)
- VALUE obj;
-{
- VALUE memo[4];
-
- RETURN_ENUMERATOR(obj, 0, 0);
-
- memo[0] = Qundef;
- memo[1] = Qundef;
- memo[2] = Qnil;
- memo[3] = Qnil;
- rb_block_call(obj, id_each, 0, 0, minmax_by_i, (VALUE)memo);
- return rb_assoc_new(memo[2], memo[3]);
-}
-
-static VALUE
member_i(item, memo)
VALUE item;
VALUE *memo;
@@ -1450,13 +757,13 @@ member_i(item, memo)
* call-seq:
* enum.include?(obj) => true or false
* enum.member?(obj) => true or false
- *
+ *
* Returns <code>true</code> if any member of <i>enum</i> equals
* <i>obj</i>. Equality is tested using <code>==</code>.
- *
+ *
* IO.constants.include? "SEEK_SET" #=> true
* IO.constants.include? "SEEK_NO_FURTHER" #=> false
- *
+ *
*/
static VALUE
@@ -1484,56 +791,29 @@ each_with_index_i(val, memo)
/*
* call-seq:
* enum.each_with_index {|obj, i| block } -> enum
- *
+ *
* Calls <em>block</em> with two arguments, the item and its index, for
* each item in <i>enum</i>.
- *
+ *
* hash = Hash.new
* %w(cat dog wombat).each_with_index {|item, index|
* hash[item] = index
* }
* hash #=> {"cat"=>0, "wombat"=>2, "dog"=>1}
- *
+ *
*/
static VALUE
enum_each_with_index(obj)
VALUE obj;
{
- VALUE memo;
+ VALUE memo = 0;
- RETURN_ENUMERATOR(obj, 0, 0);
-
- memo = 0;
+ rb_need_block();
rb_iterate(rb_each, obj, each_with_index_i, (VALUE)&memo);
return obj;
}
-/*
- * call-seq:
- * enum.reverse_each {|item| block }
- *
- * Traverses <i>enum</i> in reverse order.
- */
-
-static VALUE
-enum_reverse_each(int argc, VALUE *argv, VALUE obj)
-{
- VALUE ary;
- long i;
-
- RETURN_ENUMERATOR(obj, argc, argv);
-
- ary = enum_to_a(argc, argv, obj);
-
- for (i = RARRAY_LEN(ary); --i >= 0; ) {
- rb_yield(RARRAY_PTR(ary)[i]);
- }
-
- return obj;
-}
-
-
static VALUE
zip_i(val, memo)
VALUE val;
@@ -1563,7 +843,7 @@ zip_i(val, memo)
* call-seq:
* enum.zip(arg, ...) => array
* enum.zip(arg, ...) {|arr| block } => nil
- *
+ *
* Converts any arguments to arrays, then merges elements of
* <i>enum</i> with corresponding elements from each argument. This
* generates a sequence of <code>enum#size</code> <em>n</em>-element
@@ -1572,14 +852,14 @@ zip_i(val, memo)
* <code>nil</code> values are supplied. If a block given, it is
* invoked for each output array, otherwise an array of arrays is
* returned.
- *
+ *
* a = [ 4, 5, 6 ]
* b = [ 7, 8, 9 ]
- *
+ *
* (1..3).zip(a, b) #=> [[1, 4, 7], [2, 5, 8], [3, 6, 9]]
* "cat\ndog".zip([1]) #=> [["cat\n", 1], ["dog", nil]]
* (1..3).zip #=> [[1], [2], [3]]
- *
+ *
*/
static VALUE
@@ -1604,227 +884,6 @@ enum_zip(argc, argv, obj)
return result;
}
-static VALUE
-take_i(i, arg)
- VALUE i;
- VALUE *arg;
-{
- if (arg[1]-- == 0) rb_iter_break();
- rb_ary_push(arg[0], i);
- return Qnil;
-}
-
-/*
- * call-seq:
- * enum.take(n) => array
- *
- * Returns first n elements from <i>enum</i>.
- *
- * a = [1, 2, 3, 4, 5, 0]
- * a.take(3) # => [1, 2, 3]
- *
- */
-
-static VALUE
-enum_take(obj, n)
- VALUE obj;
- VALUE n;
-{
- VALUE args[2];
- long len = NUM2LONG(n);
-
- if (len < 0) {
- rb_raise(rb_eArgError, "attempt to take negative size");
- }
-
- args[1] = len;
- args[0] = rb_ary_new();
- rb_block_call(obj, id_each, 0, 0, take_i, (VALUE)args);
- return args[0];
-}
-
-
-static VALUE
-take_while_i(i, ary)
- VALUE i;
- VALUE *ary;
-{
- if (!RTEST(rb_yield(i))) rb_iter_break();
- rb_ary_push(*ary, i);
- return Qnil;
-}
-
-/*
- * call-seq:
- * enum.take_while {|arr| block } => array
- *
- * Passes elements to the block until the block returns nil or false,
- * then stops iterating and returns an array of all prior elements.
- *
- * a = [1, 2, 3, 4, 5, 0]
- * a.take_while {|i| i < 3 } # => [1, 2]
- *
- */
-
-static VALUE
-enum_take_while(obj)
- VALUE obj;
-{
- VALUE ary;
-
- RETURN_ENUMERATOR(obj, 0, 0);
- ary = rb_ary_new();
- rb_block_call(obj, id_each, 0, 0, take_while_i, (VALUE)&ary);
- return ary;
-}
-
-static VALUE
-drop_i(i, arg)
- VALUE i;
- VALUE *arg;
-{
- if (arg[1] == 0) {
- rb_ary_push(arg[0], i);
- }
- else {
- arg[1]--;
- }
- return Qnil;
-}
-
-/*
- * call-seq:
- * enum.drop(n) => array
- *
- * Drops first n elements from <i>enum</i>, and returns rest elements
- * in an array.
- *
- * a = [1, 2, 3, 4, 5, 0]
- * a.drop(3) # => [4, 5, 0]
- *
- */
-
-static VALUE
-enum_drop(obj, n)
- VALUE obj;
- VALUE n;
-{
- VALUE args[2];
- long len = NUM2LONG(n);
-
- if (len < 0) {
- rb_raise(rb_eArgError, "attempt to drop negative size");
- }
-
- args[1] = len;
- args[0] = rb_ary_new();
- rb_block_call(obj, id_each, 0, 0, drop_i, (VALUE)args);
- return args[0];
-}
-
-
-static VALUE
-drop_while_i(i, args)
- VALUE i;
- VALUE *args;
-{
- if (!args[1] && !RTEST(rb_yield(i))) {
- args[1] = Qtrue;
- }
- if (args[1]) {
- rb_ary_push(args[0], i);
- }
- return Qnil;
-}
-
-/*
- * call-seq:
- * enum.drop_while {|arr| block } => array
- *
- * Drops elements up to, but not including, the first element for
- * which the block returns nil or false and returns an array
- * containing the remaining elements.
- *
- * a = [1, 2, 3, 4, 5, 0]
- * a.drop_while {|i| i < 3 } # => [3, 4, 5, 0]
- *
- */
-
-static VALUE
-enum_drop_while(obj)
- VALUE obj;
-{
- VALUE args[2];
-
- RETURN_ENUMERATOR(obj, 0, 0);
- args[0] = rb_ary_new();
- args[1] = Qfalse;
- rb_block_call(obj, id_each, 0, 0, drop_while_i, (VALUE)args);
- return args[0];
-}
-
-static VALUE
-cycle_i(i, ary)
- VALUE i;
- VALUE ary;
-{
- rb_ary_push(ary, i);
- rb_yield(i);
- return Qnil;
-}
-
-/*
- * call-seq:
- * enum.cycle {|obj| block }
- * enum.cycle(n) {|obj| block }
- *
- * Calls <i>block</i> for each element of <i>enum</i> repeatedly _n_
- * times or forever if none or nil is given. If a non-positive
- * number is given or the collection is empty, does nothing. Returns
- * nil if the loop has finished without getting interrupted.
- *
- * Enumerable#cycle saves elements in an internal array so changes
- * to <i>enum</i> after the first pass have no effect.
- *
- * a = ["a", "b", "c"]
- * a.cycle {|x| puts x } # print, a, b, c, a, b, c,.. forever.
- * a.cycle(2) {|x| puts x } # print, a, b, c, a, b, c.
- *
- */
-
-static VALUE
-enum_cycle(argc, argv, obj)
- int argc;
- VALUE *argv;
- VALUE obj;
-{
- VALUE ary;
- VALUE nv = Qnil;
- long n, i, len;
-
- rb_scan_args(argc, argv, "01", &nv);
-
- RETURN_ENUMERATOR(obj, argc, argv);
- if (NIL_P(nv)) {
- n = -1;
- }
- else {
- n = NUM2LONG(nv);
- if (n <= 0) return Qnil;
- }
- ary = rb_ary_new();
- RBASIC(ary)->klass = 0;
- rb_block_call(obj, id_each, 0, 0, cycle_i, ary);
- len = RARRAY(ary)->len;
- if (len == 0) return Qnil;
- while (n < 0 || 0 < --n) {
- for (i=0; i<len; i++) {
- rb_yield(RARRAY(ary)->ptr[i]);
- }
- }
- return Qnil; /* not reached */
-}
-
/*
* The <code>Enumerable</code> mixin provides collection classes with
* several traversal and searching methods, and with the ability to
@@ -1841,51 +900,32 @@ Init_Enumerable()
{
rb_mEnumerable = rb_define_module("Enumerable");
- rb_define_method(rb_mEnumerable, "to_a", enum_to_a, -1);
- rb_define_method(rb_mEnumerable, "entries", enum_to_a, -1);
-
- rb_define_method(rb_mEnumerable, "sort", enum_sort, 0);
- rb_define_method(rb_mEnumerable, "sort_by", enum_sort_by, 0);
- rb_define_method(rb_mEnumerable, "grep", enum_grep, 1);
- rb_define_method(rb_mEnumerable, "count", enum_count, -1);
- rb_define_method(rb_mEnumerable, "find", enum_find, -1);
- rb_define_method(rb_mEnumerable, "detect", enum_find, -1);
- rb_define_method(rb_mEnumerable, "find_index", enum_find_index, -1);
- rb_define_method(rb_mEnumerable, "find_all", enum_find_all, 0);
- rb_define_method(rb_mEnumerable, "select", enum_find_all, 0);
- rb_define_method(rb_mEnumerable, "reject", enum_reject, 0);
- rb_define_method(rb_mEnumerable, "collect", enum_collect, 0);
- rb_define_method(rb_mEnumerable, "map", enum_collect, 0);
- rb_define_method(rb_mEnumerable, "inject", enum_inject, -1);
- rb_define_method(rb_mEnumerable, "reduce", enum_inject, -1);
- rb_define_method(rb_mEnumerable, "partition", enum_partition, 0);
- rb_define_method(rb_mEnumerable, "group_by", enum_group_by, 0);
- rb_define_method(rb_mEnumerable, "first", enum_first, -1);
- rb_define_method(rb_mEnumerable, "all?", enum_all, 0);
- rb_define_method(rb_mEnumerable, "any?", enum_any, 0);
- rb_define_method(rb_mEnumerable, "one?", enum_one, 0);
- rb_define_method(rb_mEnumerable, "none?", enum_none, 0);
- rb_define_method(rb_mEnumerable, "min", enum_min, 0);
- rb_define_method(rb_mEnumerable, "max", enum_max, 0);
- rb_define_method(rb_mEnumerable, "minmax", enum_minmax, 0);
- rb_define_method(rb_mEnumerable, "min_by", enum_min_by, 0);
- rb_define_method(rb_mEnumerable, "max_by", enum_max_by, 0);
- rb_define_method(rb_mEnumerable, "minmax_by", enum_minmax_by, 0);
- rb_define_method(rb_mEnumerable, "member?", enum_member, 1);
- rb_define_method(rb_mEnumerable, "include?", enum_member, 1);
- rb_define_method(rb_mEnumerable, "each_with_index", enum_each_with_index, 0);
- rb_define_method(rb_mEnumerable, "enum_with_index", enum_each_with_index, 0);
- rb_define_method(rb_mEnumerable, "reverse_each", enum_reverse_each, -1);
+ rb_define_method(rb_mEnumerable,"to_a", enum_to_a, 0);
+ rb_define_method(rb_mEnumerable,"entries", enum_to_a, 0);
+
+ rb_define_method(rb_mEnumerable,"sort", enum_sort, 0);
+ rb_define_method(rb_mEnumerable,"sort_by", enum_sort_by, 0);
+ rb_define_method(rb_mEnumerable,"grep", enum_grep, 1);
+ rb_define_method(rb_mEnumerable,"find", enum_find, -1);
+ rb_define_method(rb_mEnumerable,"detect", enum_find, -1);
+ rb_define_method(rb_mEnumerable,"find_all", enum_find_all, 0);
+ rb_define_method(rb_mEnumerable,"select", enum_find_all, 0);
+ rb_define_method(rb_mEnumerable,"reject", enum_reject, 0);
+ rb_define_method(rb_mEnumerable,"collect", enum_collect, 0);
+ rb_define_method(rb_mEnumerable,"map", enum_collect, 0);
+ rb_define_method(rb_mEnumerable,"inject", enum_inject, -1);
+ rb_define_method(rb_mEnumerable,"partition", enum_partition, 0);
+ rb_define_method(rb_mEnumerable,"all?", enum_all, 0);
+ rb_define_method(rb_mEnumerable,"any?", enum_any, 0);
+ rb_define_method(rb_mEnumerable,"min", enum_min, 0);
+ rb_define_method(rb_mEnumerable,"max", enum_max, 0);
+ rb_define_method(rb_mEnumerable,"member?", enum_member, 1);
+ rb_define_method(rb_mEnumerable,"include?", enum_member, 1);
+ rb_define_method(rb_mEnumerable,"each_with_index", enum_each_with_index, 0);
rb_define_method(rb_mEnumerable, "zip", enum_zip, -1);
- rb_define_method(rb_mEnumerable, "take", enum_take, 1);
- rb_define_method(rb_mEnumerable, "take_while", enum_take_while, 0);
- rb_define_method(rb_mEnumerable, "drop", enum_drop, 1);
- rb_define_method(rb_mEnumerable, "drop_while", enum_drop_while, 0);
- rb_define_method(rb_mEnumerable, "cycle", enum_cycle, -1);
id_eqq = rb_intern("===");
id_each = rb_intern("each");
id_cmp = rb_intern("<=>");
- id_size = rb_intern("size");
}
diff --git a/enumerator.c b/enumerator.c
deleted file mode 100644
index f95d931b62..0000000000
--- a/enumerator.c
+++ /dev/null
@@ -1,450 +0,0 @@
-/************************************************
-
- enumerator.c - provides Enumerator class
-
- $Author$
-
- Copyright (C) 2001-2003 Akinori MUSHA
-
- $Idaemons: /home/cvs/rb/enumerator/enumerator.c,v 1.1.1.1 2001/07/15 10:12:48 knu Exp $
- $RoughId: enumerator.c,v 1.6 2003/07/27 11:03:24 nobu Exp $
- $Id$
-
-************************************************/
-
-#include "ruby.h"
-
-/*
- * Document-class: Enumerable::Enumerator
- *
- * A class which provides a method `each' to be used as an Enumerable
- * object.
- */
-VALUE rb_cEnumerator;
-static VALUE sym_each;
-
-VALUE rb_eStopIteration;
-
-struct enumerator {
- VALUE obj;
- ID meth;
- VALUE proc;
- VALUE args;
- rb_block_call_func *iter;
-};
-
-static void enumerator_mark _((void *));
-static void
-enumerator_mark(p)
- void *p;
-{
- struct enumerator *ptr = p;
- rb_gc_mark(ptr->obj);
- rb_gc_mark(ptr->args);
-}
-
-static struct enumerator *
-enumerator_ptr(obj)
- VALUE obj;
-{
- struct enumerator *ptr;
-
- Data_Get_Struct(obj, struct enumerator, ptr);
- if (RDATA(obj)->dmark != enumerator_mark) {
- rb_raise(rb_eTypeError,
- "wrong argument type %s (expected Enumerable::Enumerator)",
- rb_obj_classname(obj));
- }
- if (!ptr || ptr->obj == Qundef) {
- rb_raise(rb_eArgError, "uninitialized enumerator");
- }
- return ptr;
-}
-
-/*
- * call-seq:
- * obj.to_enum(method = :each, *args)
- * obj.enum_for(method = :each, *args)
- *
- * Returns Enumerable::Enumerator.new(self, method, *args).
- *
- * e.g.:
- *
- * str = "xyz"
- *
- * enum = str.enum_for(:each_byte)
- * a = enum.map {|b| '%02x' % b } #=> ["78", "79", "7a"]
- *
- * # protects an array from being modified
- * a = [1, 2, 3]
- * some_method(a.to_enum)
- *
- */
-static VALUE
-obj_to_enum(argc, argv, obj)
- int argc;
- VALUE *argv;
- VALUE obj;
-{
- VALUE meth = sym_each;
-
- if (argc > 0) {
- --argc;
- meth = *argv++;
- }
- return rb_enumeratorize(obj, meth, argc, argv);
-}
-
-static VALUE
-each_slice_i(val, memo)
- VALUE val;
- VALUE *memo;
-{
- VALUE ary = memo[0];
- VALUE v = Qnil;
- long size = (long)memo[1];
-
- rb_ary_push(ary, val);
-
- if (RARRAY_LEN(ary) == size) {
- v = rb_yield(ary);
- memo[0] = rb_ary_new2(size);
- }
-
- return v;
-}
-
-/*
- * call-seq:
- * e.each_slice(n) {...}
- * e.each_slice(n)
- *
- * Iterates the given block for each slice of <n> elements. If no
- * block is given, returns an enumerator.
- *
- * e.g.:
- * (1..10).each_slice(3) {|a| p a}
- * # outputs below
- * [1, 2, 3]
- * [4, 5, 6]
- * [7, 8, 9]
- * [10]
- *
- */
-static VALUE
-enum_each_slice(obj, n)
- VALUE obj, n;
-{
- long size = NUM2LONG(n);
- VALUE args[2], ary;
-
- if (size <= 0) rb_raise(rb_eArgError, "invalid slice size");
- RETURN_ENUMERATOR(obj, 1, &n);
- args[0] = rb_ary_new2(size);
- args[1] = (VALUE)size;
-
- rb_block_call(obj, SYM2ID(sym_each), 0, 0, each_slice_i, (VALUE)args);
-
- ary = args[0];
- if (RARRAY_LEN(ary) > 0) rb_yield(ary);
-
- return Qnil;
-}
-
-static VALUE
-each_cons_i(val, memo)
- VALUE val;
- VALUE *memo;
-{
- VALUE ary = memo[0];
- VALUE v = Qnil;
- long size = (long)memo[1];
-
- if (RARRAY_LEN(ary) == size) {
- rb_ary_shift(ary);
- }
- rb_ary_push(ary, val);
- if (RARRAY_LEN(ary) == size) {
- v = rb_yield(rb_ary_dup(ary));
- }
- return v;
-}
-
-/*
- * call-seq:
- * each_cons(n) {...}
- * each_cons(n)
- *
- * Iterates the given block for each array of consecutive <n>
- * elements. If no block is given, returns an enumerator.a
- *
- * e.g.:
- * (1..10).each_cons(3) {|a| p a}
- * # outputs below
- * [1, 2, 3]
- * [2, 3, 4]
- * [3, 4, 5]
- * [4, 5, 6]
- * [5, 6, 7]
- * [6, 7, 8]
- * [7, 8, 9]
- * [8, 9, 10]
- *
- */
-static VALUE
-enum_each_cons(obj, n)
- VALUE obj, n;
-{
- long size = NUM2LONG(n);
- VALUE args[2];
-
- if (size <= 0) rb_raise(rb_eArgError, "invalid size");
- RETURN_ENUMERATOR(obj, 1, &n);
- args[0] = rb_ary_new2(size);
- args[1] = (VALUE)size;
-
- rb_block_call(obj, SYM2ID(sym_each), 0, 0, each_cons_i, (VALUE)args);
-
- return Qnil;
-}
-
-static VALUE enumerator_allocate _((VALUE));
-static VALUE
-enumerator_allocate(klass)
- VALUE klass;
-{
- struct enumerator *ptr;
- VALUE enum_obj;
-
- enum_obj = Data_Make_Struct(klass, struct enumerator,
- enumerator_mark, -1, ptr);
- ptr->obj = Qundef;
-
- return enum_obj;
-}
-
-static VALUE enumerator_each_i _((VALUE, VALUE));
-static VALUE
-enumerator_each_i(v, enum_obj)
- VALUE v;
- VALUE enum_obj;
-{
- return rb_yield(v);
-}
-
-static VALUE
-enumerator_init(enum_obj, obj, meth, argc, argv)
- VALUE enum_obj;
- VALUE obj;
- VALUE meth;
- int argc;
- VALUE *argv;
-{
- struct enumerator *ptr;
-
- Data_Get_Struct(enum_obj, struct enumerator, ptr);
-
- if (!ptr) {
- rb_raise(rb_eArgError, "unallocated enumerator");
- }
-
- ptr->obj = obj;
- ptr->meth = rb_to_id(meth);
- ptr->iter = enumerator_each_i;
- if (argc) ptr->args = rb_ary_new4(argc, argv);
-
- return enum_obj;
-}
-
-/*
- * call-seq:
- * Enumerable::Enumerator.new(obj, method = :each, *args)
- *
- * Creates a new Enumerable::Enumerator object, which is to be
- * used as an Enumerable object using the given object's given
- * method with the given arguments.
- *
- * Use of this method is discouraged. Use Kernel#enum_for() instead.
- */
-static VALUE
-enumerator_initialize(argc, argv, obj)
- int argc;
- VALUE *argv;
- VALUE obj;
-{
- VALUE recv, meth = sym_each;
-
- if (argc == 0)
- rb_raise(rb_eArgError, "wrong number of argument (0 for 1)");
- recv = *argv++;
- if (--argc) {
- meth = *argv++;
- --argc;
- }
- return enumerator_init(obj, recv, meth, argc, argv);
-}
-
-/* :nodoc: */
-static VALUE
-enumerator_init_copy(obj, orig)
- VALUE obj;
- VALUE orig;
-{
- struct enumerator *ptr0, *ptr1;
-
- ptr0 = enumerator_ptr(orig);
-
- Data_Get_Struct(obj, struct enumerator, ptr1);
-
- if (!ptr1) {
- rb_raise(rb_eArgError, "unallocated enumerator");
- }
-
- ptr1->obj = ptr0->obj;
- ptr1->meth = ptr0->meth;
- ptr1->iter = ptr0->iter;
- ptr1->args = ptr0->args;
-
- return obj;
-}
-
-VALUE
-rb_enumeratorize(obj, meth, argc, argv)
- VALUE obj;
- VALUE meth;
- int argc;
- VALUE *argv;
-{
- return enumerator_init(enumerator_allocate(rb_cEnumerator), obj, meth, argc, argv);
-}
-
-/*
- * call-seq:
- * enum.each {...}
- *
- * Iterates the given block using the object and the method specified
- * in the first place. If no block is given, returns self.
- *
- */
-static VALUE
-enumerator_each(obj)
- VALUE obj;
-{
- struct enumerator *e;
- int argc = 0;
- VALUE *argv = 0;
-
- if (!rb_block_given_p()) return obj;
- e = enumerator_ptr(obj);
- if (e->args) {
- argc = RARRAY_LEN(e->args);
- argv = RARRAY_PTR(e->args);
- }
- return rb_block_call(e->obj, e->meth, argc, argv, e->iter, (VALUE)e);
-}
-
-static VALUE
-enumerator_with_index_i(val, memo)
- VALUE val;
- VALUE *memo;
-{
- val = rb_yield_values(2, val, INT2FIX(*memo));
- ++*memo;
- return val;
-}
-
-/*
- * call-seq:
- * e.with_index {|(*args), idx| ... }
- * e.with_index
- *
- * Iterates the given block for each elements with an index, which
- * start from 0. If no block is given, returns an enumerator.
- *
- */
-static VALUE
-enumerator_with_index(obj)
- VALUE obj;
-{
- struct enumerator *e = enumerator_ptr(obj);
- VALUE memo = 0;
- int argc = 0;
- VALUE *argv = 0;
-
- RETURN_ENUMERATOR(obj, 0, 0);
- if (e->args) {
- argc = RARRAY_LEN(e->args);
- argv = RARRAY_PTR(e->args);
- }
- return rb_block_call(e->obj, e->meth, argc, argv,
- enumerator_with_index_i, (VALUE)&memo);
-}
-
-/*
- * call-seq:
- * e.next => object
- *
- * Returns the next object in the enumerator, and move the internal
- * position forward. When the position reached at the end, internal
- * position is rewinded then StopIteration is raised.
- *
- * Note that enumeration sequence by next method does not affect other
- * non-external enumeration methods, unless underlying iteration
- * methods itself has side-effect, e.g. IO#each_line.
- *
- * Caution: Calling this method causes the "generator" library to be
- * loaded.
- */
-
-static VALUE
-enumerator_next(obj)
- VALUE obj;
-{
- rb_require("generator");
- return rb_funcall(obj, rb_intern("next"), 0, 0);
-}
-
-/*
- * call-seq:
- * e.rewind => e
- *
- * Rewinds the enumeration sequence by the next method.
- */
-
-static VALUE
-enumerator_rewind(obj)
- VALUE obj;
-{
- rb_require("generator");
- return rb_funcall(obj, rb_intern("rewind"), 0, 0);
-}
-
-void
-Init_Enumerator()
-{
- rb_define_method(rb_mKernel, "to_enum", obj_to_enum, -1);
- rb_define_method(rb_mKernel, "enum_for", obj_to_enum, -1);
-
- rb_define_method(rb_mEnumerable, "each_slice", enum_each_slice, 1);
- rb_define_method(rb_mEnumerable, "enum_slice", enum_each_slice, 1);
- rb_define_method(rb_mEnumerable, "each_cons", enum_each_cons, 1);
- rb_define_method(rb_mEnumerable, "enum_cons", enum_each_cons, 1);
-
- rb_cEnumerator = rb_define_class_under(rb_mEnumerable, "Enumerator", rb_cObject);
- rb_include_module(rb_cEnumerator, rb_mEnumerable);
-
- rb_define_alloc_func(rb_cEnumerator, enumerator_allocate);
- rb_define_method(rb_cEnumerator, "initialize", enumerator_initialize, -1);
- rb_define_method(rb_cEnumerator, "initialize_copy", enumerator_init_copy, 1);
- rb_define_method(rb_cEnumerator, "each", enumerator_each, 0);
- rb_define_method(rb_cEnumerator, "each_with_index", enumerator_with_index, 0);
- rb_define_method(rb_cEnumerator, "with_index", enumerator_with_index, 0);
- rb_define_method(rb_cEnumerator, "next", enumerator_next, 0);
- rb_define_method(rb_cEnumerator, "rewind", enumerator_rewind, 0);
-
- rb_eStopIteration = rb_define_class("StopIteration", rb_eIndexError);
-
- sym_each = ID2SYM(rb_intern("each"));
-
- rb_provide("enumerator.so"); /* for backward compatibility */
-}
diff --git a/env.h b/env.h
index c50103f71e..196090f387 100644
--- a/env.h
+++ b/env.h
@@ -2,8 +2,8 @@
env.h -
- $Author$
- $Date$
+ $Author: matz $
+ $Date: 2006/02/13 09:10:55 $
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 a991f55e57..6ebc927853 100644
--- a/error.c
+++ b/error.c
@@ -2,8 +2,8 @@
error.c -
- $Author$
- $Date$
+ $Author: matz $
+ $Date: 2006/07/20 07:04:13 $
created at: Mon Aug 9 16:11:34 JST 1993
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -29,7 +29,7 @@
#define EXIT_SUCCESS 0
#endif
-extern const char *ruby_description;
+extern const char ruby_version[], ruby_release_date[], ruby_platform[];
int ruby_nerrs;
@@ -208,7 +208,8 @@ rb_bug(fmt, va_alist)
va_init_list(args, fmt);
vfprintf(out, fmt, args);
va_end(args);
- fprintf(out, "\n%s\n\n", ruby_description);
+ fprintf(out, "\nruby %s (%s) [%s]\n\n",
+ ruby_version, ruby_release_date, ruby_platform);
}
abort();
}
@@ -257,7 +258,7 @@ rb_check_type(x, t)
if (TYPE(x) != t) {
while (type->type >= 0) {
if (type->type == t) {
- const char *etype;
+ char *etype;
if (NIL_P(x)) {
etype = "nil";
@@ -333,7 +334,7 @@ rb_exc_new3(etype, str)
VALUE etype, str;
{
StringValue(str);
- return rb_funcall(etype, rb_intern("new"), 1, str);
+ return rb_exc_new(etype, RSTRING(str)->ptr, RSTRING(str)->len);
}
/*
@@ -498,7 +499,7 @@ rb_check_backtrace(bt)
VALUE bt;
{
long i;
- static const char err[] = "backtrace must be Array of String";
+ static char *err = "backtrace must be Array of String";
if (!NIL_P(bt)) {
int t = TYPE(bt);
@@ -727,7 +728,7 @@ name_err_mesg_to_str(obj)
mesg = ptr[0];
if (NIL_P(mesg)) return Qnil;
else {
- const char *desc = 0;
+ char *desc = 0;
VALUE d = 0, args[3];
obj = ptr[1];
@@ -881,7 +882,7 @@ syserr_initialize(argc, argv, self)
#if !defined(_WIN32) && !defined(__VMS)
char *strerror();
#endif
- const char *err;
+ char *err;
VALUE mesg, error;
VALUE klass = rb_obj_class(self);
@@ -951,16 +952,18 @@ syserr_eqq(self, exc)
VALUE self, exc;
{
VALUE num, e;
- ID en = rb_intern("errno");
- if (!rb_obj_is_kind_of(exc, rb_eSystemCallError)) {
- if (!rb_respond_to(exc, en)) return Qfalse;
- }
- else if (self == rb_eSystemCallError) return Qtrue;
+ if (!rb_obj_is_kind_of(exc, rb_eSystemCallError)) return Qfalse;
+ if (self == rb_eSystemCallError) return Qtrue;
- num = rb_attr_get(exc, en);
+ num = rb_attr_get(exc, rb_intern("errno"));
if (NIL_P(num)) {
- num = rb_funcall(exc, en, 0, 0);
+ VALUE klass = CLASS_OF(exc);
+
+ while (TYPE(klass) == T_ICLASS || FL_TEST(klass, FL_SINGLETON)) {
+ klass = (VALUE)RCLASS(klass)->super;
+ }
+ num = rb_const_get(klass, rb_intern("Errno"));
}
e = rb_const_get(self, rb_intern("Errno"));
if (FIXNUM_P(num) ? num == e : rb_equal(num, e))
diff --git a/eval.c b/eval.c
index bd90b4041f..3dc2eac856 100644
--- a/eval.c
+++ b/eval.c
@@ -2,8 +2,8 @@
eval.c -
- $Author$
- $Date$
+ $Author: shyouhei $
+ $Date: 2007/01/27 15:45:49 $
created at: Thu Jun 10 14:22:17 JST 1993
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -29,6 +29,11 @@
#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"
@@ -72,8 +77,6 @@ char *strrchr _((const char*,const char));
#include <unistd.h>
#endif
-#include <time.h>
-
#ifdef __BEOS__
#include <net/socket.h>
#endif
@@ -87,6 +90,10 @@ 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
@@ -188,18 +195,19 @@ 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(just_before_setjmp, j) ((j)->status = 0, \
- (just_before_setjmp), \
+# define ruby_setjmp(j) ((j)->status = 0, \
PRE_GETCONTEXT, \
getcontext(&(j)->context), \
POST_GETCONTEXT, \
(j)->status)
#else
-# define ruby_setjmp(just_before_setjmp, env) \
- ((just_before_setjmp), RUBY_SETJMP(env))
-# define ruby_longjmp(env,val) RUBY_LONGJMP(env,val)
-# ifdef __CYGWIN__
-int _setjmp(), _longjmp();
+typedef jmp_buf rb_jmpbuf_t;
+# if !defined(setjmp) && defined(HAVE__SETJMP)
+# define ruby_setjmp(env) _setjmp(env)
+# define ruby_longjmp(env,val) _longjmp(env,val)
+# else
+# define ruby_setjmp(env) setjmp(env)
+# define ruby_longjmp(env,val) longjmp(env,val)
# endif
#endif
@@ -242,8 +250,6 @@ 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:
@@ -469,16 +475,16 @@ search_method(klass, id, origin)
VALUE klass, *origin;
ID id;
{
- st_data_t body;
+ NODE *body;
if (!klass) return 0;
- while (!st_lookup(RCLASS(klass)->m_tbl, id, &body)) {
+ while (!st_lookup(RCLASS(klass)->m_tbl, id, (st_data_t *)&body)) {
klass = RCLASS(klass)->super;
if (!klass) return 0;
}
if (origin) *origin = klass;
- return (NODE *)body;
+ return body;
}
static NODE*
@@ -489,7 +495,7 @@ rb_get_method_body(klassp, idp, noexp)
{
ID id = *idp;
VALUE klass = *klassp;
- VALUE origin = 0;
+ VALUE origin;
NODE * volatile body;
struct cache_entry *ent;
@@ -557,8 +563,7 @@ remove_method(klass, mid)
VALUE klass;
ID mid;
{
- st_data_t data;
- NODE *body = 0;
+ NODE *body;
if (klass == rb_cObject) {
rb_secure(4);
@@ -570,11 +575,10 @@ 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, &data)) {
- body = (NODE *)data;
+ 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, &data);
+ st_delete(RCLASS(klass)->m_tbl, &mid, (st_data_t *)&body);
}
}
if (!body) {
@@ -760,7 +764,7 @@ static struct SCOPE *top_scope;
static unsigned long frame_unique = 0;
#define PUSH_FRAME() do { \
- volatile struct FRAME _frame; \
+ struct FRAME _frame; \
_frame.prev = ruby_frame; \
_frame.tmp = 0; \
_frame.node = ruby_current_node; \
@@ -1029,7 +1033,7 @@ static struct tag *prot_tag;
#define PROT_LAMBDA INT2FIX(2) /* 5 */
#define PROT_YIELD INT2FIX(3) /* 7 */
-#define EXEC_TAG() ruby_setjmp(((void)0), prot_tag->buf)
+#define EXEC_TAG() (FLUSH_REGISTER_WINDOWS, ruby_setjmp(prot_tag->buf))
#define JUMP_TAG(st) do { \
ruby_frame = prot_tag->frame; \
@@ -1057,15 +1061,15 @@ VALUE ruby_class;
static VALUE ruby_wrapper; /* security wrapper */
#define PUSH_CLASS(c) do { \
- volatile VALUE _class = ruby_class; \
+ VALUE _class = ruby_class; \
ruby_class = (c)
#define POP_CLASS() ruby_class = _class; \
} while (0)
-NODE *ruby_cref = 0;
-NODE *ruby_top_cref;
-#define PUSH_CREF(c) ruby_cref = NEW_CREF(c,ruby_cref)
+static NODE *ruby_cref = 0;
+static NODE *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
#define PUSH_SCOPE() do { \
@@ -1080,11 +1084,9 @@ NODE *ruby_top_cref;
ruby_scope = _scope; \
scope_vmode = SCOPE_PUBLIC
-rb_thread_t rb_curr_thread;
-rb_thread_t rb_main_thread;
-#define main_thread rb_main_thread
-#define curr_thread rb_curr_thread
-
+typedef struct thread * rb_thread_t;
+static rb_thread_t curr_thread = 0;
+static rb_thread_t main_thread;
static void scope_dup _((struct SCOPE *));
#define POP_SCOPE() \
@@ -1105,8 +1107,8 @@ static void scope_dup _((struct SCOPE *));
} while (0)
static VALUE rb_eval _((VALUE,NODE*));
-static VALUE eval _((VALUE,VALUE,VALUE,const char*,int));
-static NODE *compile _((VALUE, const char*, int));
+static VALUE eval _((VALUE,VALUE,VALUE,char*,int));
+static NODE *compile _((VALUE, char*, int));
static VALUE rb_yield_0 _((VALUE, VALUE, VALUE, int, int));
@@ -1115,9 +1117,8 @@ static VALUE rb_yield_0 _((VALUE, VALUE, VALUE, int, int));
#define YIELD_PUBLIC_DEF 4
#define YIELD_FUNC_AVALUE 1
#define YIELD_FUNC_SVALUE 2
-#define YIELD_FUNC_LAMBDA 3
-static VALUE rb_call _((VALUE,VALUE,ID,int,const VALUE*,int,VALUE));
+static VALUE rb_call _((VALUE,VALUE,ID,int,const VALUE*,int));
static VALUE module_setup _((VALUE,NODE*));
static VALUE massign _((VALUE,NODE*,VALUE,int));
@@ -1229,7 +1230,7 @@ error_print()
{
VALUE errat = Qnil; /* OK */
volatile VALUE eclass, e;
- const char *einfo;
+ char *einfo;
long elen;
if (NIL_P(ruby_errinfo)) return;
@@ -1290,7 +1291,7 @@ error_print()
long len = elen;
if (RSTRING(epath)->ptr[0] == '#') epath = 0;
- if ((tail = memchr(einfo, '\n', elen)) != 0) {
+ if (tail = memchr(einfo, '\n', elen)) {
len = tail - einfo;
tail++; /* skip newline */
}
@@ -1311,7 +1312,6 @@ error_print()
if (!NIL_P(errat)) {
long i;
struct RArray *ep = RARRAY(errat);
- int truncate = eclass == rb_eSysStackError;
#define TRACE_MAX (TRACE_HEAD+TRACE_TAIL+5)
#define TRACE_HEAD 8
@@ -1322,7 +1322,7 @@ error_print()
if (TYPE(ep->ptr[i]) == T_STRING) {
warn_printf("\tfrom %s\n", RSTRING(ep->ptr[i])->ptr);
}
- if (truncate && i == TRACE_HEAD && ep->len > TRACE_MAX) {
+ if (i == TRACE_HEAD && ep->len > TRACE_MAX) {
warn_printf("\t ... %ld levels...\n",
ep->len - TRACE_HEAD - TRACE_TAIL);
i = ep->len - TRACE_TAIL;
@@ -1400,8 +1400,8 @@ ruby_init()
rb_call_inits();
ruby_class = rb_cObject;
ruby_frame->self = ruby_top_self;
- ruby_top_cref = rb_node_newnode(NODE_CREF,rb_cObject,0,0);
- ruby_cref = ruby_top_cref;
+ top_cref = rb_node_newnode(NODE_CREF,rb_cObject,0,0);
+ ruby_cref = top_cref;
rb_define_global_const("TOPLEVEL_BINDING", rb_f_binding(ruby_top_self));
#ifdef __MACOS__
_macruby_init();
@@ -1440,12 +1440,11 @@ eval_node(self, node)
int ruby_in_eval;
-static int rb_thread_join _((rb_thread_t, double));
-
static void rb_thread_cleanup _((void));
static void rb_thread_wait_other_threads _((void));
-static int thread_no_ensure _((void));
+static int thread_set_raised();
+static int thread_reset_raised();
static VALUE exception_error;
static VALUE sysstack_error;
@@ -1463,10 +1462,8 @@ error_handle(ex)
int ex;
{
int status = EXIT_FAILURE;
- rb_thread_t th = curr_thread;
- if (rb_thread_set_raised(th))
- return EXIT_FAILURE;
+ if (thread_set_raised()) return EXIT_FAILURE;
switch (ex & TAG_MASK) {
case 0:
status = EXIT_SUCCESS;
@@ -1508,9 +1505,6 @@ 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();
}
@@ -1519,7 +1513,7 @@ error_handle(ex)
rb_bug("Unknown longjmp status %d", ex);
break;
}
- rb_thread_reset_raised(th);
+ thread_reset_raised();
return status;
}
@@ -1578,14 +1572,12 @@ ruby_cleanup(ex)
int ex;
{
int state;
- volatile VALUE errs[2];
- int nerr;
+ volatile VALUE err = ruby_errinfo;
- errs[1] = ruby_errinfo;
ruby_safe_level = 0;
- Init_stack((void *)&state);
+ Init_stack((void*)&state);
ruby_finalize_0();
- errs[0] = ruby_errinfo;
+ if (ruby_errinfo) err = ruby_errinfo;
PUSH_TAG(PROT_NONE);
PUSH_ITER(ITER_NOT);
if ((state = EXEC_TAG()) == 0) {
@@ -1596,39 +1588,15 @@ ruby_cleanup(ex)
ex = state;
}
POP_ITER();
- ruby_errinfo = errs[1];
+ ruby_errinfo = err;
ex = error_handle(ex);
ruby_finalize_1();
POP_TAG();
- for (nerr = 0; nerr < sizeof(errs) / sizeof(errs[0]); ++nerr) {
- VALUE err = errs[nerr];
-
- if (!RTEST(err)) 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));
- }
- else if (ex == 0) {
- ex = 1;
- }
- }
-
-#if EXIT_SUCCESS != 0 || EXIT_FAILURE != 1
- switch (ex) {
-#if EXIT_SUCCESS != 0
- case 0: return EXIT_SUCCESS;
-#endif
-#if EXIT_FAILURE != 1
- case 1: return EXIT_FAILURE;
-#endif
+ if (err && rb_obj_is_kind_of(err, rb_eSystemExit)) {
+ VALUE st = rb_iv_get(err, "status");
+ return NUM2INT(st);
}
-#endif
-
return ex;
}
@@ -1892,7 +1860,7 @@ rb_eval_cmd(cmd, arg, level)
POP_TAG();
POP_FRAME();
- if (state) jump_tag_but_local_jump(state, val);
+ jump_tag_but_local_jump(state, val);
return val;
}
@@ -2035,7 +2003,7 @@ void
rb_frozen_class_p(klass)
VALUE klass;
{
- const char *desc = "something(?!)";
+ char *desc = "something(?!)";
if (OBJ_FROZEN(klass)) {
if (FL_TEST(klass, FL_SINGLETON))
@@ -2073,7 +2041,7 @@ rb_undef(klass, id)
}
body = search_method(klass, id, &origin);
if (!body || !body->nd_body) {
- const char *s0 = " class";
+ char *s0 = " class";
VALUE c = klass;
if (FL_TEST(c, FL_SINGLETON)) {
@@ -2164,10 +2132,9 @@ rb_alias(klass, name, def)
VALUE klass;
ID name, def;
{
- VALUE origin = 0;
+ VALUE origin;
NODE *orig, *body, *node;
VALUE singleton = 0;
- st_data_t data;
rb_frozen_class_p(klass);
if (name == def) return;
@@ -2195,8 +2162,7 @@ rb_alias(klass, name, def)
}
rb_clear_cache_by_id(name);
- if (RTEST(ruby_verbose) && st_lookup(RCLASS(klass)->m_tbl, name, &data)) {
- node = (NODE *)data;
+ if (RTEST(ruby_verbose) && st_lookup(RCLASS(klass)->m_tbl, name, (st_data_t *)&node)) {
if (node->nd_cnt == 0 && node->nd_body) {
rb_warning("discarding old %s", rb_id2name(name));
}
@@ -2245,8 +2211,8 @@ rb_mod_alias_method(mod, newname, oldname)
return mod;
}
-NODE *
-rb_copy_node_scope(node, rval)
+static NODE*
+copy_node_scope(node, rval)
NODE *node;
NODE *rval;
{
@@ -2312,7 +2278,7 @@ rb_copy_node_scope(node, rval)
int tmp_iter = ruby_iter->iter;\
switch (tmp_iter) {\
case ITER_PRE:\
- if (ruby_block) ruby_block = ruby_block->outer;\
+ ruby_block = ruby_block->outer;\
case ITER_PAS:\
tmp_iter = ITER_NOT;\
}\
@@ -2325,9 +2291,9 @@ rb_copy_node_scope(node, rval)
#define MATCH_DATA *rb_svar(node->nd_cnt)
-static const char* is_defined _((VALUE, NODE*, char*));
+static char* is_defined _((VALUE, NODE*, char*));
-static const char*
+static char*
arg_defined(self, node, buf, type)
VALUE self;
NODE *node;
@@ -2354,7 +2320,7 @@ arg_defined(self, node, buf, type)
return type;
}
-static const char*
+static char*
is_defined(self, node, buf)
VALUE self;
NODE *node; /* OK */
@@ -2674,27 +2640,27 @@ set_trace_func(obj, trace)
return trace;
}
-static const char *
+static char *
get_event_name(rb_event_t event)
{
switch (event) {
- case RUBY_EVENT_LINE:
+ case RUBY_EVENT_LINE:
return "line";
- case RUBY_EVENT_CLASS:
+ case RUBY_EVENT_CLASS:
return "class";
- case RUBY_EVENT_END:
+ case RUBY_EVENT_END:
return "end";
- case RUBY_EVENT_CALL:
+ case RUBY_EVENT_CALL:
return "call";
- case RUBY_EVENT_RETURN:
+ case RUBY_EVENT_RETURN:
return "return";
- case RUBY_EVENT_C_CALL:
+ case RUBY_EVENT_C_CALL:
return "c-call";
- case RUBY_EVENT_C_RETURN:
+ case RUBY_EVENT_C_RETURN:
return "c-return";
- case RUBY_EVENT_RAISE:
+ case RUBY_EVENT_RAISE:
return "raise";
- default:
+ default:
return "unknown";
}
}
@@ -2711,8 +2677,7 @@ call_trace_func(event, node, self, id, klass)
struct FRAME *prev;
NODE *node_save;
VALUE srcfile;
- const char *event_name;
- rb_thread_t th = curr_thread;
+ char *event_name;
if (!trace_func) return;
if (tracing) return;
@@ -2744,7 +2709,7 @@ call_trace_func(event, node, self, id, klass)
}
}
PUSH_TAG(PROT_NONE);
- raised = rb_thread_reset_raised(th);
+ raised = thread_reset_raised();
if ((state = EXEC_TAG()) == 0) {
srcfile = rb_str_new2(ruby_sourcefile?ruby_sourcefile:"(ruby)");
event_name = get_event_name(event);
@@ -2756,7 +2721,7 @@ call_trace_func(event, node, self, id, klass)
klass),
Qundef, 0);
}
- if (raised) rb_thread_set_raised(th);
+ if (raised) thread_set_raised();
POP_TAG();
POP_FRAME();
@@ -2948,7 +2913,6 @@ rb_eval(self, n)
NODE * volatile node = n;
int state;
volatile VALUE result = Qnil;
- st_data_t data;
#define RETURN(v) do { \
result = (v); \
@@ -3048,16 +3012,13 @@ rb_eval(self, n)
RETURN(Qfalse);
case NODE_IF:
+ EXEC_EVENT_HOOK(RUBY_EVENT_LINE, node, self,
+ ruby_frame->last_func,
+ ruby_frame->last_class);
if (RTEST(rb_eval(self, node->nd_cond))) {
- EXEC_EVENT_HOOK(RUBY_EVENT_LINE, node, self,
- ruby_frame->last_func,
- ruby_frame->last_class);
node = node->nd_body;
}
else {
- EXEC_EVENT_HOOK(RUBY_EVENT_LINE, node, self,
- ruby_frame->last_func,
- ruby_frame->last_class);
node = node->nd_else;
}
goto again;
@@ -3234,7 +3195,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,self);
+ result = rb_call(CLASS_OF(recv),recv,each,0,0,0);
}
POP_ITER();
}
@@ -3360,7 +3321,7 @@ rb_eval(self, n)
result = rb_eval(self, node->nd_head);
}
POP_TAG();
- if (node->nd_ensr && !thread_no_ensure()) {
+ if (node->nd_ensr) {
VALUE retval = prot_tag->retval; /* save retval */
VALUE errinfo = ruby_errinfo;
@@ -3475,7 +3436,7 @@ rb_eval(self, n)
ruby_current_node = node;
SET_CURRENT_SOURCE();
- rb_call(CLASS_OF(recv),recv,node->nd_mid,argc,argv,scope,self);
+ rb_call(CLASS_OF(recv),recv,node->nd_mid,argc,argv,scope);
result = argv[argc-1];
}
break;
@@ -3493,7 +3454,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,self);
+ result = rb_call(CLASS_OF(recv),recv,node->nd_mid,argc,argv,0);
}
break;
@@ -3508,13 +3469,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,self);
+ result = rb_call(CLASS_OF(self),self,node->nd_mid,argc,argv,1);
}
break;
case NODE_VCALL:
SET_CURRENT_SOURCE();
- result = rb_call(CLASS_OF(self),self,node->nd_mid,0,0,2,self);
+ result = rb_call(CLASS_OF(self),self,node->nd_mid,0,0,2);
break;
case NODE_SUPER:
@@ -3543,10 +3504,6 @@ 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;
}
@@ -3925,7 +3882,7 @@ rb_eval(self, n)
case NODE_DEFN:
if (node->nd_defn) {
NODE *body, *defn;
- VALUE origin = 0;
+ VALUE origin;
int noex;
if (NIL_P(ruby_class)) {
@@ -3959,7 +3916,7 @@ rb_eval(self, n)
noex |= NOEX_NOSUPER;
}
- defn = rb_copy_node_scope(node->nd_defn, ruby_cref);
+ defn = copy_node_scope(node->nd_defn, ruby_cref);
rb_add_method(ruby_class, node->nd_mid, defn, noex);
if (scope_vmode == SCOPE_MODFUNC) {
rb_add_method(rb_singleton_class(ruby_class),
@@ -3987,8 +3944,7 @@ rb_eval(self, n)
if (OBJ_FROZEN(recv)) rb_error_frozen("object");
klass = rb_singleton_class(recv);
- if (st_lookup(RCLASS(klass)->m_tbl, node->nd_mid, &data)) {
- body = (NODE *)data;
+ if (st_lookup(RCLASS(klass)->m_tbl, node->nd_mid, (st_data_t *)&body)) {
if (ruby_safe_level >= 4) {
rb_raise(rb_eSecurityError, "redefining method prohibited");
}
@@ -3996,7 +3952,7 @@ rb_eval(self, n)
rb_warning("redefine %s", rb_id2name(node->nd_mid));
}
}
- defn = rb_copy_node_scope(node->nd_defn, ruby_cref);
+ defn = copy_node_scope(node->nd_defn, ruby_cref);
rb_add_method(klass, node->nd_mid, defn,
NOEX_PUBLIC|(body?body->nd_noex&NOEX_UNDEF:0));
result = Qnil;
@@ -4140,7 +4096,7 @@ rb_eval(self, n)
case NODE_DEFINED:
{
char buf[20];
- const char *desc = is_defined(self, node->nd_head, buf);
+ char *desc = is_defined(self, node->nd_head, buf);
if (desc) result = rb_str_new2(desc);
else result = Qnil;
@@ -4237,7 +4193,7 @@ rb_obj_respond_to(obj, id, priv)
int n = 0;
args[n++] = ID2SYM(id);
if (priv) args[n++] = Qtrue;
- return RTEST(rb_funcall2(obj, respond_to, n, args));
+ return rb_funcall2(obj, respond_to, n, args);
}
}
@@ -4575,9 +4531,8 @@ rb_longjmp(tag, mesg)
VALUE mesg;
{
VALUE at;
- rb_thread_t th = curr_thread;
- if (rb_thread_set_raised(th)) {
+ if (thread_set_raised()) {
ruby_errinfo = exception_error;
JUMP_TAG(TAG_FATAL);
}
@@ -4591,9 +4546,6 @@ rb_longjmp(tag, mesg)
at = get_backtrace(mesg);
if (NIL_P(at)) {
at = make_backtrace();
- if (OBJ_FROZEN(mesg)) {
- mesg = rb_obj_dup(mesg);
- }
set_backtrace(mesg, at);
}
}
@@ -4619,7 +4571,7 @@ rb_longjmp(tag, mesg)
ruby_errinfo = mesg;
}
else if (status) {
- rb_thread_reset_raised(th);
+ thread_reset_raised();
JUMP_TAG(status);
}
}
@@ -4634,20 +4586,11 @@ rb_longjmp(tag, mesg)
if (!prot_tag) {
error_print();
}
- rb_thread_raised_clear(th);
+ thread_reset_raised();
JUMP_TAG(tag);
}
void
-rb_exc_jump(mesg)
- VALUE mesg;
-{
- rb_thread_raised_clear(rb_curr_thread);
- ruby_errinfo = mesg;
- JUMP_TAG(TAG_RAISE);
-}
-
-void
rb_exc_raise(mesg)
VALUE mesg;
{
@@ -4664,8 +4607,7 @@ rb_exc_fatal(mesg)
void
rb_interrupt()
{
- static const char fmt[1] = {'\0'};
- rb_raise(rb_eInterrupt, fmt);
+ rb_raise(rb_eInterrupt, "");
}
/*
@@ -4812,7 +4754,7 @@ rb_f_block_given_p()
return Qfalse;
}
-VALUE rb_eThreadError;
+static VALUE rb_eThreadError;
NORETURN(static void proc_jump_error(int, VALUE));
static void
@@ -4821,7 +4763,7 @@ proc_jump_error(state, result)
VALUE result;
{
char mesg[32];
- const char *statement;
+ char *statement;
switch (state) {
case TAG_BREAK:
@@ -4935,7 +4877,7 @@ rb_yield_0(val, self, klass, flags, avalue)
VALUE val, self, klass; /* OK */
int flags, avalue;
{
- NODE *node, *var;
+ NODE *node;
volatile VALUE result = Qnil;
volatile VALUE old_cref;
volatile VALUE old_wrapper;
@@ -4977,35 +4919,27 @@ rb_yield_0(val, self, klass, flags, avalue)
self = block->self;
}
node = block->body;
- var = block->var;
- if (var) {
+ if (block->var) {
PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
- NODE *bvar = NULL;
- block_var:
- if (var == (NODE*)1) { /* no parameter || */
+ if (block->var == (NODE*)1) { /* no parameter || */
if (lambda && RARRAY(val)->len != 0) {
rb_raise(rb_eArgError, "wrong number of arguments (%ld for 0)",
RARRAY(val)->len);
}
}
- else if (var == (NODE*)2) {
+ else if (block->var == (NODE*)2) {
if (TYPE(val) == T_ARRAY && RARRAY(val)->len != 0) {
rb_raise(rb_eArgError, "wrong number of arguments (%ld for 0)",
RARRAY(val)->len);
}
}
- else if (!bvar && nd_type(var) == NODE_BLOCK_PASS) {
- bvar = var->nd_body;
- var = var->nd_args;
- goto block_var;
- }
- else if (nd_type(var) == NODE_MASGN) {
+ else if (nd_type(block->var) == NODE_MASGN) {
if (!avalue) {
- val = svalue_to_mrhs(val, var->nd_head);
+ val = svalue_to_mrhs(val, block->var->nd_head);
}
- massign(self, var, val, lambda);
+ massign(self, block->var, val, lambda);
}
else {
int len = 0;
@@ -5026,21 +4960,13 @@ rb_yield_0(val, self, klass, flags, avalue)
val = Qnil;
multi_values:
{
- ruby_current_node = var;
+ ruby_current_node = block->var;
rb_warn("multiple values for a block parameter (%d for 1)\n\tfrom %s:%d",
len, cnode->nd_file, nd_line(cnode));
ruby_current_node = cnode;
}
}
- assign(self, var, val, lambda);
- }
- if (bvar) {
- VALUE blk;
- if (flags & YIELD_PROC_CALL)
- blk = block->block_obj;
- else
- blk = rb_block_proc();
- assign(self, bvar, blk, 0);
+ assign(self, block->var, val, lambda);
}
}
POP_TAG();
@@ -5057,18 +4983,12 @@ rb_yield_0(val, self, klass, flags, avalue)
if ((state = EXEC_TAG()) == 0) {
redo:
if (nd_type(node) == NODE_CFUNC || nd_type(node) == NODE_IFUNC) {
- switch (node->nd_state) {
- case YIELD_FUNC_LAMBDA:
- if (!avalue) {
- val = rb_ary_new3(1, val);
- }
- break;
- case YIELD_FUNC_AVALUE:
+ if (node->nd_state == YIELD_FUNC_AVALUE) {
if (!avalue) {
val = svalue_to_avalue(val);
}
- break;
- default:
+ }
+ else {
if (avalue) {
val = avalue_to_svalue(val);
}
@@ -5206,16 +5126,6 @@ rb_yield_splat(values)
return rb_yield_0(values, 0, 0, 0, avalue);
}
-static VALUE
-loop_i()
-{
- for (;;) {
- rb_yield_0(Qundef, 0, 0, 0, Qfalse);
- CHECK_INTS;
- }
- return Qnil;
-}
-
/*
* call-seq:
* loop {|| block }
@@ -5228,14 +5138,15 @@ loop_i()
* break if !line or line =~ /^qQ/
* # ...
* end
- *
- * StopIteration raised in the block breaks the loop.
*/
static VALUE
rb_f_loop()
{
- rb_rescue2(loop_i, (VALUE)0, 0, 0, rb_eStopIteration, (VALUE)0);
+ for (;;) {
+ rb_yield_0(Qundef, 0, 0, 0, Qfalse);
+ CHECK_INTS;
+ }
return Qnil; /* dummy */
}
@@ -5362,7 +5273,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, self);
+ rb_call(CLASS_OF(recv), recv, lhs->nd_mid, 1, &val, scope);
}
else {
/* array set */
@@ -5373,7 +5284,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, self);
+ RARRAY(args)->len, RARRAY(args)->ptr, scope);
}
}
break;
@@ -5394,9 +5305,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:
@@ -5410,9 +5321,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:
@@ -5480,7 +5391,7 @@ rb_rescue2(b_proc, data1, r_proc, data2, va_alist)
if (handle) break;
handle = Qfalse;
va_init_list(args, data2);
- while ((eclass = va_arg(args, VALUE)) != 0) {
+ while (eclass = va_arg(args, VALUE)) {
if (rb_obj_is_kind_of(ruby_errinfo, eclass)) {
handle = Qtrue;
break;
@@ -5558,9 +5469,7 @@ 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;
@@ -5595,11 +5504,18 @@ rb_with_disable_interrupt(proc, data)
static void
stack_check()
{
- rb_thread_t th = rb_curr_thread;
+ static int overflowing = 0;
- if (!rb_thread_raised_p(th, RAISED_STACKOVERFLOW) && ruby_stack_check()) {
- rb_thread_raised_set(th, RAISED_STACKOVERFLOW);
- rb_exc_raise(sysstack_error);
+ if (!overflowing && ruby_stack_check()) {
+ int state;
+ overflowing = 1;
+ PUSH_TAG(PROT_NONE);
+ if ((state = EXEC_TAG()) == 0) {
+ rb_exc_raise(sysstack_error);
+ }
+ POP_TAG();
+ overflowing = 0;
+ JUMP_TAG(state);
}
}
@@ -5648,7 +5564,7 @@ rb_method_missing(argc, argv, obj)
{
ID id;
VALUE exc = rb_eNoMethodError;
- const char *format = 0;
+ char *format = 0;
NODE *cnode = ruby_current_node;
if (argc == 0 || !SYMBOL_P(argv[0])) {
@@ -5838,7 +5754,8 @@ rb_call0(klass, recv, id, oid, argc, argv, body, flags)
TMP_PROTECT;
volatile int safe = -1;
- if (NOEX_SAFE(flags) > ruby_safe_level && NOEX_SAFE(flags) > 2) {
+ if (NOEX_SAFE(flags) > ruby_safe_level &&
+ ruby_safe_level == 0 && NOEX_SAFE(flags) > 2) {
rb_raise(rb_eSecurityError, "calling insecure method: %s",
rb_id2name(id));
}
@@ -5941,7 +5858,7 @@ rb_call0(klass, recv, id, oid, argc, argv, body, flags)
}
result = proc_invoke(body->nd_cval, rb_ary_new4(argc, argv), recv, klass);
if (event_hooks) {
- EXEC_EVENT_HOOK(RUBY_EVENT_RETURN, ruby_current_node, recv, id, klass);
+ EXEC_EVENT_HOOK(RUBY_EVENT_RETURN, body, recv, id, klass);
}
break;
@@ -6025,21 +5942,14 @@ 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;
}
- else {
+ if (node->nd_rest) {
VALUE v;
if (argc > 0) {
@@ -6064,7 +5974,7 @@ rb_call0(klass, recv, id, oid, argc, argv, body, flags)
}
POP_TAG();
if (event_hooks) {
- EXEC_EVENT_HOOK(RUBY_EVENT_RETURN, ruby_current_node, recv, id, klass);
+ EXEC_EVENT_HOOK(RUBY_EVENT_RETURN, body, recv, id, klass);
}
POP_VARS();
POP_CLASS();
@@ -6100,13 +6010,12 @@ rb_call0(klass, recv, id, oid, argc, argv, body, flags)
}
static VALUE
-rb_call(klass, recv, mid, argc, argv, scope, self)
+rb_call(klass, recv, mid, argc, argv, scope)
VALUE klass, recv;
ID mid;
int argc; /* OK */
const VALUE *argv; /* OK */
int scope;
- VALUE self;
{
NODE *body; /* OK */
int noex;
@@ -6143,11 +6052,10 @@ rb_call(klass, recv, mid, argc, argv, scope, self)
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(self, rb_class_real(defined_class)))
+ if (!rb_obj_is_kind_of(ruby_frame->self, rb_class_real(defined_class)))
return method_missing(recv, mid, argc, argv, CSTAT_PROT);
}
}
@@ -6167,7 +6075,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, Qundef);
+ return rb_call(CLASS_OF(recv), recv, mid, argc, argv, 1);
}
/*
@@ -6200,7 +6108,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, Qundef);
+ vid = rb_call(CLASS_OF(recv), recv, rb_to_id(vid), argc, argv, 1);
POP_ITER();
return vid;
@@ -6229,7 +6137,7 @@ vafuncall(recv, mid, n, ar)
argv = 0;
}
- return rb_call(CLASS_OF(recv), recv, mid, n, argv, 1, Qundef);
+ return rb_call(CLASS_OF(recv), recv, mid, n, argv, 1);
}
VALUE
@@ -6288,7 +6196,7 @@ rb_funcall2(recv, mid, argc, argv)
int argc;
const VALUE *argv;
{
- return rb_call(CLASS_OF(recv), recv, mid, argc, argv, 1, Qundef);
+ return rb_call(CLASS_OF(recv), recv, mid, argc, argv, 1);
}
VALUE
@@ -6298,7 +6206,7 @@ rb_funcall3(recv, mid, argc, argv)
int argc;
const VALUE *argv;
{
- return rb_call(CLASS_OF(recv), recv, mid, argc, argv, 0, Qundef);
+ return rb_call(CLASS_OF(recv), recv, mid, argc, argv, 0);
}
VALUE
@@ -6320,7 +6228,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, Qundef);
+ result = rb_call(RCLASS(klass)->super, self, ruby_frame->orig_func, argc, argv, 3);
POP_ITER();
return result;
@@ -6448,16 +6356,10 @@ rb_frame_last_func()
return ruby_frame->last_func;
}
-ID
-rb_frame_this_func()
-{
- return ruby_frame->orig_func;
-}
-
static NODE*
compile(src, file, line)
VALUE src;
- const char *file;
+ char *file;
int line;
{
NODE *node;
@@ -6477,7 +6379,7 @@ compile(src, file, line)
static VALUE
eval(self, src, scope, file, line)
VALUE self, src, scope;
- const char *file;
+ char *file;
int line;
{
struct BLOCK *data = NULL;
@@ -6596,12 +6498,12 @@ eval(self, src, scope, file, line)
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_LEN(bt2) > 0)) {
+ (bt2 = backtrace(-2), RARRAY(bt2)->len > 0)) {
if (!NIL_P(mesg) && TYPE(mesg) == T_STRING) {
rb_str_update(mesg, 0, 0, rb_str_new2(": "));
- rb_str_update(mesg, 0, 0, RARRAY_PTR(errat)[0]);
+ rb_str_update(mesg, 0, 0, RARRAY(errat)->ptr[0]);
}
- RARRAY_PTR(errat)[0] = RARRAY_PTR(bt2)[0];
+ RARRAY(errat)->ptr[0] = RARRAY(bt2)->ptr[0];
}
}
rb_exc_raise(ruby_errinfo);
@@ -6638,7 +6540,7 @@ rb_f_eval(argc, argv, self)
VALUE self;
{
VALUE src, scope, vfile, vline;
- const char *file = "(eval)";
+ char *file = "(eval)";
int line = 1;
rb_scan_args(argc, argv, "13", &src, &scope, &vfile, &vline);
@@ -6755,28 +6657,12 @@ yield_under_i(self)
return rb_yield_0(self, self, ruby_class, YIELD_PUBLIC_DEF, Qfalse);
}
-static VALUE
-yield_args_under_i(vinfo)
- VALUE vinfo;
-{
- VALUE *info = (VALUE *)vinfo;
-
- return rb_yield_0(info[0], info[1], ruby_class, YIELD_PUBLIC_DEF, Qtrue);
-}
-
/* block eval under the class/module context */
static VALUE
-yield_under(under, self, args)
- VALUE under, self, args;
+yield_under(under, self)
+ VALUE under, self;
{
- if (args == Qundef) {
- return exec_under(yield_under_i, under, 0, self);
- }
- else {
- VALUE info[2] = { args, self };
-
- return exec_under(yield_args_under_i, under, 0, (VALUE)info);
- }
+ return exec_under(yield_under_i, under, 0, self);
}
static VALUE
@@ -6789,10 +6675,10 @@ specific_eval(argc, argv, klass, self)
if (argc > 0) {
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
}
- return yield_under(klass, self, Qundef);
+ return yield_under(klass, self);
}
else {
- const char *file = "(eval)";
+ char *file = "(eval)";
int line = 1;
if (argc == 0) {
@@ -6861,41 +6747,6 @@ rb_obj_instance_eval(argc, argv, self)
/*
* call-seq:
- * obj.instance_exec(arg...) {|var...| block } => obj
- *
- * Executes the given block within the context of the receiver
- * (_obj_). In order to set the context, the variable +self+ is set
- * to _obj_ while the code is executing, giving the code access to
- * _obj_'s instance variables. Arguments are passed as block parameters.
- *
- * class KlassWithSecret
- * def initialize
- * @secret = 99
- * end
- * end
- * k = KlassWithSecret.new
- * k.instance_exec(5) {|x| @secret+x } #=> 104
- */
-
-VALUE
-rb_obj_instance_exec(argc, argv, self)
- int argc;
- VALUE *argv;
- VALUE self;
-{
- VALUE klass;
-
- if (SPECIAL_CONST_P(self)) {
- klass = Qnil;
- }
- else {
- klass = rb_singleton_class(self);
- }
- return yield_under(klass, self, rb_ary_new4(argc, argv));
-}
-
-/*
- * call-seq:
* mod.class_eval(string [, filename [, lineno]]) => obj
* mod.module_eval {|| block } => obj
*
@@ -6927,35 +6778,6 @@ rb_mod_module_eval(argc, argv, mod)
return specific_eval(argc, argv, mod, mod);
}
-/*
- * call-seq:
- * mod.module_exec(arg...) {|var...| block } => obj
- * mod.class_exec(arg...) {|var...| block } => obj
- *
- * Evaluates the given block in the context of the class/module.
- * The method defined in the block will belong to the receiver.
- *
- * class Thing
- * end
- * Thing.class_exec{
- * def hello() "Hello there!" end
- * }
- * puts Thing.new.hello()
- *
- * <em>produces:</em>
- *
- * Hello there!
- */
-
-VALUE
-rb_mod_module_exec(argc, argv, mod)
- int argc;
- VALUE *argv;
- VALUE mod;
-{
- return yield_under(mod, mod, rb_ary_new4(argc, argv));
-}
-
VALUE rb_load_path;
NORETURN(static void load_failed _((VALUE)));
@@ -6973,6 +6795,7 @@ rb_load(fname, wrap)
volatile VALUE self = ruby_top_self;
NODE *volatile last_node;
NODE *saved_cref = ruby_cref;
+ TMP_PROTECT;
if (wrap && ruby_safe_level >= 4) {
StringValue(fname);
@@ -6990,7 +6813,7 @@ rb_load(fname, wrap)
ruby_errinfo = Qnil; /* ensure */
PUSH_VARS();
PUSH_CLASS(ruby_wrapper);
- ruby_cref = ruby_top_cref;
+ ruby_cref = top_cref;
if (!wrap) {
rb_secure(4); /* should alter global state */
ruby_class = rb_cObject;
@@ -7116,25 +6939,13 @@ static st_table *loading_tbl;
#define IS_DLEXT(e) (strcmp(e, DLEXT) == 0)
#endif
-
-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(ftptr, ext, rb)
- const char **ftptr, *ext;
+static char *
+rb_feature_p(feature, ext, rb)
+ const char *feature, *ext;
int rb;
{
VALUE v;
- const char *f, *e, *feature = *ftptr;
+ char *f, *e;
long i, len, elen;
if (ext) {
@@ -7145,68 +6956,51 @@ rb_feature_p(ftptr, ext, rb)
len = strlen(feature);
elen = 0;
}
- for (i = 0; i < RARRAY_LEN(rb_features); ++i) {
- v = RARRAY_PTR(rb_features)[i];
+ for (i = 0; i < RARRAY(rb_features)->len; ++i) {
+ v = RARRAY(rb_features)->ptr[i];
f = StringValuePtr(v);
- if (RSTRING_LEN(v) < len || strncmp(f, feature, len) != 0)
- continue;
+ if (strncmp(f, feature, len) != 0) continue;
if (!*(e = f + len)) {
if (ext) continue;
- *ftptr = 0;
- return 'u';
+ return e;
}
if (*e != '.') continue;
if ((!rb || !ext) && (IS_SOEXT(e) || IS_DLEXT(e))) {
- *ftptr = 0;
- return 's';
+ return e;
}
if ((rb || !ext) && (strcmp(e, ".rb") == 0)) {
- *ftptr = 0;
- return 'r';
- }
- }
- if (loading_tbl) {
- if (st_lookup(loading_tbl, (st_data_t)feature, (st_data_t *)ftptr)) {
- 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, (st_data_t *)ftptr)) {
- return i ? 's' : 'r';
- }
- }
+ return e;
}
}
return 0;
}
-#define rb_feature_p(feature, ext, rb) rb_feature_p(&feature, ext, rb)
+
+static const char *const loadable_ext[] = {
+ ".rb", DLEXT,
+#ifdef DLEXT2
+ DLEXT2,
+#endif
+ 0
+};
int
rb_provided(feature)
const char *feature;
{
- const char *ext = strrchr(feature, '.');
+ int i;
+ char *buf;
- 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))
+ if (rb_feature_p(feature, 0, Qfalse))
return Qtrue;
-
+ if (!loading_tbl) return Qfalse;
+ if (st_lookup(loading_tbl, (st_data_t)feature, 0)) return Qtrue;
+ buf = ALLOCA_N(char, strlen(feature)+8);
+ strcpy(buf, feature);
+ for (i=0; ; i++) {
+ if (!loadable_ext[i]) break;
+ strcpy(buf+strlen(feature), loadable_ext[i]);
+ if (st_lookup(loading_tbl, (st_data_t)buf, 0)) return Qtrue;
+ }
return Qfalse;
}
@@ -7224,42 +7018,19 @@ rb_provide(feature)
rb_provide_feature(rb_str_new2(feature));
}
-static char *
-load_lock(ftptr)
- const char *ftptr;
+static int
+load_wait(ftptr)
+ char *ftptr;
{
st_data_t th;
- 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;
- }
+ if (!loading_tbl) return Qfalse;
+ if (!st_lookup(loading_tbl, (st_data_t)ftptr, &th)) return Qfalse;
do {
- rb_thread_t owner = (rb_thread_t)th;
- if (owner == curr_thread) return 0;
- rb_thread_join(owner->thread, -1.0);
+ if ((rb_thread_t)th == curr_thread) return Qtrue;
+ CHECK_INTS;
} while (st_lookup(loading_tbl, (st_data_t)ftptr, &th));
- 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);
- }
- }
+ return Qtrue;
}
/*
@@ -7296,27 +7067,21 @@ search_required(fname, featurep, path)
VALUE fname, *featurep, *path;
{
VALUE tmp;
- const char *ext, *ftptr;
+ char *ext, *ftptr;
int type;
*featurep = fname;
*path = 0;
- ext = strrchr(ftptr = RSTRING_PTR(fname), '.');
+ ext = strrchr(ftptr = RSTRING(fname)->ptr, '.');
if (ext && !strchr(ext, '/')) {
if (strcmp(".rb", ext) == 0) {
- if (rb_feature_p(ftptr, ext, Qtrue)) {
- if (ftptr) *path = rb_str_new2(ftptr);
- return 'r';
- }
- if ((*path = rb_find_file(fname)) != 0) return 'r';
+ if (rb_feature_p(ftptr, ext, Qtrue)) return 'r';
+ if (*path = rb_find_file(fname)) return 'r';
return 0;
}
else if (IS_SOEXT(ext)) {
- if (rb_feature_p(ftptr, ext, Qfalse)) {
- if (ftptr) *path = rb_str_new2(ftptr);
- return 's';
- }
- tmp = rb_str_new(RSTRING_PTR(fname), ext-RSTRING_PTR(fname));
+ if (rb_feature_p(ftptr, ext, Qfalse)) return 's';
+ tmp = rb_str_new(RSTRING(fname)->ptr, ext-RSTRING(fname)->ptr);
*featurep = tmp;
#ifdef DLEXT2
OBJ_FREEZE(tmp);
@@ -7328,34 +7093,30 @@ search_required(fname, featurep, path)
#else
rb_str_cat2(tmp, DLEXT);
OBJ_FREEZE(tmp);
- if ((*path = rb_find_file(tmp)) != 0) {
+ if (*path = rb_find_file(tmp)) {
return 's';
}
#endif
}
else if (IS_DLEXT(ext)) {
- if (rb_feature_p(ftptr, ext, Qfalse)) {
- if (ftptr) *path = rb_str_new2(ftptr);
- return 's';
- }
- if ((*path = rb_find_file(fname)) != 0) return 's';
+ if (rb_feature_p(ftptr, ext, Qfalse)) return 's';
+ if (*path = rb_find_file(fname)) return 's';
}
}
tmp = fname;
- type = rb_find_file_ext(&tmp, loadable_ext);
- *featurep = tmp;
- switch (type) {
+ switch (type = rb_find_file_ext(&tmp, loadable_ext)) {
case 0:
- type = rb_feature_p(ftptr, 0, Qfalse);
- if (type && ftptr) *path = rb_str_new2(ftptr);
- return type;
+ if ((ext = rb_feature_p(ftptr, 0, Qfalse))) {
+ type = strcmp(".rb", ext);
+ break;
+ }
+ return 0;
default:
+ *featurep = tmp;
ext = strrchr(ftptr = RSTRING(tmp)->ptr, '.');
- if (!rb_feature_p(ftptr, ext, !--type))
- *path = rb_find_file(tmp);
- else if (ftptr)
- *path = rb_str_new2(ftptr);
+ if (rb_feature_p(ftptr, ext, !--type)) break;
+ *path = rb_find_file(tmp);
}
return type ? 's' : 'r';
}
@@ -7400,13 +7161,20 @@ rb_require_safe(fname, safe)
ruby_safe_level = safe;
found = search_required(fname, &feature, &path);
if (found) {
- if (!path || !(ftptr = load_lock(RSTRING_PTR(feature)))) {
+ if (!path || load_wait(RSTRING(feature)->ptr)) {
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;
@@ -7431,7 +7199,11 @@ rb_require_safe(fname, safe)
ruby_frame->last_func = saved.func;
SCOPE_SET(saved.vmode);
ruby_safe_level = saved.safe;
- load_unlock(ftptr);
+ if (ftptr) {
+ if (st_delete(loading_tbl, (st_data_t *)&ftptr, 0)) { /* loading done */
+ free(ftptr);
+ }
+ }
if (state) JUMP_TAG(state);
if (NIL_P(result)) {
load_failed(fname);
@@ -7450,24 +7222,6 @@ 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;
@@ -7716,7 +7470,7 @@ rb_mod_modfunc(argc, argv, module)
body = search_method(rb_cObject, id, &m);
}
if (body == 0 || body->nd_body == 0) {
- print_undef(module, id);
+ rb_bug("undefined method `%s'; can't happen", rb_id2name(id));
}
if (nd_type(body->nd_body) != NODE_ZSUPER) {
break; /* normal case: need not to follow 'super' link */
@@ -8134,37 +7888,6 @@ rb_exec_end_proc()
ruby_safe_level = safe;
}
-/*
- * call-seq:
- * __method__ => symbol
- *
- * Returns the name of the current method as a Symbol.
- * If called from inside of an aliased method it will return the original
- * nonaliased name.
- * If called outside of a method, it returns <code>nil</code>.
- *
- * def foo
- * __method__
- * end
- * alias bar foo
- *
- * foo # => :foo
- * bar # => :foo
- *
- */
-
-static VALUE
-rb_f_method_name()
-{
- struct FRAME* prev = ruby_frame->prev;
- if (prev && prev->orig_func) {
- return ID2SYM(prev->orig_func);
- }
- else {
- return Qnil;
- }
-}
-
void
Init_eval()
{
@@ -8186,11 +7909,11 @@ Init_eval()
__id__ = rb_intern("__id__");
__send__ = rb_intern("__send__");
- rb_global_variable((void *)&top_scope);
- rb_global_variable((void *)&ruby_eval_tree_begin);
+ rb_global_variable((VALUE*)&top_scope);
+ rb_global_variable((VALUE*)&ruby_eval_tree_begin);
- rb_global_variable((void *)&ruby_eval_tree);
- rb_global_variable((void *)&ruby_dyna_vars);
+ rb_global_variable((VALUE*)&ruby_eval_tree);
+ rb_global_variable((VALUE*)&ruby_dyna_vars);
rb_define_virtual_variable("$@", errat_getter, errat_setter);
rb_define_hooked_variable("$!", &ruby_errinfo, 0, errinfo_setter);
@@ -8203,7 +7926,7 @@ Init_eval()
rb_define_method(rb_mKernel, "respond_to?", obj_respond_to, -1);
respond_to = rb_intern("respond_to?");
- rb_global_variable((void *)&basic_respond_to);
+ rb_global_variable((VALUE*)&basic_respond_to);
basic_respond_to = rb_method_node(rb_cObject, respond_to);
rb_define_global_function("raise", rb_f_raise, -1);
@@ -8221,12 +7944,9 @@ Init_eval()
rb_define_global_function("global_variables", rb_f_global_variables, 0); /* in variable.c */
rb_define_global_function("local_variables", rb_f_local_variables, 0);
- rb_define_global_function("__method__", rb_f_method_name, 0);
-
rb_define_method(rb_mKernel, "send", rb_f_send, -1);
rb_define_method(rb_mKernel, "__send__", rb_f_send, -1);
rb_define_method(rb_mKernel, "instance_eval", rb_obj_instance_eval, -1);
- rb_define_method(rb_mKernel, "instance_exec", rb_obj_instance_exec, -1);
rb_define_private_method(rb_cModule, "append_features", rb_mod_append_features, 1);
rb_define_private_method(rb_cModule, "extend_object", rb_mod_extend_object, 1);
@@ -8242,9 +7962,7 @@ Init_eval()
rb_define_method(rb_cModule, "public_class_method", rb_mod_public_method, -1);
rb_define_method(rb_cModule, "private_class_method", rb_mod_private_method, -1);
rb_define_method(rb_cModule, "module_eval", rb_mod_module_eval, -1);
- rb_define_method(rb_cModule, "module_exec", rb_mod_module_exec, -1);
rb_define_method(rb_cModule, "class_eval", rb_mod_module_eval, -1);
- rb_define_method(rb_cModule, "class_exec", rb_mod_module_exec, -1);
rb_undef_method(rb_cClass, "module_function");
@@ -8556,19 +8274,6 @@ proc_dup(self)
return bind;
}
-VALUE
-rb_block_dup(self, klass, cref)
- VALUE self, klass, cref;
-{
- struct BLOCK *block;
- VALUE obj = proc_dup(self);
- Data_Get_Struct(obj, struct BLOCK, block);
- block->klass = klass;
- block->cref = NEW_NODE(nd_type(block->cref), cref, block->cref->u2.node,
- block->cref->u3.node);
- return obj;
-}
-
/*
* call-seq:
* binding -> a_binding
@@ -8626,35 +8331,6 @@ rb_f_binding(self)
return bind;
}
-/*
- * call-seq:
- * binding.eval(string [, filename [,lineno]]) => obj
- *
- * Evaluates the Ruby expression(s) in <em>string</em>, in the
- * <em>binding</em>'s context. If the optional <em>filename</em> and
- * <em>lineno</em> parameters are present, they will be used when
- * reporting syntax errors.
- *
- * def getBinding(param)
- * return binding
- * end
- * b = getBinding("hello")
- * b.eval("param") #=> "hello"
- */
-
-static VALUE
-bind_eval(argc, argv, bindval)
- int argc;
- VALUE *argv;
- VALUE bindval;
-{
- VALUE args[4];
-
- rb_scan_args(argc, argv, "12", &args[0], &args[2], &args[3]);
- args[1] = bindval;
- return rb_f_eval(argc+1, args, Qnil /* self will be searched in eval */);
-}
-
#define SAFE_LEVEL_MAX PROC_TMASK
static void
@@ -8816,12 +8492,13 @@ proc_invoke(proc, args, self, klass)
volatile VALUE old_wrapper = ruby_wrapper;
volatile int pcall, avalue = Qtrue;
volatile VALUE tmp = args;
- VALUE bvar = Qnil;
if (rb_block_given_p() && ruby_frame->last_func) {
if (klass != ruby_frame->last_class)
klass = rb_obj_class(proc);
- bvar = rb_block_proc();
+ rb_warning("block for %s#%s is useless",
+ rb_class2name(klass),
+ rb_id2name(ruby_frame->last_func));
}
Data_Get_Struct(proc, struct BLOCK, data);
@@ -8837,7 +8514,6 @@ proc_invoke(proc, args, self, klass)
/* PUSH BLOCK from data */
old_block = ruby_block;
_block = *data;
- _block.block_obj = bvar;
if (self != Qundef) _block.frame.self = self;
if (klass) _block.frame.last_class = klass;
_block.frame.argc = RARRAY(tmp)->len;
@@ -8858,8 +8534,7 @@ proc_invoke(proc, args, self, klass)
state = EXEC_TAG();
if (state == 0) {
proc_set_safe_level(proc);
- result = rb_yield_0(args, self, (self!=Qundef)?CLASS_OF(self):0,
- pcall | YIELD_PROC_CALL, avalue);
+ result = rb_yield_0(args, self, (self!=Qundef)?CLASS_OF(self):0, pcall, avalue);
}
else if (TAG_DST()) {
result = prot_tag->retval;
@@ -8928,8 +8603,8 @@ proc_invoke(proc, args, self, klass)
* from prog.rb:5
*/
-VALUE
-rb_proc_call(proc, args)
+static VALUE
+proc_call(proc, args)
VALUE proc, args; /* OK */
{
return proc_invoke(proc, args, Qundef, 0);
@@ -8963,36 +8638,30 @@ proc_arity(proc)
VALUE proc;
{
struct BLOCK *data;
- NODE *var, *list;
+ NODE *list;
int n;
Data_Get_Struct(proc, struct BLOCK, data);
- var = data->var;
- if (var == 0) {
+ if (data->var == 0) {
if (data->body && nd_type(data->body) == NODE_IFUNC &&
data->body->nd_cfnc == bmcall) {
return method_arity(data->body->nd_tval);
}
return INT2FIX(-1);
}
- if (var == (NODE*)1) return INT2FIX(0);
- if (var == (NODE*)2) return INT2FIX(0);
- if (nd_type(var) == NODE_BLOCK_ARG) {
- var = var->nd_args;
- if (var == (NODE*)1) return INT2FIX(0);
- if (var == (NODE*)2) return INT2FIX(0);
- }
- switch (nd_type(var)) {
+ if (data->var == (NODE*)1) return INT2FIX(0);
+ if (data->var == (NODE*)2) return INT2FIX(0);
+ switch (nd_type(data->var)) {
default:
return INT2FIX(1);
case NODE_MASGN:
- list = var->nd_head;
+ list = data->var->nd_head;
n = 0;
while (list) {
n++;
list = list->nd_next;
}
- if (var->nd_args) return INT2FIX(-n-1);
+ if (data->var->nd_args) return INT2FIX(-n-1);
return INT2FIX(n);
}
}
@@ -9040,7 +8709,7 @@ proc_to_s(self)
{
struct BLOCK *data;
NODE *node;
- const char *cname = rb_obj_classname(self);
+ char *cname = rb_obj_classname(self);
const int w = (sizeof(VALUE) * CHAR_BIT) / 4;
long len = strlen(cname)+6+w; /* 6:tags 16:addr */
VALUE str;
@@ -9254,7 +8923,6 @@ mnew(klass, obj, id, mklass)
(FL_TEST(rklass, FL_SINGLETON) || TYPE(rklass) == T_ICLASS)) {
rklass = RCLASS(rklass)->super;
}
- if (TYPE(klass) == T_ICLASS) klass = RBASIC(klass)->klass;
method = Data_Make_Struct(mklass, struct METHOD, bm_mark, free, data);
data->klass = klass;
data->recv = obj;
@@ -9354,57 +9022,6 @@ method_unbind(obj)
/*
* call-seq:
- * meth.receiver => object
- *
- * Returns the bound receiver of the method object.
- */
-
-static VALUE
-method_receiver(obj)
- VALUE obj;
-{
- struct METHOD *data;
-
- Data_Get_Struct(obj, struct METHOD, data);
- return data->recv;
-}
-
-/*
- * call-seq:
- * meth.name => string
- *
- * Returns the name of the method.
- */
-
-static VALUE
-method_name(obj)
- VALUE obj;
-{
- struct METHOD *data;
-
- Data_Get_Struct(obj, struct METHOD, data);
- return rb_str_new2(rb_id2name(data->oid));
-}
-
-/*
- * call-seq:
- * meth.owner => class_or_module
- *
- * Returns the class or module that defines the method.
- */
-
-static VALUE
-method_owner(obj)
- VALUE obj;
-{
- struct METHOD *data;
-
- Data_Get_Struct(obj, struct METHOD, data);
- return data->klass;
-}
-
-/*
- * call-seq:
* obj.method(sym) => method
*
* Looks up the named method as a receiver in <i>obj</i>, returning a
@@ -9431,7 +9048,7 @@ method_owner(obj)
* m.call #=> "Hello, @iv = Fred"
*/
-VALUE
+static VALUE
rb_obj_method(obj, vid)
VALUE obj;
VALUE vid;
@@ -9498,29 +9115,6 @@ method_clone(self)
return clone;
}
-VALUE
-rb_method_dup(self, klass, cref)
- VALUE self;
- VALUE klass;
- VALUE cref;
-{
- VALUE clone;
- struct METHOD *orig, *data;
-
- Data_Get_Struct(self, struct METHOD, orig);
- clone = Data_Make_Struct(CLASS_OF(self),struct METHOD, bm_mark, free, data);
- *data = *orig;
- data->rklass = klass;
- if (data->body->nd_rval) {
- NODE *tmp = NEW_NODE(nd_type(data->body->u2.node), cref,
- data->body->u2.node->u2.node,
- data->body->u2.node->u3.node);
- data->body = NEW_NODE(nd_type(data->body), data->body->u1.node, tmp,
- data->body->u3.node);
- }
- return clone;
-}
-
/*
* call-seq:
* meth.call(args, ...) => obj
@@ -9774,7 +9368,7 @@ method_inspect(method)
struct METHOD *data;
VALUE str;
const char *s;
- const char *sharp = "#";
+ char *sharp = "#";
Data_Get_Struct(method, struct METHOD, data);
str = rb_str_buf_new2("#<");
@@ -9803,8 +9397,12 @@ method_inspect(method)
else {
rb_str_buf_cat2(str, rb_class2name(data->rklass));
if (data->rklass != data->klass) {
+ VALUE klass = data -> klass;
+ if (TYPE(klass) == T_ICLASS) {
+ klass = RBASIC(klass)->klass;
+ }
rb_str_buf_cat2(str, "(");
- rb_str_buf_cat2(str, rb_class2name(data->klass));
+ rb_str_buf_cat2(str, rb_class2name(klass));
rb_str_buf_cat2(str, ")");
}
}
@@ -9853,8 +9451,7 @@ rb_proc_new(func, val)
VALUE proc = rb_iterate((VALUE(*)_((VALUE)))mproc, 0, func, val);
Data_Get_Struct(proc, struct BLOCK, data);
- data->body->nd_state = YIELD_FUNC_LAMBDA;
- data->flags |= BLOCK_LAMBDA;
+ data->body->nd_state = YIELD_FUNC_AVALUE;
return proc;
}
@@ -9974,14 +9571,14 @@ rb_mod_define_method(argc, argv, mod)
rb_raise(rb_eTypeError, "wrong argument type (expected Proc/Method)");
}
- noex = NOEX_PUBLIC;
- if (ruby_cbase == mod) {
- if (SCOPE_TEST(SCOPE_PRIVATE)) {
- noex = NOEX_PRIVATE;
- }
- else if (SCOPE_TEST(SCOPE_PROTECTED)) {
- noex = NOEX_PROTECTED;
- }
+ if (SCOPE_TEST(SCOPE_PRIVATE)) {
+ noex = NOEX_PRIVATE;
+ }
+ else if (SCOPE_TEST(SCOPE_PROTECTED)) {
+ noex = NOEX_PROTECTED;
+ }
+ else {
+ noex = NOEX_PUBLIC;
}
rb_add_method(mod, id, node, noex);
return body;
@@ -10013,17 +9610,12 @@ Init_Proc()
rb_define_method(rb_eLocalJumpError, "reason", localjump_reason, 0);
rb_global_variable(&exception_error);
- exception_error = rb_exc_new3(rb_eFatal,
- rb_obj_freeze(rb_str_new2("exception reentered")));
- OBJ_TAINT(exception_error);
- OBJ_FREEZE(exception_error);
+ exception_error = rb_exc_new2(rb_eFatal, "exception reentered");
rb_eSysStackError = rb_define_class("SystemStackError", rb_eStandardError);
rb_global_variable(&sysstack_error);
- sysstack_error = rb_exc_new3(rb_eSysStackError,
- rb_obj_freeze(rb_str_new2("stack level too deep")));
+ sysstack_error = rb_exc_new2(rb_eSysStackError, "stack level too deep");
OBJ_TAINT(sysstack_error);
- OBJ_FREEZE(sysstack_error);
rb_cProc = rb_define_class("Proc", rb_cObject);
rb_undef_alloc_func(rb_cProc);
@@ -10031,9 +9623,9 @@ Init_Proc()
rb_define_method(rb_cProc, "clone", proc_clone, 0);
rb_define_method(rb_cProc, "dup", proc_dup, 0);
- rb_define_method(rb_cProc, "call", rb_proc_call, -2);
+ rb_define_method(rb_cProc, "call", proc_call, -2);
rb_define_method(rb_cProc, "arity", proc_arity, 0);
- rb_define_method(rb_cProc, "[]", rb_proc_call, -2);
+ rb_define_method(rb_cProc, "[]", proc_call, -2);
rb_define_method(rb_cProc, "==", proc_eq, 1);
rb_define_method(rb_cProc, "to_s", proc_to_s, 0);
rb_define_method(rb_cProc, "to_proc", proc_to_self, 0);
@@ -10053,9 +9645,6 @@ Init_Proc()
rb_define_method(rb_cMethod, "inspect", method_inspect, 0);
rb_define_method(rb_cMethod, "to_s", method_inspect, 0);
rb_define_method(rb_cMethod, "to_proc", method_proc, 0);
- rb_define_method(rb_cMethod, "receiver", method_receiver, 0);
- rb_define_method(rb_cMethod, "name", method_name, 0);
- rb_define_method(rb_cMethod, "owner", method_owner, 0);
rb_define_method(rb_cMethod, "unbind", method_unbind, 0);
rb_define_method(rb_mKernel, "method", rb_obj_method, 1);
@@ -10067,8 +9656,6 @@ Init_Proc()
rb_define_method(rb_cUnboundMethod, "arity", method_arity, 0);
rb_define_method(rb_cUnboundMethod, "inspect", method_inspect, 0);
rb_define_method(rb_cUnboundMethod, "to_s", method_inspect, 0);
- rb_define_method(rb_cUnboundMethod, "name", method_name, 0);
- rb_define_method(rb_cUnboundMethod, "owner", method_owner, 0);
rb_define_method(rb_cUnboundMethod, "bind", umethod_bind, 1);
rb_define_method(rb_cModule, "instance_method", rb_mod_method, 1);
}
@@ -10116,10 +9703,22 @@ Init_Binding()
rb_undef_method(CLASS_OF(rb_cBinding), "new");
rb_define_method(rb_cBinding, "clone", proc_clone, 0);
rb_define_method(rb_cBinding, "dup", proc_dup, 0);
- rb_define_method(rb_cBinding, "eval", bind_eval, -1);
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__
@@ -10184,6 +9783,13 @@ 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)
@@ -10201,9 +9807,70 @@ extern VALUE rb_last_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_NO_ENSURE 0x800 /* persistent flag */
-#define THREAD_FLAGS_MASK 0xfc00 /* mask for persistent flags */
+#define THREAD_FLAGS_MASK 0x400 /* 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)
@@ -10222,7 +9889,7 @@ struct thread_status_t {
int safe;
- enum rb_thread_status status;
+ enum thread_status status;
int wait_for;
int fd;
fd_set readfds;
@@ -10255,32 +9922,20 @@ struct thread_status_t {
(dst)->join = (src)->join, \
0)
-int
-rb_thread_set_raised(th)
- rb_thread_t th;
+static int
+thread_set_raised()
{
- if (th->flags & RAISED_EXCEPTION) {
- return 1;
- }
- th->flags |= RAISED_EXCEPTION;
+ if (curr_thread->flags & THREAD_RAISED) return 1;
+ curr_thread->flags |= THREAD_RAISED;
return 0;
}
-int
-rb_thread_reset_raised(th)
- rb_thread_t th;
-{
- if (!(th->flags & RAISED_EXCEPTION)) {
- return 0;
- }
- th->flags &= ~RAISED_EXCEPTION;
- return 1;
-}
-
static int
-thread_no_ensure()
+thread_reset_raised()
{
- return ((curr_thread->flags & THREAD_NO_ENSURE) == THREAD_NO_ENSURE);
+ if (!(curr_thread->flags & THREAD_RAISED)) return 0;
+ curr_thread->flags &= ~THREAD_RAISED;
+ return 1;
}
static void rb_thread_ready _((rb_thread_t));
@@ -10330,7 +9985,7 @@ rb_trap_eval(cmd, sig, safe)
static const char *
thread_status_name(status)
- enum rb_thread_status status;
+ enum thread_status status;
{
switch (status) {
case THREAD_RUNNABLE:
@@ -10384,13 +10039,6 @@ static double
timeofday()
{
struct timeval tv;
-#ifdef CLOCK_MONOTONIC
- struct timespec tp;
-
- if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0) {
- return (double)tp.tv_sec + (double)tp.tv_nsec * 1e-9;
- }
-#endif
gettimeofday(&tv, NULL);
return (double)tv.tv_sec + (double)tv.tv_usec * 1e-6;
}
@@ -10420,7 +10068,6 @@ 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;
@@ -10431,9 +10078,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
}
@@ -10519,7 +10166,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
@@ -10548,6 +10195,7 @@ 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
@@ -10558,16 +10206,13 @@ static int th_sig, th_safe;
#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)
rb_thread_t th;
{
VALUE *pos;
- size_t len;
+ int len;
static VALUE tval;
len = ruby_stack_length(&pos);
@@ -10582,19 +10227,22 @@ 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
- 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);
+#ifdef __ia64__
+ {
+ ucontext_t ctx;
+ VALUE *top, *bot;
+
+ getcontext(&ctx);
+ bot = (VALUE*)__libc_ia64_register_backing_store_base;
+#if defined(__FreeBSD__)
+ top = (VALUE*)ctx.uc_mcontext.mc_special.bspstore;
+#else
+ top = (VALUE*)ctx.uc_mcontext.sc_ar_bsp;
+#endif
+ th->bstr_len = top - bot;
+ REALLOC_N(th->bstr_ptr, VALUE, th->bstr_len);
+ MEMCPY(th->bstr_ptr, (VALUE*)__libc_ia64_register_backing_store_base, VALUE, th->bstr_len);
+ }
#endif
#ifdef SAVE_WIN32_EXCEPTION_LIST
th->win32_exception_list = win32_get_exception_list();
@@ -10624,10 +10272,6 @@ 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
@@ -10653,7 +10297,7 @@ rb_thread_switch(n)
rb_raise_jump(th_raise_exception);
break;
case RESTORE_SIGNAL:
- rb_thread_signal_raise(th_sig);
+ rb_raise(rb_eSignal, "SIG%s", th_signm);
break;
case RESTORE_EXIT:
ruby_errinfo = th_raise_exception;
@@ -10671,24 +10315,53 @@ rb_thread_switch(n)
}
#define THREAD_SAVE_CONTEXT(th) \
- (rb_thread_switch(ruby_setjmp(rb_thread_save_context(th), (th)->context)))
+ (rb_thread_save_context(th),\
+ rb_thread_switch((FLUSH_REGISTER_WINDOWS, ruby_setjmp((th)->context))))
NORETURN(static void rb_thread_restore_context _((rb_thread_t,int)));
-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 *)));
+
+# 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);
+}
static void
-rb_thread_restore_context_0(rb_thread_t th, int exit, void *vp)
+rb_thread_restore_context(th, exit)
+ rb_thread_t th;
+ int exit;
{
+ VALUE v;
static rb_thread_t tmp;
static int ex;
static VALUE tval;
- rb_trap_immediate = 0; /* inhibit interrupts from here */
- if (ruby_sandbox_restore != NULL)
- {
- ruby_sandbox_restore(th);
+ 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 */
ruby_frame = th->frame;
ruby_scope = th->scope;
ruby_class = th->klass;
@@ -10713,8 +10386,8 @@ rb_thread_restore_context_0(rb_thread_t th, int exit, void *vp)
ex = exit;
FLUSH_REGISTER_WINDOWS;
MEMCPY(tmp->stk_pos, tmp->stk_ptr, VALUE, tmp->stk_len);
-#ifdef __ia64
- MEMCPY(tmp->bstr_pos, tmp->bstr_ptr, VALUE, tmp->bstr_len);
+#ifdef __ia64__
+ MEMCPY((VALUE*)__libc_ia64_register_backing_store_base, tmp->bstr_ptr, VALUE, tmp->bstr_len);
#endif
tval = rb_lastline_get();
@@ -10727,78 +10400,6 @@ rb_thread_restore_context_0(rb_thread_t th, int exit, void *vp)
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;
@@ -10976,7 +10577,6 @@ rb_thread_schedule()
}
#endif
rb_thread_pending = 0;
- rb_gc_finalize_deferred();
if (curr_thread == curr_thread->next
&& curr_thread->status == THREAD_RUNNABLE)
return;
@@ -11389,12 +10989,14 @@ rb_thread_select(max, read, write, except, timeout)
return curr_thread->select_value;
}
+static int rb_thread_join _((rb_thread_t, double));
+
static int
rb_thread_join(th, limit)
rb_thread_t th;
double limit;
{
- enum rb_thread_status last_status = THREAD_RUNNABLE;
+ enum thread_status last_status = THREAD_RUNNABLE;
if (rb_thread_critical) rb_thread_deadlock();
if (!rb_thread_dead(th)) {
@@ -11417,7 +11019,7 @@ rb_thread_join(th, limit)
if (!rb_thread_dead(th)) return Qfalse;
}
- if (!NIL_P(th->errinfo) && (th->flags & RAISED_EXCEPTION)) {
+ if (!NIL_P(th->errinfo) && (th->flags & THREAD_RAISED)) {
VALUE oldbt = get_backtrace(th->errinfo);
VALUE errat = make_backtrace();
VALUE errinfo = rb_obj_dup(th->errinfo);
@@ -11584,19 +11186,10 @@ 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)
- return Qnil;
+ rb_raise(rb_eThreadError, "killed thread");
rb_thread_ready(th);
return thread;
@@ -11634,34 +11227,16 @@ rb_thread_run(thread)
}
-static void
-rb_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
- * thr.kill => thr
- * thr.terminate => thr
+ * thr.exit => thr or nil
+ * thr.kill => thr or nil
+ * thr.terminate => thr or nil
*
- * Terminates <i>thr</i> and schedules another thread to be run, returning
- * the terminated <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. If this thread
+ * is already marked to be killed, <code>exit</code> returns the
+ * <code>Thread</code>. If this is the main thread, or the last thread, exits
+ * the process.
*/
VALUE
@@ -11670,33 +11245,20 @@ rb_thread_kill(thread)
{
rb_thread_t th = rb_thread_check(thread);
- rb_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.
- */
+ 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);
-static VALUE
-rb_thread_kill_bang(thread)
- VALUE thread;
-{
- rb_thread_t th = rb_thread_check(thread);
- rb_kill_thread(th, THREAD_NO_ENSURE);
+ rb_thread_ready(th);
+ th->status = THREAD_TO_KILL;
+ if (!rb_thread_critical) rb_thread_schedule();
return thread;
}
+
/*
* call-seq:
* Thread.kill(thread) => thread
@@ -11786,7 +11348,7 @@ rb_thread_pass()
VALUE
rb_thread_stop()
{
- enum rb_thread_status last_status = THREAD_RUNNABLE;
+ enum thread_status last_status = THREAD_RUNNABLE;
rb_thread_critical = 0;
if (curr_thread == curr_thread->next) {
@@ -11851,12 +11413,10 @@ rb_thread_sleep_forever()
/*
* call-seq:
* thr.priority => integer
- *
- * 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.
- *
+ *
+ * Returns the priority of <i>thr</i>. Default is zero; higher-priority threads
+ * will run before lower-priority threads.
+ *
* Thread.current.priority #=> 0
*/
@@ -11871,10 +11431,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 }
@@ -12045,14 +11605,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 rb_thread);\
+ th = ALLOC(struct thread);\
\
th->next = 0;\
th->prev = 0;\
@@ -12067,7 +11627,6 @@ 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);\
@@ -12093,11 +11652,6 @@ 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
@@ -12117,7 +11671,7 @@ rb_thread_alloc(klass)
return th;
}
-static int thread_init;
+static int thread_init = 0;
#if defined(_THREAD_SAFE)
static void
@@ -12136,11 +11690,6 @@ static void*
thread_timer(dummy)
void *dummy;
{
- sigset_t all_signals;
-
- sigfillset(&all_signals);
- pthread_sigmask(SIG_BLOCK, &all_signals, 0);
-
for (;;) {
#ifdef HAVE_NANOSLEEP
struct timespec req, rem;
@@ -12222,7 +11771,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 rb_thread_status status;
+ enum thread_status status;
int state;
if (OBJ_FROZEN(curr_thread->thgroup)) {
@@ -12293,7 +11842,7 @@ rb_thread_start_0(fn, arg, th)
}
if (state && status != THREAD_TO_KILL && !NIL_P(ruby_errinfo)) {
- th->flags |= RAISED_EXCEPTION;
+ th->flags |= THREAD_RAISED;
if (state == TAG_FATAL) {
/* fatal error within this thread, need to stop whole script */
main_thread->errinfo = ruby_errinfo;
@@ -12330,7 +11879,7 @@ rb_thread_create(fn, arg)
VALUE (*fn)();
void *arg;
{
- Init_stack((void *)&arg);
+ Init_stack((VALUE*)&arg);
return rb_thread_start_0(fn, arg, rb_thread_alloc(rb_cThread));
}
@@ -12511,7 +12060,7 @@ rb_thread_status(thread)
rb_thread_t th = rb_thread_check(thread);
if (rb_thread_dead(th)) {
- if (!NIL_P(th->errinfo) && (th->flags & RAISED_EXCEPTION))
+ if (!NIL_P(th->errinfo) && (th->flags & THREAD_RAISED))
return Qnil;
return Qfalse;
}
@@ -12532,7 +12081,7 @@ rb_thread_status(thread)
* thr.alive? #=> false
*/
-VALUE
+static VALUE
rb_thread_alive_p(thread)
VALUE thread;
{
@@ -12669,15 +12218,13 @@ rb_thread_interrupt()
void
rb_thread_signal_raise(sig)
- int sig;
+ char *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);
- argv[0] = INT2FIX(sig);
- rb_exc_raise(rb_class_new_instance(1, argv, rb_eSignal));
+ rb_raise(rb_eSignal, "SIG%s", sig);
}
rb_thread_ready(main_thread);
if (!rb_thread_dead(curr_thread)) {
@@ -12685,7 +12232,7 @@ rb_thread_signal_raise(sig)
return;
}
}
- th_sig = sig;
+ th_signm = sig;
curr_thread = main_thread;
rb_thread_restore_context(curr_thread, RESTORE_SIGNAL);
}
@@ -12965,7 +12512,7 @@ static VALUE
rb_thread_inspect(thread)
VALUE thread;
{
- const char *cname = rb_obj_classname(thread);
+ char *cname = rb_obj_classname(thread);
rb_thread_t th = rb_thread_check(thread);
const char *status = thread_status_name(th->status);
VALUE str;
@@ -13320,109 +12867,6 @@ thgroup_add(group, thread)
}
-/* variables for recursive traversals */
-static ID recursive_key;
-
-static VALUE
-recursive_check(hash, obj)
- VALUE hash;
- VALUE obj;
-{
- if (NIL_P(hash) || TYPE(hash) != T_HASH) {
- return Qfalse;
- }
- else {
- VALUE list = rb_hash_aref(hash, ID2SYM(rb_frame_last_func()));
-
- if (NIL_P(list) || TYPE(list) != T_HASH)
- return Qfalse;
- if (NIL_P(rb_hash_lookup(list, obj)))
- return Qfalse;
- return Qtrue;
- }
-}
-
-static VALUE
-recursive_push(hash, obj)
- VALUE hash;
- VALUE obj;
-{
- VALUE list, sym;
-
- sym = ID2SYM(rb_frame_last_func());
- if (NIL_P(hash) || TYPE(hash) != T_HASH) {
- hash = rb_hash_new();
- rb_thread_local_aset(rb_thread_current(), recursive_key, hash);
- list = Qnil;
- }
- else {
- list = rb_hash_aref(hash, sym);
- }
- if (NIL_P(list) || TYPE(list) != T_HASH) {
- list = rb_hash_new();
- rb_hash_aset(hash, sym, list);
- }
- rb_hash_aset(list, obj, Qtrue);
- return hash;
-}
-
-static void
-recursive_pop(hash, obj)
- VALUE hash;
- VALUE obj;
-{
- VALUE list, sym;
-
- sym = ID2SYM(rb_frame_last_func());
- if (NIL_P(hash) || TYPE(hash) != T_HASH) {
- VALUE symname;
- VALUE thrname;
- symname = rb_inspect(sym);
- thrname = rb_inspect(rb_thread_current());
-
- rb_raise(rb_eTypeError, "invalid inspect_tbl hash for %s in %s",
- StringValuePtr(symname), StringValuePtr(thrname));
- }
- list = rb_hash_aref(hash, sym);
- if (NIL_P(list) || TYPE(list) != T_HASH) {
- VALUE symname = rb_inspect(sym);
- VALUE thrname = rb_inspect(rb_thread_current());
- rb_raise(rb_eTypeError, "invalid inspect_tbl list for %s in %s",
- StringValuePtr(symname), StringValuePtr(thrname));
- }
- rb_hash_delete(list, obj);
-}
-
-VALUE
-rb_exec_recursive(func, obj, arg)
- VALUE (*func) _((VALUE, VALUE, int));
- VALUE obj;
- VALUE arg;
-{
- VALUE hash = rb_thread_local_aref(rb_thread_current(), recursive_key);
- VALUE objid = rb_obj_id(obj);
-
- if (recursive_check(hash, objid)) {
- return (*func) (obj, arg, Qtrue);
- }
- else {
- VALUE result = Qundef;
- int state;
-
- hash = recursive_push(hash, objid);
- PUSH_TAG(PROT_NONE);
- if ((state = EXEC_TAG()) == 0) {
- result = (*func) (obj, arg, Qfalse);
- }
- POP_TAG();
- recursive_pop(hash, objid);
- if (state)
- JUMP_TAG(state);
- return result;
- }
-}
-
-
/*
* +Thread+ encapsulates the behavior of a thread of
* execution, including the main thread of the Ruby script.
@@ -13437,7 +12881,6 @@ Init_Thread()
{
VALUE cThGroup;
- recursive_key = rb_intern("__recursive_key__");
rb_eThreadError = rb_define_class("ThreadError", rb_eStandardError);
rb_cThread = rb_define_class("Thread", rb_cObject);
rb_undef_alloc_func(rb_cThread);
@@ -13466,9 +12909,6 @@ 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, "join", rb_thread_join_m, -1);
@@ -13640,3 +13080,13 @@ 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 d0d6317a5e..7b214abde3 100644
--- a/ext/Setup
+++ b/ext/Setup
@@ -28,7 +28,6 @@
#syck
#syslog
#tcltklib
-#thread
#tk
#win32ole
#zlib
diff --git a/ext/Setup.atheos b/ext/Setup.atheos
index 6bda3a4cfb..9b1bdecb95 100644
--- a/ext/Setup.atheos
+++ b/ext/Setup.atheos
@@ -28,7 +28,6 @@ strscan
syck
syslog
#tcltklib
-thread
#tk
#win32ole
zlib
diff --git a/ext/Setup.dj b/ext/Setup.dj
index 4f94788886..f2ed3a4f16 100644
--- a/ext/Setup.dj
+++ b/ext/Setup.dj
@@ -28,7 +28,6 @@ strscan
syck
#syslog
#tcltklib
-thread
#tk
#win32ole
zlib
diff --git a/ext/Setup.emx b/ext/Setup.emx
index afc5923577..7ea04543c5 100644
--- a/ext/Setup.emx
+++ b/ext/Setup.emx
@@ -28,7 +28,6 @@ strscan
#syck
#syslog
#tcltklib
-thread
#tk
#win32ole
#zlib
diff --git a/ext/Setup.nt b/ext/Setup.nt
index 9f8abf9b8d..7a330f801a 100644
--- a/ext/Setup.nt
+++ b/ext/Setup.nt
@@ -28,7 +28,6 @@ strscan
syck
#syslog
#tcltklib
-thread
#tk
win32ole
#zlib
diff --git a/ext/Setup.x68 b/ext/Setup.x68
index 0966e737e9..9b9563d941 100644
--- a/ext/Setup.x68
+++ b/ext/Setup.x68
@@ -28,7 +28,6 @@ strscan
#syck
#syslog
#tcltklib
-thread
#tk
#win32ole
#zlib
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 7400b313a4..6f215afa48 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_PTR(v)) + VpBaseFig() + 1,
- RSTRING_PTR(v));
+ return VpCreateRbObject(strlen(RSTRING(v)->ptr) + VpBaseFig() + 1,
+ RSTRING(v)->ptr);
#endif /* ENABLE_NUMERIC_STRING */
case T_BIGNUM:
bg = rb_big2str(v, 10);
- return VpCreateRbObject(strlen(RSTRING_PTR(bg)) + VpBaseFig() + 1,
- RSTRING_PTR(bg));
+ return VpCreateRbObject(strlen(RSTRING(bg)->ptr) + VpBaseFig() + 1,
+ RSTRING(bg)->ptr);
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_PTR(rb_inspect(v)):
+ RSTRING(rb_inspect(v))->ptr:
rb_obj_classname(v)
);
}
@@ -332,7 +332,7 @@ BigDecimal_load(VALUE self, VALUE str)
unsigned long m=0;
SafeStringValue(str);
- pch = (unsigned char *)RSTRING_PTR(str);
+ pch = RSTRING(str)->ptr;
/* 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,(char *)pch,self));
+ GUARD_OBJ(pv,VpNewRbClass(m,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, const char *str)
+VpCreateRbObject(U_LONG mx, char *str)
{
Real *pv = VpAlloc(mx,str);
pv->obj = (VALUE)Data_Wrap_Struct(rb_cBigDecimal, 0, BigDecimal_delete, pv);
@@ -784,6 +784,17 @@ 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
*
@@ -1268,7 +1279,7 @@ BigDecimal_round(int argc, VALUE *argv, VALUE self)
{
ENTER(5);
Real *c, *a;
- int iLoc = 0;
+ int iLoc;
U_LONG mx;
VALUE vLoc;
VALUE vRound;
@@ -1502,7 +1513,7 @@ 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_PTR(f);
+ psz = RSTRING(f)->ptr;
if(*psz==' ') {
fPlus = 1; psz++;
} else if(*psz=='+') {
@@ -1679,7 +1690,7 @@ BigDecimal_global_new(int argc, VALUE *argv, VALUE self)
mf = GetPositiveInt(nFig);
}
SafeStringValue(iniValue);
- GUARD_OBJ(pv,VpCreateRbObject(mf, RSTRING_PTR(iniValue)));
+ GUARD_OBJ(pv,VpCreateRbObject(mf, RSTRING(iniValue)->ptr));
return ToValue(pv);
}
@@ -1710,7 +1721,7 @@ BigDecimal_new(int argc, VALUE *argv, VALUE self)
mf = GetPositiveInt(nFig);
}
SafeStringValue(iniValue);
- GUARD_OBJ(pv,VpNewRbClass(mf, RSTRING_PTR(iniValue),self));
+ GUARD_OBJ(pv,VpNewRbClass(mf, RSTRING(iniValue)->ptr,self));
return ToValue(pv);
}
@@ -1803,94 +1814,76 @@ Init_bigdecimal(void)
/* Exceptions */
/*
- * 0xff: Determines whether overflow, underflow or zero divide result in
+ * 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));
/*
- * 0x02: Determines what happens when the result of a computation is not a
+ * 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));
/*
- * 0x01: Determines what happens when the result of a computation is
- * infinity. See BigDecimal.mode.
+ * 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));
/*
- * 0x04: Determines what happens when the result of a computation is an
- * underflow (a result too small to be represented). See BigDecimal.mode.
+ * 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));
/*
- * 0x01: Determines what happens when the result of a computation is an
- * underflow (a result too large to be represented). See BigDecimal.mode.
+ * 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));
/*
- * 0x01: Determines what happens when a division by zero is performed.
+ * Determines what happens when a division by zero is performed.
* See BigDecimal.mode.
*/
rb_define_const(rb_cBigDecimal, "EXCEPTION_ZERODIVIDE",INT2FIX(VP_EXCEPTION_ZERODIVIDE));
/*
- * 0x100: Determines what happens when a result must be rounded in order to
- * fit in the appropriate number of significant digits. See
+ * 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));
- /* 1: Indicates that values should be rounded away from zero. See
- * BigDecimal.mode.
- */
+ /* Indicates that values should be rounded away from zero. See BigDecimal.mode. */
rb_define_const(rb_cBigDecimal, "ROUND_UP",INT2FIX(VP_ROUND_UP));
-
- /* 2: Indicates that values should be rounded towards zero. See
- * BigDecimal.mode.
- */
+ /* Indicates that values should be rounded towards zero. See BigDecimal.mode. */
rb_define_const(rb_cBigDecimal, "ROUND_DOWN",INT2FIX(VP_ROUND_DOWN));
-
- /* 3: Indicates that digits >= 5 should be rounded up, others rounded down.
- * See BigDecimal.mode. */
+ /* 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));
-
- /* 4: Indicates that digits >= 6 should be rounded up, others rounded down.
- * See BigDecimal.mode.
- */
+ /* 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));
- /* 5: Round towards +infinity. See BigDecimal.mode. */
+ /* Round towards +infinity. See BigDecimal.mode. */
rb_define_const(rb_cBigDecimal, "ROUND_CEILING",INT2FIX(VP_ROUND_CEIL));
-
- /* 6: Round towards -infinity. See BigDecimal.mode. */
+ /* Round towards -infinity. See BigDecimal.mode. */
rb_define_const(rb_cBigDecimal, "ROUND_FLOOR",INT2FIX(VP_ROUND_FLOOR));
-
- /* 7: Round towards the even neighbor. See BigDecimal.mode. */
+ /* Round towards the even neighbor. See BigDecimal.mode. */
rb_define_const(rb_cBigDecimal, "ROUND_HALF_EVEN",INT2FIX(VP_ROUND_HALF_EVEN));
- /* 0: Indicates that a value is not a number. See BigDecimal.sign. */
+ /* Indicates that a value is not a number. See BigDecimal.sign. */
rb_define_const(rb_cBigDecimal, "SIGN_NaN",INT2FIX(VP_SIGN_NaN));
-
- /* 1: Indicates that a value is +0. See BigDecimal.sign. */
+ /* Indicates that a value is +0. See BigDecimal.sign. */
rb_define_const(rb_cBigDecimal, "SIGN_POSITIVE_ZERO",INT2FIX(VP_SIGN_POSITIVE_ZERO));
-
- /* -1: Indicates that a value is -0. See BigDecimal.sign. */
+ /* Indicates that a value is -0. See BigDecimal.sign. */
rb_define_const(rb_cBigDecimal, "SIGN_NEGATIVE_ZERO",INT2FIX(VP_SIGN_NEGATIVE_ZERO));
-
- /* 2: Indicates that a value is positive and finite. See BigDecimal.sign. */
+ /* Indicates that a value is positive and finite. See BigDecimal.sign. */
rb_define_const(rb_cBigDecimal, "SIGN_POSITIVE_FINITE",INT2FIX(VP_SIGN_POSITIVE_FINITE));
-
- /* -2: Indicates that a value is negative and finite. See BigDecimal.sign. */
+ /* Indicates that a value is negative and finite. See BigDecimal.sign. */
rb_define_const(rb_cBigDecimal, "SIGN_NEGATIVE_FINITE",INT2FIX(VP_SIGN_NEGATIVE_FINITE));
-
- /* 3: Indicates that a value is positive and infinite. See BigDecimal.sign. */
+ /* Indicates that a value is positive and infinite. See BigDecimal.sign. */
rb_define_const(rb_cBigDecimal, "SIGN_POSITIVE_INFINITE",INT2FIX(VP_SIGN_POSITIVE_INFINITE));
-
- /* -3: Indicates that a value is negative and infinite. See BigDecimal.sign. */
+ /* 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 */
@@ -1931,6 +1924,7 @@ 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);
@@ -2188,7 +2182,7 @@ VpIsNegDoubleZero(double v)
}
VP_EXPORT int
-VpException(unsigned short f, const char *str,int always)
+VpException(unsigned short f,char *str,int always)
{
VALUE exc;
int fatal=0;
@@ -2225,8 +2219,8 @@ VpException(unsigned short f, const char *str,int always)
return 0; /* 0 Means VpException() raised no exception */
raise:
- if(fatal) rb_fatal("%s", str);
- else rb_raise(exc, "%s", str);
+ if(fatal) rb_fatal(str);
+ else rb_raise(exc,str);
return 0;
}
@@ -2330,7 +2324,7 @@ NaN:
* returns number of chars needed to represent vp in specified format.
*/
VP_EXPORT U_LONG
-VpNumOfChars(Real *vp,const char *pszFmt)
+VpNumOfChars(Real *vp,char *pszFmt)
{
S_INT ex;
U_LONG nc;
@@ -2425,7 +2419,7 @@ VpInit(U_LONG BaseVal)
}
VP_EXPORT Real *
-VpOne(void)
+VpOne()
{
return VpConstOne;
}
@@ -2475,7 +2469,7 @@ overflow:
* NULL be returned if memory allocation is failed,or any error.
*/
VP_EXPORT Real *
-VpAlloc(U_LONG mx, const char *szVal)
+VpAlloc(U_LONG mx, char *szVal)
{
U_LONG i, ni, ipn, ipf, nf, ipe, ne, nalloc;
char v,*psz;
@@ -3890,7 +3884,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, const char *int_chr, U_LONG ni, const char *frac, U_LONG nf, const char *exp_chr, U_LONG ne)
+VpCtoV(Real *a, char *int_chr, U_LONG ni, char *frac, U_LONG nf, char *exp_chr, U_LONG ne)
{
U_LONG i, j, ind_a, ma, mi, me;
U_LONG loc;
@@ -4345,11 +4339,6 @@ VpMidRound(Real *y, int f, int nf)
nf += y->exponent*((int)BASE_FIG);
exptoadd=0;
if (nf < 0) {
- /* rounding position too left(large). */
- if((f!=VP_ROUND_CEIL) && (f!=VP_ROUND_FLOOR)) {
- VpSetZero(y,VpGetSign(y)); /* truncate everything */
- return 0;
- }
exptoadd = -nf;
nf = 0;
}
diff --git a/ext/bigdecimal/bigdecimal.h b/ext/bigdecimal/bigdecimal.h
index 4f77feab00..aabc551a76 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,const char *str);
+VP_EXPORT Real *VpCreateRbObject(U_LONG mx,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,const char *str,int always);
+VP_EXPORT int VpException(unsigned short f,char *str,int always);
VP_EXPORT int VpIsNegDoubleZero(double v);
-VP_EXPORT U_LONG VpNumOfChars(Real *vp,const char *pszFmt);
+VP_EXPORT U_LONG VpNumOfChars(Real *vp,char *pszFmt);
VP_EXPORT U_LONG VpInit(U_LONG BaseVal);
VP_EXPORT void *VpMemAlloc(U_LONG mb);
VP_EXPORT void VpFree(Real *pv);
-VP_EXPORT Real *VpAlloc(U_LONG mx, const char *szVal);
+VP_EXPORT Real *VpAlloc(U_LONG mx, char *szVal);
VP_EXPORT int VpAsgn(Real *c,Real *a,int isw);
VP_EXPORT int VpAddSub(Real *c,Real *a,Real *b,int operation);
VP_EXPORT int VpMult(Real *c,Real *a,Real *b);
@@ -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,const char *int_chr,U_LONG ni,const char *frac,U_LONG nf,const char *exp_chr,U_LONG ne);
+VP_EXPORT int VpCtoV(Real *a,char *int_chr,U_LONG ni,char *frac,U_LONG nf,char *exp_chr,U_LONG ne);
VP_EXPORT int VpVtoD(double *d,S_LONG *e,Real *m);
VP_EXPORT void VpDtoV(Real *m,double d);
VP_EXPORT void VpItoV(Real *m,S_INT ival);
@@ -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(void);
+VP_EXPORT Real *VpOne();
/*
* ------------------
diff --git a/ext/bigdecimal/bigdecimal_en.html b/ext/bigdecimal/bigdecimal_en.html
index c2b86faef6..02c88df43e 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 a string representing a positive integer number.
+n can be an string representing a positive integer number.
<CODE><PRE>
BigDecimal("0.1234567890123456789").to_s("10") # ==> "0.1234567890 123456789E0"
</PRE></CODE>
@@ -678,9 +678,10 @@ structure.
</DL>
<H3>Disadvantage of decimal representation</H3>
-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.
+Advantages stated so far can also be disadvantages if the input from outside is
+ represented in binary.
+Translation error from decimal to binary or vice versa is inevitable.
+So,translation from Float(binary) to BigDecimal(decimal) is not alway done exactly.
<H4>Which is the first input?</H4>
Because most people uses decimal notatin for numeric data representation,
diff --git a/ext/bigdecimal/bigdecimal_ja.html b/ext/bigdecimal/bigdecimal_ja.html
index 37bbcbbb09..8fd95a6fe3 100644
--- a/ext/bigdecimal/bigdecimal_ja.html
+++ b/ext/bigdecimal/bigdecimal_ja.html
@@ -676,11 +676,10 @@ exponent=1Asign=2 ‚Ȃ甒l‚ª 1234.56784321 ‚Å‚ ‚é‚̂͌©‚ê‚Î’¼‚®‚É•ª‚©‚è‚Ü‚·B
<H3>10i‚̃fƒƒŠƒbƒg</H3>
ŽÀ‚Í¡‚܂ł̃ƒŠƒbƒg‚ÍA‚»‚̂܂܃fƒƒŠƒbƒg‚É‚à‚È‚è‚Ü‚·B
-‚»‚à‚»‚àA10i‚ð2i‚ɕϊ·‚·‚邿‚¤‚È‘€ì‚͕ϊ·Œë·
+‚»‚à‚»‚àA10i‚ð2iA2i‚ð10i‚ɕϊ·‚·‚邿‚¤‚È‘€ì‚͕ϊ·Œë·
‚𔺂¤ê‡‚ð‰ñ”ð‚·‚é‚±‚Ƃ͂ł«‚Ü‚¹‚ñB
-‘åŠT‚̃Rƒ“ƒsƒ…[ƒ^‚Í10i‚Ì“à•”•\Œ»‚ðŽ‚Á‚Ä‚¢‚È‚¢‚Ì‚ÅA
-BigDecimal ‚ð—˜—p‚µ‚Č뷖³‚µ‚ÌŒvŽZ‚ð‚·‚éꇂÍAŒvŽZ‘¬“x
-‚𖳎‹‚µ‚Ä‚àÅŒã‚܂ŠBigDecimal ‚ðŽg—p‘±‚¯‚é•K—v‚ª‚ ‚è‚Ü‚·B
+Šù‚ÉŒvŽZ‹@“à•”‚ÉŽæ‚螂܂ꂽ2i”’l‚ð BigDecimal ‚Ì“à•”•\Œ»‚É
+•ÏŠ·‚·‚邯‚«‚ɂ͌뷂ª”ð‚¯‚ç‚ê‚È‚¢ê‡‚ª‚ ‚è‚Ü‚·B
<H3>ʼn‚͉½‚©H</H3>
Ž©•ª‚ÅŒvŽZ‚·‚邯‚«‚ɂ킴‚í‚´2i”‚ðŽg‚¤l‚͋ɂ߂Ă܂ê‚Å‚·B
diff --git a/ext/bigdecimal/extconf.rb b/ext/bigdecimal/extconf.rb
index 0c8b98e4a3..864aaad862 100644
--- a/ext/bigdecimal/extconf.rb
+++ b/ext/bigdecimal/extconf.rb
@@ -1,7 +1,9 @@
require 'mkmf'
base_fig = 0
-src = "(BASE * (BASE+1)) / BASE == (BASE+1)"
+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
diff --git a/ext/curses/curses.c b/ext/curses/curses.c
index 9c51a2127f..4e84b0837f 100644
--- a/ext/curses/curses.c
+++ b/ext/curses/curses.c
@@ -1,5 +1,5 @@
/* -*- C -*-
- * $Id$
+ * $Id: curses.c,v 1.24.2.8 2006/07/18 05:08:34 matz Exp $
*
* ext/curses/curses.c
*
@@ -1255,6 +1255,7 @@ 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/dbm/dbm.c b/ext/dbm/dbm.c
index 0247387fdc..83e6a9893b 100644
--- a/ext/dbm/dbm.c
+++ b/ext/dbm/dbm.c
@@ -2,8 +2,8 @@
dbm.c -
- $Author$
- $Date$
+ $Author: usa $
+ $Date: 2005/06/20 07:53:19 $
created at: Mon Jan 24 15:59:52 JST 1994
Copyright (C) 1995-2001 Yukihiro Matsumoto
@@ -812,7 +812,5 @@ Init_dbm()
#ifdef DB_VERSION_STRING
rb_define_const(rb_cDBM, "VERSION", rb_str_new2(DB_VERSION_STRING));
-#else
- rb_define_const(rb_cDBM, "VERSION", rb_str_new2("unknown"));
#endif
}
diff --git a/ext/dbm/extconf.rb b/ext/dbm/extconf.rb
index 0074ab605b..52ec688952 100644
--- a/ext/dbm/extconf.rb
+++ b/ext/dbm/extconf.rb
@@ -2,13 +2,9 @@ require 'mkmf'
dir_config("dbm")
-if dblib = with_config("dbm-type", nil)
- dblib = dblib.split(/[ ,]+/)
-else
- dblib = %w(db db2 db1 dbm gdbm gdbm_compat qdbm)
-end
+dblib = with_config("dbm-type", nil)
-headers = {
+$dbm_conf_headers = {
"db" => ["db.h"],
"db1" => ["db1/ndbm.h", "db1.h", "ndbm.h"],
"db2" => ["db2/db.h", "db2.h", "db.h"],
@@ -18,36 +14,48 @@ headers = {
"qdbm" => ["relic.h"],
}
-def headers.db_check(db)
- db_prefix = nil
- have_gdbm = false
- hsearch = nil
+def db_check(db)
+ $dbm_conf_db_prefix = ""
+ $dbm_conf_have_gdbm = false
+ hsearch = ""
case db
when /^db2?$/
- db_prefix = "__db_n"
+ $dbm_conf_db_prefix = "__db_n"
hsearch = "-DDB_DBM_HSEARCH "
when "gdbm"
- have_gdbm = true
+ $dbm_conf_have_gdbm = true
when "gdbm_compat"
- have_gdbm = true
+ $dbm_conf_have_gdbm = true
have_library("gdbm") or return false
end
- 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
+
+ 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)
end
end
-if dblib.any? {|db| headers.db_check(db)}
- have_header("cdefs.h")
- have_header("sys/cdefs.h")
+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
create_makefile("dbm")
end
diff --git a/ext/digest/bubblebabble/bubblebabble.c b/ext/digest/bubblebabble/bubblebabble.c
deleted file mode 100644
index 3a03ceced0..0000000000
--- a/ext/digest/bubblebabble/bubblebabble.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/************************************************
-
- 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
deleted file mode 100644
index b20148ded4..0000000000
--- a/ext/digest/bubblebabble/depend
+++ /dev/null
@@ -1,3 +0,0 @@
-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
deleted file mode 100644
index 53cb83934a..0000000000
--- a/ext/digest/bubblebabble/extconf.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-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 b9a3470e65..d51c627cf9 100644
--- a/ext/digest/defs.h
+++ b/ext/digest/defs.h
@@ -1,5 +1,5 @@
/* -*- C -*-
- * $Id$
+ * $Id: defs.h,v 1.7 2003/06/01 15:39:52 eban Exp $
*/
#ifndef DEFS_H
@@ -23,8 +23,12 @@
typedef unsigned int uint32_t;
# if SIZEOF_LONG == 8
typedef unsigned long uint64_t;
-# elif SIZEOF_LONG_LONG == 8
- typedef unsigned LONG_LONG uint64_t;
+# elif defined(__GNUC__)
+ typedef unsigned long long uint64_t;
+# elif defined(_MSC_VER)
+ typedef unsigned _int64 uint64_t;
+# elif defined(__BORLANDC__)
+ typedef unsigned __int64 uint64_t;
# else
# define NO_UINT64_T
# endif
diff --git a/ext/digest/digest.c b/ext/digest/digest.c
index 0b910e8c47..957fe4f6ea 100644
--- a/ext/digest/digest.c
+++ b/ext/digest/digest.c
@@ -2,491 +2,157 @@
digest.c -
- $Author$
+ $Author: matz $
created at: Fri May 25 08:57:27 JST 2001
Copyright (C) 1995-2001 Yukihiro Matsumoto
- Copyright (C) 2001-2006 Akinori MUSHA
+ Copyright (C) 2001 Akinori MUSHA
$RoughId: digest.c,v 1.16 2001/07/13 15:38:27 knu Exp $
- $Id$
+ $Id: digest.c,v 1.14.2.2 2005/12/12 00:36:51 matz Exp $
************************************************/
-#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);
-
/*
- * Document-module: Digest
+ * This module provides an interface to the following hash algorithms:
*
- * 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 MD5 Message-Digest Algorithm by the RSA Data Security,
+ * Inc., described in RFC 1321
*
- * 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 SHA-1 Secure Hash Algorithm by NIST (the US' National
+ * Institute of Standards and Technology), described in FIPS PUB
+ * 180-1.
*
- * This module provides instance methods for a digest implementation
- * object to calculate message digest values.
- */
-
-/*
- * 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()", RSTRING_PTR(rb_inspect(self)));
-}
-
-/*
- * call-seq:
- * digest_obj.instance_eval { finish } -> digest_obj
+ * - the SHA-256/384/512 Secure Hash Algorithm by NIST (the US'
+ * National Institute of Standards and Technology), described in
+ * FIPS PUB 180-2.
*
- * 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.
+ * - the RIPEMD-160 cryptographic hash function, designed by Hans
+ * Dobbertin, Antoon Bosselaers, and Bart Preneel.
*/
-static VALUE
-rb_digest_instance_finish(VALUE self)
-{
- rb_raise(rb_eRuntimeError, "%s does not implement finish()", RSTRING_PTR(rb_inspect(self)));
-}
-/*
- * 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()", RSTRING_PTR(rb_inspect(self)));
-}
+#include "digest.h"
-/*
- * 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 clone = rb_obj_clone(self);
- rb_funcall(clone, id_reset, 0);
- return clone;
-}
+static VALUE mDigest, cDigest_Base;
+static ID id_metadata;
/*
- * 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.
+ * Digest::Base
*/
-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);
- }
-
- return value;
-}
-/*
- * 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)
+static algo_t *
+get_digest_base_metadata(klass)
+ VALUE klass;
{
- VALUE value = rb_funcall(self, id_finish, 0);
- rb_funcall(self, id_reset, 0);
-
- return value;
-}
+ VALUE obj;
+ algo_t *algo;
-/*
- * 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_instance_hexdigest(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);
+ if (rb_cvar_defined(klass, id_metadata) == Qfalse) {
+ rb_notimplement();
}
- return hexencode_str_new(value);
-}
-
-/*
- * 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 = rb_cvar_get(klass, id_metadata);
- return hexencode_str_new(value);
-}
+ Data_Get_Struct(obj, algo_t, algo);
-/*
- * 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_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;
+ return algo;
}
-/*
- * 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_base_alloc _((VALUE));
static VALUE
-rb_digest_instance_equal(VALUE self, VALUE other)
+rb_digest_base_alloc(klass)
+ VALUE klass;
{
- VALUE str1, str2;
-
- 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;
- }
-
- /* never blindly assume that subclass methods return strings */
- StringValue(str1);
- StringValue(str2);
+ algo_t *algo;
+ VALUE obj;
+ void *pctx;
- if (RSTRING_LEN(str1) == RSTRING_LEN(str2) &&
- rb_str_cmp(str1, str2) == 0) {
- return Qtrue;
+ if (klass == cDigest_Base) {
+ rb_raise(rb_eNotImpError, "Digest::Base is an abstract class");
}
- return Qfalse;
-}
-/*
- * 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);
+ algo = get_digest_base_metadata(klass);
- /* never blindly assume that #digest() returns a string */
- StringValue(digest);
- return INT2NUM(RSTRING_LEN(digest));
-}
+ /* XXX: An uninitialized buffer leads ALGO_Equal() to fail */
+ pctx = xcalloc(algo->ctx_size, 1);
+ algo->init_func(pctx);
-/*
- * 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);
-}
+ obj = Data_Wrap_Struct(klass, 0, free, pctx);
-/*
- * 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()", RSTRING_PTR(rb_inspect(self)));
+ return obj;
}
-/*
- * 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_class_s_digest(int argc, VALUE *argv, VALUE klass)
-{
+rb_digest_base_s_digest(klass, str)
+ VALUE klass;
VALUE str;
- volatile VALUE obj;
-
- if (argc < 1) {
- rb_raise(rb_eArgError, "no data given");
- }
-
- str = *argv++;
- argc--;
-
- StringValue(str);
-
- 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;
+ algo_t *algo;
+ void *pctx;
+ size_t len;
+ unsigned char *digest;
+ volatile VALUE obj = rb_digest_base_alloc(klass);
- for (p = klass; p; p = RCLASS(p)->super) {
- if (rb_ivar_defined(p, id_metadata)) {
- obj = rb_ivar_get(p, id_metadata);
- break;
- }
- }
+ algo = get_digest_base_metadata(klass);
+ Data_Get_Struct(obj, void, pctx);
- if (!p)
- rb_raise(rb_eRuntimeError, "Digest::Base cannot be directly inherited in Ruby");
+ StringValue(str);
+ algo->update_func(pctx, RSTRING(str)->ptr, RSTRING(str)->len);
- Data_Get_Struct(obj, rb_digest_metadata_t, algo);
+ len = algo->digest_len;
- switch (algo->api_version) {
- case 2:
- break;
+ digest = xmalloc(len);
+ algo->final_func(digest, pctx);
- /*
- * put conversion here if possible when API is updated
- */
+ obj = rb_str_new(digest, len);
- default:
- rb_raise(rb_eRuntimeError, "Incompatible digest API version");
- }
+ free(digest);
- return algo;
+ return obj;
}
static VALUE
-rb_digest_base_alloc(VALUE klass)
+rb_digest_base_s_hexdigest(klass, str)
+ VALUE klass;
+ VALUE str;
{
- rb_digest_metadata_t *algo;
- VALUE obj;
+ algo_t *algo;
void *pctx;
-
- if (klass == rb_cDigest_Base) {
- rb_raise(rb_eNotImpError, "Digest::Base is an abstract class");
- }
+ size_t len;
+ unsigned char *hexdigest;
+ volatile VALUE obj = rb_digest_base_alloc(klass);
algo = get_digest_base_metadata(klass);
+ Data_Get_Struct(obj, void, pctx);
- pctx = xmalloc(algo->ctx_size);
- algo->init_func(pctx);
+ StringValue(str);
+ algo->update_func(pctx, RSTRING(str)->ptr, RSTRING(str)->len);
- obj = Data_Wrap_Struct(klass, 0, free, pctx);
+ len = algo->digest_len * 2;
+
+ hexdigest = xmalloc(len + 1); /* +1 is for '\0' */
+ algo->end_func(pctx, hexdigest);
+
+ obj = rb_str_new(hexdigest, len);
+
+ free(hexdigest);
return obj;
}
-/* :nodoc: */
static VALUE
-rb_digest_base_copy(VALUE copy, VALUE obj)
+rb_digest_base_copy(copy, obj)
+ VALUE copy, obj;
{
- rb_digest_metadata_t *algo;
+ algo_t *algo;
void *pctx1, *pctx2;
if (copy == obj) return copy;
-
rb_check_frozen(copy);
-
algo = get_digest_base_metadata(rb_obj_class(copy));
-
+ if (algo != get_digest_base_metadata(rb_obj_class(obj))) {
+ rb_raise(rb_eTypeError, "wrong argument class");
+ }
Data_Get_Struct(obj, void, pctx1);
Data_Get_Struct(copy, void, pctx2);
memcpy(pctx2, pctx1, algo->ctx_size);
@@ -494,149 +160,157 @@ rb_digest_base_copy(VALUE copy, VALUE obj)
return copy;
}
-/* :nodoc: */
static VALUE
-rb_digest_base_reset(VALUE self)
+rb_digest_base_update(self, str)
+ VALUE self, str;
{
- rb_digest_metadata_t *algo;
+ algo_t *algo;
void *pctx;
+ StringValue(str);
algo = get_digest_base_metadata(rb_obj_class(self));
-
Data_Get_Struct(self, void, pctx);
- algo->init_func(pctx);
+ algo->update_func(pctx, RSTRING(str)->ptr, RSTRING(str)->len);
return self;
}
-/* :nodoc: */
static VALUE
-rb_digest_base_update(VALUE self, VALUE str)
+rb_digest_base_init(argc, argv, self)
+ int argc;
+ VALUE* argv;
+ VALUE self;
{
- rb_digest_metadata_t *algo;
- void *pctx;
-
- algo = get_digest_base_metadata(rb_obj_class(self));
+ VALUE arg;
- Data_Get_Struct(self, void, pctx);
+ rb_scan_args(argc, argv, "01", &arg);
- StringValue(str);
- algo->update_func(pctx, (unsigned char *)RSTRING_PTR(str), RSTRING_LEN(str));
+ if (!NIL_P(arg)) rb_digest_base_update(self, arg);
return self;
}
-/* :nodoc: */
static VALUE
-rb_digest_base_finish(VALUE self)
+rb_digest_base_digest(self)
+ VALUE self;
{
- rb_digest_metadata_t *algo;
- void *pctx;
+ algo_t *algo;
+ void *pctx1, *pctx2;
+ unsigned char *digest;
+ size_t len;
VALUE str;
algo = get_digest_base_metadata(rb_obj_class(self));
+ Data_Get_Struct(self, void, pctx1);
- Data_Get_Struct(self, void, pctx);
+ len = algo->ctx_size;
- str = rb_str_new(0, algo->digest_len);
- algo->finish_func(pctx, (unsigned char *)RSTRING_PTR(str));
+ pctx2 = xmalloc(len);
+ memcpy(pctx2, pctx1, len);
- /* avoid potential coredump caused by use of a finished context */
- algo->init_func(pctx);
+ len = algo->digest_len;
+
+ digest = xmalloc(len);
+ algo->final_func(digest, pctx2);
+
+ str = rb_str_new(digest, len);
+
+ free(digest);
+ free(pctx2);
return str;
}
-/* :nodoc: */
static VALUE
-rb_digest_base_digest_length(VALUE self)
+rb_digest_base_hexdigest(self)
+ VALUE self;
{
- rb_digest_metadata_t *algo;
+ algo_t *algo;
+ void *pctx1, *pctx2;
+ unsigned char *hexdigest;
+ size_t len;
+ VALUE str;
algo = get_digest_base_metadata(rb_obj_class(self));
+ Data_Get_Struct(self, void, pctx1);
+
+ len = algo->ctx_size;
+
+ pctx2 = xmalloc(len);
+ memcpy(pctx2, pctx1, len);
+
+ len = algo->digest_len * 2;
- return INT2NUM(algo->digest_len);
+ 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;
}
-/* :nodoc: */
static VALUE
-rb_digest_base_block_length(VALUE self)
+rb_digest_base_equal(self, other)
+ VALUE self, other;
{
- rb_digest_metadata_t *algo;
+ algo_t *algo;
+ VALUE klass;
+ VALUE str1, str2;
- algo = get_digest_base_metadata(rb_obj_class(self));
+ klass = rb_obj_class(self);
+ algo = get_digest_base_metadata(klass);
- return INT2NUM(algo->block_len);
+ if (rb_obj_class(other) == klass) {
+ void *pctx1, *pctx2;
+
+ Data_Get_Struct(self, void, pctx1);
+ Data_Get_Struct(other, void, pctx2);
+
+ return algo->equal_func(pctx1, pctx2) ? Qtrue : Qfalse;
+ }
+
+ StringValue(other);
+ str2 = other;
+
+ if (RSTRING(str2)->len == algo->digest_len)
+ str1 = rb_digest_base_digest(self);
+ else
+ str1 = rb_digest_base_hexdigest(self);
+
+ if (RSTRING(str1)->len == RSTRING(str2)->len
+ && rb_str_cmp(str1, str2) == 0)
+ return Qtrue;
+
+ return Qfalse;
}
+/*
+ * Init
+ */
+
void
-Init_digest(void)
+Init_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);
+ mDigest = rb_define_module("Digest");
- id_metadata = rb_intern("metadata");
+ cDigest_Base = rb_define_class_under(mDigest, "Base", rb_cObject);
- /* class Digest::Base < Digest::Class */
- rb_cDigest_Base = rb_define_class_under(rb_mDigest, "Base", rb_cDigest_Class);
+ rb_define_alloc_func(cDigest_Base, rb_digest_base_alloc);
+ rb_define_singleton_method(cDigest_Base, "digest", rb_digest_base_s_digest, 1);
+ rb_define_singleton_method(cDigest_Base, "hexdigest", rb_digest_base_s_hexdigest, 1);
- rb_define_alloc_func(rb_cDigest_Base, rb_digest_base_alloc);
+ 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_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);
+ id_metadata = rb_intern("metadata");
}
diff --git a/ext/digest/digest.h b/ext/digest/digest.h
index 6e4906c859..578be0a3c4 100644
--- a/ext/digest/digest.h
+++ b/ext/digest/digest.h
@@ -1,32 +1,32 @@
/************************************************
- digest.h - header file for ruby digest modules
+ digest.c -
- $Author$
+ $Author: knu $
created at: Fri May 25 08:54:56 JST 2001
- Copyright (C) 2001-2006 Akinori MUSHA
+ Copyright (C) 2001 Akinori MUSHA
$RoughId: digest.h,v 1.3 2001/07/13 15:38:27 knu Exp $
- $Id$
+ $Id: digest.h,v 1.1 2001/07/13 20:06:13 knu Exp $
************************************************/
#include "ruby.h"
-#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 void (*hash_init_func_t) _((void *));
+typedef void (*hash_update_func_t) _((void *, unsigned char *, size_t));
+typedef void (*hash_end_func_t) _((void *, unsigned char *));
+typedef void (*hash_final_func_t) _((unsigned char *, void *));
+typedef int (*hash_equal_func_t) _((void *, void *));
typedef struct {
- int api_version;
size_t digest_len;
- size_t block_len;
size_t ctx_size;
- 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;
+ hash_init_func_t init_func;
+ hash_update_func_t update_func;
+ hash_end_func_t end_func;
+ hash_final_func_t final_func;
+ hash_equal_func_t equal_func;
+} algo_t;
diff --git a/ext/digest/digest.txt b/ext/digest/digest.txt
new file mode 100644
index 0000000000..4969a9da90
--- /dev/null
+++ b/ext/digest/digest.txt
@@ -0,0 +1,113 @@
+.\" digest.txt - -*- Indented-Text -*- created at: Fri May 25 08:13:50 JST 2001
+$RoughId: digest.txt,v 1.9 2001/07/13 19:46:51 knu Exp $
+$Id: 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
new file mode 100644
index 0000000000..7078c83573
--- /dev/null
+++ b/ext/digest/digest.txt.ja
@@ -0,0 +1,111 @@
+.\" digest.txt.ja - -*- Indented-Text -*- created at: Fri May 25 08:22:19 JST 2001
+$RoughId: digest.txt.jp,v 1.8 2001/07/13 15:38:27 knu Exp $
+$Id: 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 cf9127ecc0..3e35bf5064 100644
--- a/ext/digest/extconf.rb
+++ b/ext/digest/extconf.rb
@@ -1,10 +1,6 @@
# $RoughId: extconf.rb,v 1.6 2001/07/13 15:38:27 knu Exp $
-# $Id$
+# $Id: extconf.rb,v 1.1 2001/07/13 20:06:13 knu Exp $
require "mkmf"
-$INSTALLFILES = {
- "digest.h" => "$(RUBYARCHDIR)"
-}
-
create_makefile("digest")
diff --git a/ext/digest/lib/digest.rb b/ext/digest/lib/digest.rb
deleted file mode 100644
index 0c4ee3c2cc..0000000000
--- a/ext/digest/lib/digest.rb
+++ /dev/null
@@ -1,50 +0,0 @@
-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}", caller(1)
- end
- unless Digest.const_defined?(name)
- raise NameError, "uninitialized constant Digest::#{name}", caller(1)
- 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 c399f2de1d..6867fdc71b 100644
--- a/ext/digest/lib/md5.rb
+++ b/ext/digest/lib/md5.rb
@@ -1,23 +1,14 @@
# just for compatibility; requiring "md5" is obsoleted
#
# $RoughId: md5.rb,v 1.4 2001/07/13 15:38:27 knu Exp $
-# $Id$
+# $Id: md5.rb,v 1.1 2001/07/13 20:06:14 knu Exp $
require '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
+MD5 = Digest::MD5
- def md5(*args)
- new(*args)
- end
+class MD5
+ def self.md5(*args)
+ new(*args)
end
end
diff --git a/ext/digest/lib/sha1.rb b/ext/digest/lib/sha1.rb
index 4446e12e8d..12fb5cdfa4 100644
--- a/ext/digest/lib/sha1.rb
+++ b/ext/digest/lib/sha1.rb
@@ -1,23 +1,14 @@
# just for compatibility; requiring "sha1" is obsoleted
#
# $RoughId: sha1.rb,v 1.4 2001/07/13 15:38:27 knu Exp $
-# $Id$
+# $Id: sha1.rb,v 1.1 2001/07/13 20:06:14 knu Exp $
require '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
+SHA1 = Digest::SHA1
- def sha1(*args)
- new(*args)
- end
+class SHA1
+ def self.sha1(*args)
+ new(*args)
end
end
diff --git a/ext/digest/md5/extconf.rb b/ext/digest/md5/extconf.rb
index 018f8ccb02..ea29c9c5f8 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$
+# $Id: extconf.rb,v 1.4.2.2 2006/05/25 23:44:05 nobu Exp $
require "mkmf"
@@ -24,6 +24,4 @@ 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 993bc47a06..ed32cf95c1 100644
--- a/ext/digest/md5/md5.c
+++ b/ext/digest/md5/md5.c
@@ -41,15 +41,9 @@
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$ */
+/*$Id: md5.c,v 1.1 2001/07/13 20:06:14 knu Exp $ */
#include "md5.h"
@@ -397,7 +391,7 @@ MD5_Update(MD5_CTX *pms, const uint8_t *data, size_t nbytes)
}
void
-MD5_Finish(MD5_CTX *pms, uint8_t *digest)
+MD5_Final(uint8_t *digest, MD5_CTX *pms)
{
static const uint8_t pad[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -418,3 +412,21 @@ MD5_Finish(MD5_CTX *pms, uint8_t *digest)
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 f4580ef5e7..736e034512 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$ */
+/* $Id: md5.h,v 1.2 2002/02/24 08:20:22 knu Exp $ */
#ifndef MD5_INCLUDED
# define MD5_INCLUDED
@@ -63,15 +63,18 @@ 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_Finish rb_Digest_MD5_Finish
+#define MD5_Final rb_Digest_MD5_Final
+#define MD5_End rb_Digest_MD5_End
+#define MD5_Equal rb_Digest_MD5_Equal
#endif
void MD5_Init _((MD5_CTX *pms));
void MD5_Update _((MD5_CTX *pms, const uint8_t *data, size_t nbytes));
-void MD5_Finish _((MD5_CTX *pms, uint8_t *digest));
+void MD5_Final _((uint8_t *digest, MD5_CTX *pms));
+void MD5_End _((MD5_CTX *pctx, uint8_t *hexdigest));
+int MD5_Equal _((MD5_CTX *pctx1, MD5_CTX *pctx2));
#define MD5_BLOCK_LENGTH 64
#define MD5_DIGEST_LENGTH 16
diff --git a/ext/digest/md5/md5init.c b/ext/digest/md5/md5init.c
index 17658f4fce..52f5de540f 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$ */
+/* $Id: md5init.c,v 1.5 2002/09/26 16:27:23 knu Exp $ */
#include "digest.h"
#if defined(HAVE_OPENSSL_MD5_H)
@@ -8,33 +8,28 @@
#include "md5.h"
#endif
-static rb_digest_metadata_t md5 = {
- RUBY_DIGEST_API_VERSION,
+static algo_t md5 = {
MD5_DIGEST_LENGTH,
- MD5_BLOCK_LENGTH,
sizeof(MD5_CTX),
- (rb_digest_hash_init_func_t)MD5_Init,
- (rb_digest_hash_update_func_t)MD5_Update,
- (rb_digest_hash_finish_func_t)MD5_Finish,
+ (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,
};
-/*
- * 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");
+ rb_require("digest.so");
mDigest = rb_path2class("Digest");
cDigest_Base = rb_path2class("Digest::Base");
cDigest_MD5 = rb_define_class_under(mDigest, "MD5", cDigest_Base);
- rb_ivar_set(cDigest_MD5, rb_intern("metadata"),
- Data_Wrap_Struct(rb_cObject, 0, 0, &md5));
+ rb_cvar_set(cDigest_MD5, rb_intern("metadata"),
+ Data_Wrap_Struct(rb_cObject, 0, 0, &md5), Qtrue);
}
diff --git a/ext/digest/md5/md5ossl.c b/ext/digest/md5/md5ossl.c
index d94ae2cd2f..4af7d19ba5 100644
--- a/ext/digest/md5/md5ossl.c
+++ b/ext/digest/md5/md5ossl.c
@@ -1,9 +1,30 @@
-/* $Id$ */
+/* $Id: md5ossl.c,v 1.2 2003/01/06 11:47:53 knu Exp $ */
#include "md5ossl.h"
+#include <sys/types.h>
+#include <stdio.h>
+#include <string.h>
void
-MD5_Finish(MD5_CTX *pctx, unsigned char *digest)
+MD5_End(MD5_CTX *pctx, unsigned char *hexdigest)
{
+ unsigned char digest[16];
+ size_t i;
+
MD5_Final(digest, pctx);
+
+ for (i = 0; i < 16; i++)
+ sprintf(hexdigest + i * 2, "%02x", digest[i]);
+}
+
+int
+MD5_Equal(MD5_CTX* pctx1, MD5_CTX* pctx2) {
+ return pctx1->num == pctx2->num
+ && pctx1->A == pctx2->A
+ && pctx1->B == pctx2->B
+ && pctx1->C == pctx2->C
+ && pctx1->D == pctx2->D
+ && pctx1->Nl == pctx2->Nl
+ && pctx1->Nh == pctx2->Nh
+ && memcmp(pctx1->data, pctx2->data, sizeof(pctx1->data)) == 0;
}
diff --git a/ext/digest/md5/md5ossl.h b/ext/digest/md5/md5ossl.h
index 1680c4f5c9..401ef3418d 100644
--- a/ext/digest/md5/md5ossl.h
+++ b/ext/digest/md5/md5ossl.h
@@ -1,4 +1,4 @@
-/* $Id$ */
+/* $Id: md5ossl.h,v 1.1.2.1 2005/08/30 10:43:34 gotoyuzo Exp $ */
#ifndef MD5OSSL_H_INCLUDED
#define MD5OSSL_H_INCLUDED
@@ -6,8 +6,7 @@
#include <stddef.h>
#include <openssl/md5.h>
-#define MD5_BLOCK_LENGTH MD5_CBLOCK
-
-void MD5_Finish(MD5_CTX *pctx, unsigned char *digest);
+void MD5_End(MD5_CTX *pctx, unsigned char *hexdigest);
+int MD5_Equal(MD5_CTX *pctx1, MD5_CTX *pctx2);
#endif
diff --git a/ext/digest/rmd160/depend b/ext/digest/rmd160/depend
index a21d7188dc..0ca79c5f40 100644
--- a/ext/digest/rmd160/depend
+++ b/ext/digest/rmd160/depend
@@ -1,5 +1,7 @@
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 09359944f2..232a3a5e06 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$
+# $Id: extconf.rb,v 1.4.2.2 2006/05/25 23:44:05 nobu Exp $
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}"
+ $objs << "rmd160.#{$OBJEXT}" << "rmd160hl.#{$OBJEXT}"
end
have_header("sys/cdefs.h")
@@ -23,6 +23,4 @@ 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 88918728cd..9562a6fe67 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$ */
+/* $Id: rmd160.c,v 1.1 2001/07/13 20:06:14 knu Exp $ */
/********************************************************************\
*
@@ -409,7 +409,7 @@ RMD160_Update(RMD160_CTX *context, const uint8_t *data, size_t nbytes)
/********************************************************************/
void
-RMD160_Finish(RMD160_CTX *context, uint8_t digest[20])
+RMD160_Final(uint8_t digest[20], RMD160_CTX *context)
{
uint32_t i;
uint32_t X[16];
@@ -454,4 +454,11 @@ RMD160_Finish(RMD160_CTX *context, uint8_t digest[20])
}
}
+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 54d1ca9140..7df190413e 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$ */
+/* $Id: rmd160.h,v 1.2 2002/02/24 08:20:22 knu Exp $ */
/********************************************************************\
*
@@ -39,14 +39,26 @@ 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_Finish rb_Digest_RMD160_Finish
+#define RMD160_Final rb_Digest_RMD160_Final
+#define RMD160_Equal rb_Digest_RMD160_Equal
+#ifndef _KERNEL
+#define RMD160_End rb_Digest_RMD160_End
+#define RMD160_File rb_Digest_RMD160_File
+#define RMD160_Data rb_Digest_RMD160_Data
+#endif /* _KERNEL */
#endif
__BEGIN_DECLS
void RMD160_Init _((RMD160_CTX *));
void RMD160_Transform _((uint32_t[5], const uint32_t[16]));
void RMD160_Update _((RMD160_CTX *, const uint8_t *, size_t));
-void RMD160_Finish _((RMD160_CTX *, uint8_t[20]));
+void RMD160_Final _((uint8_t[20], RMD160_CTX *));
+int RMD160_Equal _((RMD160_CTX *, RMD160_CTX *));
+#ifndef _KERNEL
+char *RMD160_End _((RMD160_CTX *, char *));
+char *RMD160_File _((char *, char *));
+char *RMD160_Data _((const uint8_t *, size_t, char *));
+#endif /* _KERNEL */
__END_DECLS
#define RMD160_BLOCK_LENGTH 64
diff --git a/ext/digest/rmd160/rmd160hl.c b/ext/digest/rmd160/rmd160hl.c
new file mode 100644
index 0000000000..14299d7c7a
--- /dev/null
+++ b/ext/digest/rmd160/rmd160hl.c
@@ -0,0 +1,96 @@
+/* $NetBSD: rmd160hl.c,v 1.1.1.1 2001/03/06 11:21:05 agc Exp $ */
+/* $RoughId: rmd160hl.c,v 1.2 2001/07/13 19:49:10 knu Exp $ */
+/* $Id: rmd160hl.c,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 763867df86..3aa7847019 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$ */
+/* $Id: rmd160init.c,v 1.3 2002/09/26 17:26:46 knu Exp $ */
#include "digest.h"
#if defined(HAVE_OPENSSL_RIPEMD_H)
@@ -8,33 +8,31 @@
#include "rmd160.h"
#endif
-static rb_digest_metadata_t rmd160 = {
- RUBY_DIGEST_API_VERSION,
+static algo_t rmd160 = {
RMD160_DIGEST_LENGTH,
- RMD160_BLOCK_LENGTH,
sizeof(RMD160_CTX),
- (rb_digest_hash_init_func_t)RMD160_Init,
- (rb_digest_hash_update_func_t)RMD160_Update,
- (rb_digest_hash_finish_func_t)RMD160_Finish,
+ (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,
};
-/*
- * 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");
+ rb_require("digest.so");
mDigest = rb_path2class("Digest");
cDigest_Base = rb_path2class("Digest::Base");
cDigest_RMD160 = rb_define_class_under(mDigest, "RMD160", cDigest_Base);
- rb_ivar_set(cDigest_RMD160, rb_intern("metadata"),
- Data_Wrap_Struct(rb_cObject, 0, 0, &rmd160));
+ id_metadata = rb_intern("metadata");
+
+ rb_cvar_set(cDigest_RMD160, id_metadata,
+ Data_Wrap_Struct(rb_cObject, 0, 0, &rmd160), Qtrue);
}
diff --git a/ext/digest/rmd160/rmd160ossl.c b/ext/digest/rmd160/rmd160ossl.c
index f24e63e3d8..1a8436dfb8 100644
--- a/ext/digest/rmd160/rmd160ossl.c
+++ b/ext/digest/rmd160/rmd160ossl.c
@@ -1,8 +1,45 @@
-/* $Id$ */
+/* $Id: rmd160ossl.c,v 1.1.2.1 2006/08/07 09:01:27 matz Exp $ */
#include "defs.h"
#include "rmd160ossl.h"
+#include <assert.h>
+#include <stdlib.h>
-void RMD160_Finish(RMD160_CTX *ctx, char *buf) {
- RIPEMD160_Final((unsigned char *)buf, ctx);
+#ifndef _DIAGASSERT
+#define _DIAGASSERT(cond) assert(cond)
+#endif
+
+char *
+RMD160_End(RMD160_CTX *ctx, char *buf)
+{
+ size_t i;
+ char *p = buf;
+ uint8_t digest[20];
+ static const char hex[]="0123456789abcdef";
+
+ _DIAGASSERT(ctx != NULL);
+ /* buf may be NULL */
+
+ if (p == NULL && (p = malloc(41)) == NULL)
+ return 0;
+
+ RMD160_Final(digest,ctx);
+ for (i = 0; i < 20; i++) {
+ p[i + i] = hex[(uint32_t)digest[i] >> 4];
+ p[i + i + 1] = hex[digest[i] & 0x0f];
+ }
+ p[i + i] = '\0';
+ return(p);
+}
+
+int RMD160_Equal(RMD160_CTX* pctx1, RMD160_CTX* pctx2) {
+ return pctx1->num == pctx2->num
+ && pctx1->A == pctx2->A
+ && pctx1->B == pctx2->B
+ && pctx1->C == pctx2->C
+ && pctx1->D == pctx2->D
+ && pctx1->E == pctx2->E
+ && pctx1->Nl == pctx2->Nl
+ && pctx1->Nh == pctx2->Nh
+ && memcmp(pctx1->data, pctx2->data, sizeof(pctx1->data)) == 0;
}
diff --git a/ext/digest/rmd160/rmd160ossl.h b/ext/digest/rmd160/rmd160ossl.h
index 3df38a01c0..30840ca598 100644
--- a/ext/digest/rmd160/rmd160ossl.h
+++ b/ext/digest/rmd160/rmd160ossl.h
@@ -1,4 +1,4 @@
-/* $Id$ */
+/* $Id: rmd160ossl.h,v 1.1.2.1 2005/08/30 10:43:35 gotoyuzo Exp $ */
#ifndef RMD160OSSL_H_INCLUDED
#define RMD160OSSL_H_INCLUDED
@@ -10,10 +10,12 @@
#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
-void RMD160_Finish(RMD160_CTX *ctx, char *buf);
+char *RMD160_End(RMD160_CTX *ctx, char *buf);
+int RMD160_Equal(RMD160_CTX *pctx1, RMD160_CTX *pctx2);
#endif
diff --git a/ext/digest/sha1/depend b/ext/digest/sha1/depend
index 61607844d0..a159f456d3 100644
--- a/ext/digest/sha1/depend
+++ b/ext/digest/sha1/depend
@@ -1,5 +1,7 @@
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 87b74c34af..861c5563f9 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$
+# $Id: extconf.rb,v 1.5.2.1 2006/05/25 23:44:05 nobu Exp $
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}"
+ $objs << "sha1.#{$OBJEXT}" << "sha1hl.#{$OBJEXT}"
end
have_header("sys/cdefs.h")
@@ -23,6 +23,4 @@ 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 6196ca6b82..ba926e1fad 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$ */
+/* $Id: sha1.c,v 1.1 2001/07/13 20:06:14 knu Exp $ */
/*
* SHA-1 in C
@@ -129,7 +129,9 @@ 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(uint32_t state[5], const uint8_t buffer[64])
+void SHA1_Transform(state, buffer)
+ uint32_t state[5];
+ const uint8_t buffer[64];
{
uint32_t a, b, c, d, e;
CHAR64LONG16 *block;
@@ -199,7 +201,8 @@ void SHA1_Transform(uint32_t state[5], const uint8_t buffer[64])
/*
* SHA1_Init - Initialize new context
*/
-void SHA1_Init(SHA1_CTX *context)
+void SHA1_Init(context)
+ SHA1_CTX *context;
{
_DIAGASSERT(context != 0);
@@ -217,7 +220,10 @@ void SHA1_Init(SHA1_CTX *context)
/*
* Run your data through this.
*/
-void SHA1_Update(SHA1_CTX *context, const uint8_t *data, size_t len)
+void SHA1_Update(context, data, len)
+ SHA1_CTX *context;
+ const uint8_t *data;
+ size_t len;
{
uint32_t i, j;
@@ -244,7 +250,9 @@ void SHA1_Update(SHA1_CTX *context, const uint8_t *data, size_t len)
/*
* Add padding and return the message digest.
*/
-void SHA1_Finish(SHA1_CTX* context, uint8_t digest[20])
+void SHA1_Final(digest, context)
+ uint8_t digest[20];
+ SHA1_CTX* context;
{
size_t i;
uint8_t finalcount[8];
@@ -267,3 +275,9 @@ void SHA1_Finish(SHA1_CTX* context, uint8_t digest[20])
((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 60e3b01fe2..5a1143ea0d 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$ */
+/* $Id: sha1.h,v 1.2 2002/02/24 08:20:22 knu Exp $ */
/*
* SHA-1 in C
@@ -20,17 +20,28 @@ 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_Finish rb_Digest_SHA1_Finish
+#define SHA1_Final rb_Digest_SHA1_Final
+#define SHA1_Equal rb_Digest_SHA1_Equal
+#ifndef _KERNEL
+#define SHA1_End rb_Digest_SHA1_End
+#define SHA1_File rb_Digest_SHA1_File
+#define SHA1_Data rb_Digest_SHA1_Data
+#endif /* _KERNEL */
#endif
void SHA1_Transform _((uint32_t state[5], const uint8_t buffer[64]));
void SHA1_Init _((SHA1_CTX *context));
void SHA1_Update _((SHA1_CTX *context, const uint8_t *data, size_t len));
-void SHA1_Finish _((SHA1_CTX *context, uint8_t digest[20]));
+void SHA1_Final _((uint8_t digest[20], SHA1_CTX *context));
+int SHA1_Equal _((SHA1_CTX *pctx1, SHA1_CTX *pctx2));
+#ifndef _KERNEL
+char *SHA1_End _((SHA1_CTX *, char *));
+char *SHA1_File _((char *, char *));
+char *SHA1_Data _((const uint8_t *, size_t, char *));
+#endif /* _KERNEL */
#define SHA1_BLOCK_LENGTH 64
#define SHA1_DIGEST_LENGTH 20
diff --git a/ext/digest/sha1/sha1hl.c b/ext/digest/sha1/sha1hl.c
new file mode 100644
index 0000000000..47b802085d
--- /dev/null
+++ b/ext/digest/sha1/sha1hl.c
@@ -0,0 +1,102 @@
+/* $NetBSD: sha1hl.c,v 1.2 2001/03/10 15:55:14 tron Exp $ */
+/* $RoughId: sha1hl.c,v 1.2 2001/07/13 19:49:10 knu Exp $ */
+/* $Id: sha1hl.c,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 b2146f05a9..829a363921 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$ */
+/* $Id: sha1init.c,v 1.3 2002/09/26 17:44:33 knu Exp $ */
#include "digest.h"
#if defined(HAVE_OPENSSL_SHA_H)
@@ -8,33 +8,31 @@
#include "sha1.h"
#endif
-static rb_digest_metadata_t sha1 = {
- RUBY_DIGEST_API_VERSION,
+static algo_t sha1 = {
SHA1_DIGEST_LENGTH,
- SHA1_BLOCK_LENGTH,
sizeof(SHA1_CTX),
- (rb_digest_hash_init_func_t)SHA1_Init,
- (rb_digest_hash_update_func_t)SHA1_Update,
- (rb_digest_hash_finish_func_t)SHA1_Finish,
+ (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,
};
-/*
- * 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;
-
- rb_require("digest");
-
+ ID id_metadata;
+
+ rb_require("digest.so");
+
mDigest = rb_path2class("Digest");
cDigest_Base = rb_path2class("Digest::Base");
cDigest_SHA1 = rb_define_class_under(mDigest, "SHA1", cDigest_Base);
- rb_ivar_set(cDigest_SHA1, rb_intern("metadata"),
- Data_Wrap_Struct(rb_cObject, 0, 0, &sha1));
+ id_metadata = rb_intern("metadata");
+
+ rb_cvar_set(cDigest_SHA1, id_metadata,
+ Data_Wrap_Struct(rb_cObject, 0, 0, &sha1), Qtrue);
}
diff --git a/ext/digest/sha1/sha1ossl.c b/ext/digest/sha1/sha1ossl.c
index 452cf35084..72c6eb4092 100644
--- a/ext/digest/sha1/sha1ossl.c
+++ b/ext/digest/sha1/sha1ossl.c
@@ -1,10 +1,45 @@
-/* $Id$ */
+/* $Id: sha1ossl.c,v 1.1.2.1 2006/08/07 09:01:27 matz Exp $ */
#include "defs.h"
#include "sha1ossl.h"
+#include <assert.h>
+#include <stdlib.h>
-void
-SHA1_Finish(SHA1_CTX *ctx, char *buf)
+#ifndef _DIAGASSERT
+#define _DIAGASSERT(cond) assert(cond)
+#endif
+
+char *
+SHA1_End(SHA1_CTX *ctx, char *buf)
{
- SHA1_Final((unsigned char *)buf, ctx);
+ int i;
+ char *p = buf;
+ uint8_t digest[20];
+ static const char hex[]="0123456789abcdef";
+
+ _DIAGASSERT(ctx != NULL);
+ /* buf may be NULL */
+
+ if (p == NULL && (p = malloc(41)) == NULL)
+ return 0;
+
+ SHA1_Final(digest,ctx);
+ for (i = 0; i < 20; i++) {
+ p[i + i] = hex[((uint32_t)digest[i]) >> 4];
+ p[i + i + 1] = hex[digest[i] & 0x0f];
+ }
+ p[i + i] = '\0';
+ return(p);
+}
+
+int SHA1_Equal(SHA1_CTX* pctx1, SHA1_CTX* pctx2) {
+ return pctx1->num == pctx2->num
+ && pctx1->h0 == pctx2->h0
+ && pctx1->h1 == pctx2->h1
+ && pctx1->h2 == pctx2->h2
+ && pctx1->h3 == pctx2->h3
+ && pctx1->h4 == pctx2->h4
+ && pctx1->Nl == pctx2->Nl
+ && pctx1->Nh == pctx2->Nh
+ && memcmp(pctx1->data, pctx2->data, sizeof(pctx1->data)) == 0;
}
diff --git a/ext/digest/sha1/sha1ossl.h b/ext/digest/sha1/sha1ossl.h
index 8f9984cc64..24b84b4274 100644
--- a/ext/digest/sha1/sha1ossl.h
+++ b/ext/digest/sha1/sha1ossl.h
@@ -1,4 +1,4 @@
-/* $Id$ */
+/* $Id: sha1ossl.h,v 1.1.2.1 2005/08/30 10:43:36 gotoyuzo Exp $ */
#ifndef SHA1OSSL_H_INCLUDED
#define SHA1OSSL_H_INCLUDED
@@ -8,13 +8,10 @@
#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
-void SHA1_Finish(SHA1_CTX *ctx, char *buf);
+char *SHA1_End(SHA1_CTX *ctx, char *buf);
+int SHA1_Equal(SHA1_CTX *pctx1, SHA1_CTX *pctx2);
#endif
diff --git a/ext/digest/sha2/depend b/ext/digest/sha2/depend
index 225d6ad52b..2587415fdc 100644
--- a/ext/digest/sha2/depend
+++ b/ext/digest/sha2/depend
@@ -1,5 +1,7 @@
sha2.o: sha2.c sha2.h $(srcdir)/../defs.h $(hdrdir)/ruby.h \
$(topdir)/config.h $(hdrdir)/defines.h $(hdrdir)/intern.h
+sha2hl.o: sha2hl.c sha2.h $(srcdir)/../defs.h $(hdrdir)/ruby.h \
+ $(topdir)/config.h $(hdrdir)/defines.h $(hdrdir)/intern.h
sha2init.o: sha2init.c $(srcdir)/../digest.h $(hdrdir)/ruby.h \
$(topdir)/config.h $(hdrdir)/defines.h $(hdrdir)/intern.h \
sha2.h $(srcdir)/../defs.h
diff --git a/ext/digest/sha2/extconf.rb b/ext/digest/sha2/extconf.rb
index c084a51a64..5d078f4bd6 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$
+# $Id: extconf.rb,v 1.7.2.2 2006/05/25 23:44:06 nobu Exp $
require "mkmf"
@@ -8,6 +8,7 @@ $INCFLAGS << " -I$(srcdir)/.."
$objs = [
"sha2.#{$OBJEXT}",
+ "sha2hl.#{$OBJEXT}",
"sha2init.#{$OBJEXT}",
]
@@ -17,8 +18,6 @@ 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
deleted file mode 100644
index 52dd639f9b..0000000000
--- a/ext/digest/sha2/lib/sha2.rb
+++ /dev/null
@@ -1,73 +0,0 @@
-#--
-# 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 aca9ee926f..22e7d59cd3 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$ */
+/* $Id: sha2.c,v 1.4.2.1 2005/12/24 09:58:56 matz Exp $ */
#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_Finish(SHA256_CTX* context, sha2_byte digest[]) {
+void SHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
sha2_word32 *d = (sha2_word32*)digest;
unsigned int usedspace;
@@ -578,6 +578,12 @@ void SHA256_Finish(SHA256_CTX* context, sha2_byte digest[]) {
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) {
@@ -846,7 +852,7 @@ void SHA512_Last(SHA512_CTX* context) {
SHA512_Transform(context, (const sha2_word64*)context->buffer);
}
-void SHA512_Finish(SHA512_CTX* context, sha2_byte digest[]) {
+void SHA512_Final(sha2_byte digest[], SHA512_CTX* context) {
sha2_word64 *d = (sha2_word64*)digest;
/* Sanity check: */
@@ -875,6 +881,12 @@ void SHA512_Finish(SHA512_CTX* context, sha2_byte digest[]) {
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) {
@@ -889,7 +901,7 @@ void SHA384_Update(SHA384_CTX* context, const sha2_byte* data, size_t len) {
SHA512_Update((SHA512_CTX*)context, data, len);
}
-void SHA384_Finish(SHA384_CTX* context, sha2_byte digest[]) {
+void SHA384_Final(sha2_byte digest[], SHA384_CTX* context) {
sha2_word64 *d = (sha2_word64*)digest;
/* Sanity check: */
@@ -917,3 +929,9 @@ void SHA384_Finish(SHA384_CTX* context, sha2_byte digest[]) {
/* 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 917d415b73..7ccf012b77 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$ */
+/* $Id: sha2.h,v 1.2 2002/02/24 08:20:22 knu Exp $ */
#ifndef __SHA2_H__
#define __SHA2_H__
@@ -77,29 +77,53 @@ typedef SHA512_CTX SHA384_CTX;
#ifdef RUBY
#define SHA256_Init rb_Digest_SHA256_Init
#define SHA256_Update rb_Digest_SHA256_Update
-#define SHA256_Finish rb_Digest_SHA256_Finish
+#define SHA256_Final rb_Digest_SHA256_Final
+#define SHA256_End rb_Digest_SHA256_End
+#define SHA256_Data rb_Digest_SHA256_Data
+#define SHA256_File rb_Digest_SHA256_File
+#define SHA256_Equal rb_Digest_SHA256_Equal
#define SHA384_Init rb_Digest_SHA384_Init
#define SHA384_Update rb_Digest_SHA384_Update
-#define SHA384_Finish rb_Digest_SHA384_Finish
+#define SHA384_Final rb_Digest_SHA384_Final
+#define SHA384_End rb_Digest_SHA384_End
+#define SHA384_Data rb_Digest_SHA384_Data
+#define SHA384_File rb_Digest_SHA384_File
+#define SHA384_Equal rb_Digest_SHA384_Equal
#define SHA512_Init rb_Digest_SHA512_Init
#define SHA512_Update rb_Digest_SHA512_Update
-#define SHA512_Finish rb_Digest_SHA512_Finish
+#define SHA512_Final rb_Digest_SHA512_Final
+#define SHA512_End rb_Digest_SHA512_End
+#define SHA512_Data rb_Digest_SHA512_Data
+#define SHA512_File rb_Digest_SHA512_File
+#define SHA512_Equal rb_Digest_SHA512_Equal
#endif
/*** SHA-256/384/512 Function Prototypes ******************************/
void SHA256_Init _((SHA256_CTX *));
void SHA256_Update _((SHA256_CTX*, const uint8_t*, size_t));
-void SHA256_Finish _((SHA256_CTX*, uint8_t[SHA256_DIGEST_LENGTH]));
+void SHA256_Final _((uint8_t[SHA256_DIGEST_LENGTH], SHA256_CTX*));
+char* SHA256_End _((SHA256_CTX*, char[SHA256_DIGEST_STRING_LENGTH]));
+char* SHA256_Data _((const uint8_t*, size_t, char[SHA256_DIGEST_STRING_LENGTH]));
+char *SHA256_File _((char *, char *));
+int SHA256_Equal _((SHA256_CTX*, SHA256_CTX*));
void SHA384_Init _((SHA384_CTX*));
void SHA384_Update _((SHA384_CTX*, const uint8_t*, size_t));
-void SHA384_Finish _((SHA384_CTX*, uint8_t[SHA384_DIGEST_LENGTH]));
+void SHA384_Final _((uint8_t[SHA384_DIGEST_LENGTH], SHA384_CTX*));
+char* SHA384_End _((SHA384_CTX*, char[SHA384_DIGEST_STRING_LENGTH]));
+char* SHA384_Data _((const uint8_t*, size_t, char[SHA384_DIGEST_STRING_LENGTH]));
+char *SHA384_File _((char *, char *));
+int SHA384_Equal _((SHA384_CTX*, SHA384_CTX*));
void SHA512_Init _((SHA512_CTX*));
void SHA512_Update _((SHA512_CTX*, const uint8_t*, size_t));
-void SHA512_Finish _((SHA512_CTX*, uint8_t[SHA512_DIGEST_LENGTH]));
+void SHA512_Final _((uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*));
+char* SHA512_End _((SHA512_CTX*, char[SHA512_DIGEST_STRING_LENGTH]));
+char* SHA512_Data _((const uint8_t*, size_t, char[SHA512_DIGEST_STRING_LENGTH]));
+char *SHA512_File _((char *, char *));
+int SHA512_Equal _((SHA512_CTX*, SHA512_CTX*));
#ifdef __cplusplus
}
diff --git a/ext/digest/sha2/sha2hl.c b/ext/digest/sha2/sha2hl.c
new file mode 100644
index 0000000000..8f09bd6e5a
--- /dev/null
+++ b/ext/digest/sha2/sha2hl.c
@@ -0,0 +1,252 @@
+/* $NetBSD: sha2hl.c,v 1.1 2001/03/12 09:08:40 agc Exp $ */
+/* $RoughId: sha2hl.c,v 1.2 2001/07/13 19:49:10 knu Exp $ */
+/* $Id: sha2hl.c,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 c83a29316a..9c0f9854fb 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$ */
+/* $Id: sha2init.c,v 1.2 2002/02/17 12:43:44 nobu Exp $ */
#include "digest.h"
#include "sha2.h"
@@ -7,23 +7,18 @@
#define FOREACH_BITLEN(func) func(256) func(384) func(512)
#define DEFINE_ALGO_METADATA(bitlen) \
-static rb_digest_metadata_t sha##bitlen = { \
- RUBY_DIGEST_API_VERSION, \
+static algo_t sha##bitlen = { \
SHA##bitlen##_DIGEST_LENGTH, \
- SHA##bitlen##_BLOCK_LENGTH, \
sizeof(SHA##bitlen##_CTX), \
- (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, \
+ (hash_init_func_t)SHA##bitlen##_Init, \
+ (hash_update_func_t)SHA##bitlen##_Update, \
+ (hash_end_func_t)SHA##bitlen##_End, \
+ (hash_final_func_t)SHA##bitlen##_Final, \
+ (hash_equal_func_t)SHA##bitlen##_Equal, \
};
FOREACH_BITLEN(DEFINE_ALGO_METADATA)
-/*
- * 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()
{
@@ -35,7 +30,7 @@ Init_sha2()
FOREACH_BITLEN(DECLARE_ALGO_CLASS)
- rb_require("digest");
+ rb_require("digest.so");
id_metadata = rb_intern("metadata");
@@ -45,8 +40,8 @@ Init_sha2()
#define DEFINE_ALGO_CLASS(bitlen) \
cDigest_SHA##bitlen = rb_define_class_under(mDigest, "SHA" #bitlen, cDigest_Base); \
\
- rb_ivar_set(cDigest_SHA##bitlen, id_metadata, \
- Data_Wrap_Struct(rb_cObject, 0, 0, &sha##bitlen));
+ rb_cvar_set(cDigest_SHA##bitlen, id_metadata, \
+ Data_Wrap_Struct(rb_cObject, 0, 0, &sha##bitlen), Qtrue);
FOREACH_BITLEN(DEFINE_ALGO_CLASS)
}
diff --git a/ext/digest/test.sh b/ext/digest/test.sh
index 328c7575e6..2ae2688e4d 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$
+# $Id: test.sh,v 1.2 2002/09/26 17:55:16 knu Exp $
RUBY=${RUBY:=ruby}
MAKE=${MAKE:=make}
@@ -11,6 +11,8 @@ ${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}"
@@ -25,6 +27,7 @@ for algo in md5 rmd160 sha1 sha2; do
ln -sf ../../$algo/$algo.so lib/digest/
done
-${RUBY} -I. -I./lib ../../test/digest/test_digest.rb
+${RUBY} -I. -I./lib test.rb
rm lib/digest/*.so
+rmdir lib/digest
diff --git a/ext/dl/dl.c b/ext/dl/dl.c
index f65247be86..71c353bda3 100644
--- a/ext/dl/dl.c
+++ b/ext/dl/dl.c
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: dl.c,v 1.20.2.5 2005/12/16 13:32:06 ttate Exp $
*/
#include <ruby.h>
@@ -522,15 +522,12 @@ rb_str_to_ptr(VALUE self)
{
char *ptr;
int len;
- VALUE p;
len = RSTRING(self)->len;
ptr = (char*)dlmalloc(len + 1);
memcpy(ptr, RSTRING(self)->ptr, len);
ptr[len] = '\0';
- p = rb_dlptr_new((void*)ptr,len,dlfree);
- OBJ_INFECT(p, self);
- return p;
+ return rb_dlptr_new((void*)ptr,len,dlfree);
}
VALUE
@@ -548,18 +545,13 @@ rb_ary_to_ptr(int argc, VALUE argv[], VALUE self)
ptr = rb_ary2cary(0, self, &size);
break;
}
- if (ptr) {
- VALUE p = rb_dlptr_new(ptr, size, dlfree);
- OBJ_INFECT(p, self);
- return p;
- }
- return Qnil;
+ return ptr ? rb_dlptr_new(ptr, size, dlfree) : Qnil;
}
VALUE
rb_io_to_ptr(VALUE self)
{
- rb_io_t *fptr;
+ OpenFile *fptr;
FILE *fp;
GetOpenFile(self, fptr);
@@ -571,7 +563,7 @@ rb_io_to_ptr(VALUE self)
VALUE
rb_dl_dlopen(int argc, VALUE argv[], VALUE self)
{
- rb_secure(2);
+ rb_secure(4);
return rb_class_new_instance(argc, argv, rb_cDLHandle);
}
diff --git a/ext/dl/dl.h b/ext/dl/dl.h
index 1faa316cf1..9e4e01eea5 100644
--- a/ext/dl/dl.h
+++ b/ext/dl/dl.h
@@ -1,5 +1,5 @@
/* -*- C -*-
- * $Id$
+ * $Id: dl.h,v 1.9 2003/12/01 23:02:44 ttate Exp $
*/
#ifndef RUBY_DL_H
diff --git a/ext/dl/h2rb b/ext/dl/h2rb
index 00fbd60c82..d5ebd6ee2c 100644
--- a/ext/dl/h2rb
+++ b/ext/dl/h2rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
# -*- ruby -*-
-# $Id$
+# $Id: h2rb,v 1.1 2002/04/02 10:56:13 ttate Exp $
require 'mkmf'
require 'ftools'
diff --git a/ext/dl/handle.c b/ext/dl/handle.c
index 69d47caac0..1e8c17e501 100644
--- a/ext/dl/handle.c
+++ b/ext/dl/handle.c
@@ -1,5 +1,5 @@
/* -*- C -*-
- * $Id$
+ * $Id: handle.c,v 1.11.2.1 2005/02/28 02:45:17 matz Exp $
*/
#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, "%s", err);
+ rb_raise(rb_eRuntimeError, err);
}
#else
if (!ptr) {
err = dlerror();
- rb_raise(rb_eRuntimeError, "%s", err);
+ rb_raise(rb_eRuntimeError, 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 01ee2490e8..63c9b2c050 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",
- " r",
+ " @retval",
"}",
].join("\n"))
@@ -169,7 +169,7 @@ module DL
" rs = dec.call(rs) if dec",
" @retval = r",
" @args = rs",
- " return r",
+ " return @retval",
"end",
"module_function :#{mname}",
].join("\n")
diff --git a/ext/dl/ptr.c b/ext/dl/ptr.c
index 01eb31da20..a3bbcc915c 100644
--- a/ext/dl/ptr.c
+++ b/ext/dl/ptr.c
@@ -1,5 +1,5 @@
/* -*- C -*-
- * $Id$
+ * $Id: ptr.c,v 1.19.2.1 2006/05/25 16:37:57 ttate Exp $
*/
#include <ruby.h>
@@ -336,7 +336,7 @@ rb_dlptr_to_array(int argc, VALUE argv[], VALUE self)
n = data->size / sizeof(void*);
break;
case 'S': case 's':
- n = data->size / sizeof(char*);
+ for (n=0; ((void**)(data->ptr))[n]; n++) {};
break;
default:
n = 0;
diff --git a/ext/dl/sym.c b/ext/dl/sym.c
index 933fb7f4f0..2ca16a8698 100644
--- a/ext/dl/sym.c
+++ b/ext/dl/sym.c
@@ -1,5 +1,5 @@
/* -*- C -*-
- * $Id$
+ * $Id: sym.c,v 1.24.2.3 2005/06/15 23:39:27 ocean Exp $
*/
#include <ruby.h>
@@ -492,7 +492,6 @@ rb_dlsym_call(int argc, VALUE argv[], VALUE self)
rb_raise(rb_eDLTypeError, "unexpected type of argument #%d", i);
}
}
- rb_check_safe_obj(pval);
Data_Get_Struct(pval, struct ptr_data, data);
ANY2P(args[i]) = DLVOIDP(data->ptr);
}
diff --git a/ext/digest/bubblebabble/.cvsignore b/ext/enumerator/.cvsignore
index 4088712231..fc802ff1c2 100644
--- a/ext/digest/bubblebabble/.cvsignore
+++ b/ext/enumerator/.cvsignore
@@ -1,3 +1,2 @@
Makefile
mkmf.log
-*.def
diff --git a/ext/enumerator/enumerator.c b/ext/enumerator/enumerator.c
new file mode 100644
index 0000000000..7b8f109e38
--- /dev/null
+++ b/ext/enumerator/enumerator.c
@@ -0,0 +1,298 @@
+/************************************************
+
+ enumerator.c - provides Enumerator class
+
+ $Author: matz $
+
+ 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 $
+
+************************************************/
+
+#include "ruby.h"
+#include "node.h"
+
+/*
+ * Document-class: Enumerable::Enumerator
+ *
+ * A class which provides a method `each' to be used as an Enumerable
+ * object.
+ */
+static VALUE rb_cEnumerator;
+static ID sym_each, sym_each_with_index, sym_each_slice, sym_each_cons;
+static ID id_new, id_enum_obj, id_enum_method, id_enum_args;
+
+/*
+ * call-seq:
+ * obj.to_enum(method = :each, *args)
+ * obj.enum_for(method = :each, *args)
+ *
+ * Returns Enumerable::Enumerator.new(self, method, *args).
+ *
+ * e.g.:
+ * str = "xyz"
+ *
+ * enum = str.enum_for(:each_byte)
+ * a = enum.map {|b| '%02x' % b } #=> ["78", "79", "7a"]
+ *
+ * # protects an array from being modified
+ * a = [1, 2, 3]
+ * some_method(a.to_enum)
+ *
+ */
+static VALUE
+obj_to_enum(obj, enum_args)
+ VALUE obj, enum_args;
+{
+ rb_ary_unshift(enum_args, obj);
+
+ return rb_apply(rb_cEnumerator, id_new, enum_args);
+}
+
+/*
+ * call-seq:
+ * enum_with_index
+ *
+ * Returns Enumerable::Enumerator.new(self, :each_with_index).
+ *
+ */
+static VALUE
+enumerator_enum_with_index(obj)
+ VALUE obj;
+{
+ return rb_funcall(rb_cEnumerator, id_new, 2, obj, sym_each_with_index);
+}
+
+static VALUE
+each_slice_i(val, memo)
+ VALUE val;
+ NODE *memo;
+{
+ VALUE ary = memo->u1.value;
+ long size = memo->u3.cnt;
+
+ rb_ary_push(ary, val);
+
+ if (RARRAY(ary)->len == size) {
+ rb_yield(ary);
+ memo->u1.value = rb_ary_new2(size);
+ }
+
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * e.each_slice(n) {...}
+ *
+ * Iterates the given block for each slice of <n> elements.
+ *
+ * e.g.:
+ * (1..10).each_slice(3) {|a| p a}
+ * # outputs below
+ * [1, 2, 3]
+ * [4, 5, 6]
+ * [7, 8, 9]
+ * [10]
+ *
+ */
+static VALUE
+enum_each_slice(obj, n)
+ VALUE obj, n;
+{
+ long size = NUM2LONG(n);
+ NODE *memo;
+ VALUE ary;
+
+ if (size <= 0) rb_raise(rb_eArgError, "invalid slice size");
+
+ memo = rb_node_newnode(NODE_MEMO, rb_ary_new2(size), 0, size);
+
+ rb_iterate(rb_each, obj, each_slice_i, (VALUE)memo);
+
+ ary = memo->u1.value;
+ if (RARRAY(ary)->len > 0) rb_yield(ary);
+
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * e.enum_slice(n)
+ *
+ * Returns Enumerable::Enumerator.new(self, :each_slice, n).
+ *
+ */
+static VALUE
+enumerator_enum_slice(obj, n)
+ VALUE obj, n;
+{
+ return rb_funcall(rb_cEnumerator, id_new, 3, obj, sym_each_slice, n);
+}
+
+static VALUE
+each_cons_i(val, memo)
+ VALUE val;
+ NODE *memo;
+{
+ VALUE ary = memo->u1.value;
+ long size = memo->u3.cnt;
+
+ if (RARRAY(ary)->len == size) {
+ rb_ary_shift(ary);
+ }
+ rb_ary_push(ary, val);
+ if (RARRAY(ary)->len == size) {
+ rb_yield(rb_ary_dup(ary));
+ }
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * each_cons(n) {...}
+ *
+ * Iterates the given block for each array of consecutive <n>
+ * elements.
+ *
+ * e.g.:
+ * (1..10).each_cons(3) {|a| p a}
+ * # outputs below
+ * [1, 2, 3]
+ * [2, 3, 4]
+ * [3, 4, 5]
+ * [4, 5, 6]
+ * [5, 6, 7]
+ * [6, 7, 8]
+ * [7, 8, 9]
+ * [8, 9, 10]
+ *
+ */
+static VALUE
+enum_each_cons(obj, n)
+ VALUE obj, n;
+{
+ long size = NUM2LONG(n);
+ NODE *memo;
+
+ if (size <= 0) rb_raise(rb_eArgError, "invalid size");
+ memo = rb_node_newnode(NODE_MEMO, rb_ary_new2(size), 0, size);
+
+ rb_iterate(rb_each, obj, each_cons_i, (VALUE)memo);
+
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * e.enum_cons(n)
+ *
+ * Returns Enumerable::Enumerator.new(self, :each_cons, n).
+ *
+ */
+static VALUE
+enumerator_enum_cons(obj, n)
+ VALUE obj, n;
+{
+ return rb_funcall(rb_cEnumerator, id_new, 3, obj, sym_each_cons, n);
+}
+
+/*
+ * call-seq:
+ * Enumerable::Enumerator.new(obj, method = :each, *args)
+ *
+ * Creates a new Enumerable::Enumerator object, which is to be
+ * used as an Enumerable object using the given object's given
+ * method with the given arguments.
+ *
+ * e.g.:
+ * str = "xyz"
+ *
+ * enum = Enumerable::Enumerator.new(str, :each_byte)
+ * a = enum.map {|b| '%02x' % b } #=> ["78", "79", "7a"]
+ *
+ */
+static VALUE
+enumerator_initialize(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ VALUE enum_obj, enum_method, enum_args;
+
+ rb_scan_args(argc, argv, "11*", &enum_obj, &enum_method, &enum_args);
+
+ if (enum_method == Qnil)
+ enum_method = sym_each;
+
+ rb_ivar_set(obj, id_enum_obj, enum_obj);
+ rb_ivar_set(obj, id_enum_method, enum_method);
+ rb_ivar_set(obj, id_enum_args, enum_args);
+
+ return Qnil;
+}
+
+static VALUE
+enumerator_iter(memo)
+ NODE *memo;
+{
+ return rb_apply(memo->u1.value, memo->u2.id, memo->u3.value);
+}
+
+/*
+ * call-seq:
+ * enum.each {...}
+ *
+ * Iterates the given block using the object and the method specified
+ * in the first place.
+ *
+ */
+static VALUE
+enumerator_each(obj)
+ VALUE obj;
+{
+ VALUE val;
+
+ obj = (VALUE)rb_node_newnode(NODE_MEMO,
+ rb_ivar_get(obj, id_enum_obj),
+ rb_to_id(rb_ivar_get(obj, id_enum_method)),
+ rb_ivar_get(obj, id_enum_args));
+ val = rb_iterate((VALUE (*)_((VALUE)))enumerator_iter, obj, rb_yield, 0);
+ return val;
+}
+
+void
+Init_enumerator()
+{
+ VALUE rb_mEnumerable;
+
+ rb_define_method(rb_mKernel, "to_enum", obj_to_enum, -2);
+ rb_define_method(rb_mKernel, "enum_for", obj_to_enum, -2);
+
+ rb_mEnumerable = rb_path2class("Enumerable");
+
+ rb_define_method(rb_mEnumerable, "enum_with_index", enumerator_enum_with_index, 0);
+ rb_define_method(rb_mEnumerable, "each_slice", enum_each_slice, 1);
+ rb_define_method(rb_mEnumerable, "enum_slice", enumerator_enum_slice, 1);
+ rb_define_method(rb_mEnumerable, "each_cons", enum_each_cons, 1);
+ rb_define_method(rb_mEnumerable, "enum_cons", enumerator_enum_cons, 1);
+
+ rb_cEnumerator = rb_define_class_under(rb_mEnumerable, "Enumerator", rb_cObject);
+ rb_include_module(rb_cEnumerator, rb_mEnumerable);
+
+ rb_define_method(rb_cEnumerator, "initialize", enumerator_initialize, -1);
+ rb_define_method(rb_cEnumerator, "each", enumerator_each, 0);
+
+ sym_each = ID2SYM(rb_intern("each"));
+ sym_each_with_index = ID2SYM(rb_intern("each_with_index"));
+ sym_each_slice = ID2SYM(rb_intern("each_slice"));
+ sym_each_cons = ID2SYM(rb_intern("each_cons"));
+
+ id_new = rb_intern("new");
+ id_enum_obj = rb_intern("enum_obj");
+ id_enum_method = rb_intern("enum_method");
+ id_enum_args = rb_intern("enum_args");
+}
diff --git a/ext/enumerator/enumerator.txt b/ext/enumerator/enumerator.txt
new file mode 100644
index 0000000000..1b84c0c088
--- /dev/null
+++ b/ext/enumerator/enumerator.txt
@@ -0,0 +1,102 @@
+.\" enumerator.txt - -*- Indented-Text -*-
+$Idaemons: /home/cvs/rb/enumerator/enumerator.txt,v 1.2 2001/07/15 10:19:24 knu Exp $
+$RoughId: enumerator.txt,v 1.5 2003/02/20 12:24:51 knu Exp $
+$Id: enumerator.txt,v 1.2 2003/10/17 14:09:43 knu Exp $
+
+** Enumerable::Enumerator(Class)
+
+A class which provides a method `each' to be used as an Enumerable
+object.
+
+Superclass: Object
+
+Mix-ins: Enumerable
+
+require 'enumerator'
+
+Class Methods:
+
+ new(obj, method = :each, *args)
+
+ Creates a new Enumerable::Enumerator object, which is to be
+ used as an Enumerable object using the given object's given
+ method with the given arguments.
+
+ e.g.:
+ str = "xyz"
+
+ enum = Enumerable::Enumerator.new(str, :each_byte)
+ a = enum.map {|b| '%02x' % b } #=> ["78", "79", "7a"]
+
+Methods:
+
+ each {...}
+
+ Iterates the given block using the object and the method
+ specified in the first place.
+
+
+Requiring this module also adds some methods to the Object class:
+
+ to_enum(method = :each, *args)
+ enum_for(method = :each, *args)
+
+ Returns Enumerable::Enumerator.new(self, method, *args).
+
+ e.g.:
+ str = "xyz"
+
+ enum = str.enum_for(:each_byte)
+ a = enum.map {|b| '%02x' % b } #=> ["78", "79", "7a"]
+
+ # protects an array from being modified
+ a = [1, 2, 3]
+ some_method(a.to_enum)
+
+And the Enumerable module.
+
+ each_slice(n) {...}
+
+ Iterates the given block for each slice of <n> elements.
+
+ e.g.:
+ (1..10).each_slice(3) {|a| p a}
+ # outputs below
+ [1, 2, 3]
+ [4, 5, 6]
+ [7, 8, 9]
+ [10]
+
+ enum_slice(n)
+
+ Returns Enumerable::Enumerator.new(self, :each_slice, n).
+
+ each_cons(n) {...}
+
+ Iterates the given block for each array of consecutive <n>
+ elements.
+
+ e.g.:
+ (1..10).each_cons(3) {|a| p a}
+ # outputs below
+ [1, 2, 3]
+ [2, 3, 4]
+ [3, 4, 5]
+ [4, 5, 6]
+ [5, 6, 7]
+ [6, 7, 8]
+ [7, 8, 9]
+ [8, 9, 10]
+
+ enum_cons(n)
+
+ Returns Enumerable::Enumerator.new(self, :each_cons, n).
+
+ enum_with_index
+
+ Returns Enumerable::Enumerator.new(self, :each_with_index).
+
+-------------------------------------------------------
+Local variables:
+fill-column: 70
+end:
diff --git a/ext/enumerator/extconf.rb b/ext/enumerator/extconf.rb
new file mode 100644
index 0000000000..94e2ee38b2
--- /dev/null
+++ b/ext/enumerator/extconf.rb
@@ -0,0 +1,2 @@
+require 'mkmf'
+create_makefile('enumerator')
diff --git a/ext/etc/etc.c b/ext/etc/etc.c
index ecb9e16411..084405408f 100644
--- a/ext/etc/etc.c
+++ b/ext/etc/etc.c
@@ -2,8 +2,8 @@
etc.c -
- $Author$
- $Date$
+ $Author: shyouhei $
+ $Date: 2007/01/09 12:24:20 $
created at: Tue Mar 22 18:39:19 JST 1994
************************************************/
@@ -35,8 +35,6 @@ char *getenv();
char *getlogin();
/* Returns the short user name of the currently logged in user.
- * Unfortunately, it is often rather easy to fool getlogin().
- * Avoid getlogin() for security-related purposes.
*
* e.g.
* Etc.getlogin -> 'guest'
diff --git a/ext/extmk.rb b/ext/extmk.rb
index 64746552c1..86d59b0946 100644
--- a/ext/extmk.rb
+++ b/ext/extmk.rb
@@ -1,19 +1,13 @@
#! /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,14 +73,12 @@ def extract_makefile(makefile, keep = true)
$static ||= m[/^EXTSTATIC[ \t]*=[ \t]*(\S+)/, 1] || false
/^STATIC_LIB[ \t]*=[ \t]*\S+/ =~ m or $static = nil
$preload = Shellwords.shellwords(m[/^preload[ \t]*=[ \t]*(.*)/, 1] || "")
- $DLDFLAGS += " " + (m[/^dldflags[ \t]*=[ \t]*(.*)/, 1] || "")
+ $DLDFLAGS += " " + (m[/^DLDFLAGS[ \t]*=[ \t]*(.*)/, 1] || "")
if s = m[/^LIBS[ \t]*=[ \t]*(.*)/, 1]
s.sub!(/^#{Regexp.quote($LIBRUBYARG)} */, "")
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
@@ -121,8 +113,6 @@ def extmake(target)
$mdir = target
$srcdir = File.join($top_srcdir, "ext", $mdir)
$preload = nil
- $objs = ""
- $srcs = ""
$compiled[target] = false
makefile = "./Makefile"
ok = File.exist?(makefile)
@@ -135,6 +125,7 @@ def extmake(target)
"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,
@@ -156,7 +147,7 @@ def extmake(target)
ok &&= extract_makefile(makefile)
if (($extconf_h && !File.exist?($extconf_h)) ||
!(t = modified?(makefile, MTIMES)) ||
- ["#{$srcdir}/makefile.rb", "#{$srcdir}/extconf.rb", "#{$srcdir}/depend"].any? {|f| modified?(f, [t])})
+ %W"#{$srcdir}/makefile.rb #{$srcdir}/extconf.rb #{$srcdir}/depend".any? {|f| modified?(f, [t])})
then
ok = false
init_mkmf
@@ -298,7 +289,7 @@ def parse_args()
$mflags.unshift(*rest) unless rest.empty?
def $mflags.set?(flag)
- grep(/\A-(?!-).*#{flag.chr}/i) { return true }
+ grep(/\A-(?!-).*#{'%c' % flag}/i) { return true }
false
end
def $mflags.defined?(var)
@@ -325,9 +316,9 @@ parse_args()
if target = ARGV.shift and /^[a-z-]+$/ =~ target
$mflags.push(target)
+ target = target.sub(/^(dist|real)(?=(?:clean)?$)/, '')
case target
- when /^(dist|real)?(clean)$/
- target = $2
+ when /clean/
$ignore ||= true
$clean = $1 ? $1[0] : true
when /^install\b/
@@ -354,16 +345,8 @@ elsif sep = config_string('BUILD_FILE_SEPARATOR')
else
$ruby = '$(topdir)/miniruby' + EXEEXT
end
-$ruby << " -I'$(topdir)'"
-unless CROSS_COMPILING
- $ruby << " -I'$(top_srcdir)/lib'"
- $ruby << " -I'$(extout)/$(arch)' -I'$(extout)/common'" if $extout
- $ruby << " -I./- -I'$(top_srcdir)/ext' -rpurelib.rb"
- ENV["RUBYLIB"] = "-"
- ENV["RUBYOPT"] = "-rpurelib.rb"
-end
+$ruby << " -I'$(topdir)' -I'$(top_srcdir)/lib'"
$config_h = '$(topdir)/config.h'
-$mflags << "ruby=#$ruby"
MTIMES = [__FILE__, 'rbconfig.rb', srcdir+'/lib/mkmf.rb'].collect {|f| File.mtime(f)}
@@ -412,12 +395,12 @@ else
elsif (w = w.grep(String)).empty?
proc {true}
else
- proc {|c1| w.collect {|opt| opt.split(/,/)}.flatten.any?(&c1)}
+ w.collect {|opt| opt.split(/,/)}.flatten.method(:any?)
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)
@@ -429,7 +412,15 @@ else
end
if $extout
- extout = Config.expand("#{$extout}", Config::CONFIG.merge("topdir"=>$topdir))
+ 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
unless $ignore
FileUtils.mkpath(extout)
end
@@ -458,27 +449,14 @@ if $ignore
Dir.chdir ".."
if $clean
Dir.rmdir('ext') rescue nil
- if $extout
- FileUtils.rm_rf([extout+"/common", extout+"/include/ruby", extout+"/rdoc"])
- FileUtils.rm_rf(extout+"/"+CONFIG["arch"])
- if $clean != true
- FileUtils.rm_rf(extout+"/include/"+CONFIG["arch"])
- FileUtils.rm_f($mflags.defined?("INSTALLED_LIST")||ENV["INSTALLED_LIST"]||".installed.list")
- Dir.rmdir(extout+"/include") rescue nil
- Dir.rmdir(extout) rescue nil
- end
- end
+ FileUtils.rm_rf(extout) if $extout
end
exit
end
-$extinit ||= ""
-$extobjs ||= ""
-$extpath ||= []
-$extflags ||= ""
-$extlibs ||= []
-unless $extlist.empty?
- $extinit << "\n" unless $extinit.empty?
+if $extlist.size > 0
+ $extinit ||= ""
+ $extobjs ||= ""
list = $extlist.dup
built = []
while e = list.shift
@@ -492,33 +470,28 @@ unless $extlist.empty?
end
f = format("%s/%s.%s", s, i, $LIBEXT)
if File.exist?(f)
- $extinit << " init(Init_#{i}, \"#{t}.so\");\n"
- $extobjs << "ext/#{f} "
+ $extinit += "\tinit(Init_#{i}, \"#{t}.so\");\n"
+ $extobjs += "ext/#{f} "
built << t
end
end
src = %{\
-#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}
+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}
}
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]
@@ -535,7 +508,7 @@ rubies = []
%w[RUBY RUBYW STATIC_RUBY].each {|r|
n = r
if r = arg_config("--"+r.downcase) || config_string(r+"_INSTALL_NAME")
- rubies << Config.expand(r+=EXEEXT)
+ rubies << r+EXEEXT
$mflags << "#{n}=#{r}"
end
}
@@ -544,21 +517,15 @@ 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
- 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
+ $mflags.collect {|flag| flag.sub!(/\A(?=\w+=)/, "-D")}
end
system($make, *sysquote($mflags)) or exit($?.exitstatus)
diff --git a/ext/fcntl/fcntl.c b/ext/fcntl/fcntl.c
index 57cca103f4..8f9cb43d0c 100644
--- a/ext/fcntl/fcntl.c
+++ b/ext/fcntl/fcntl.c
@@ -2,7 +2,7 @@
fcntl.c -
- $Author$
+ $Author: matz $
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 2057101206..691d512460 100644
--- a/ext/gdbm/gdbm.c
+++ b/ext/gdbm/gdbm.c
@@ -2,12 +2,10 @@
gdbm.c -
- $Author$
- $Date$
+ $Author: usa $
+ $Date: 2005/06/20 07:53:20 $
modified at: Mon Jan 24 15:59:52 JST 1994
- Documentation by Peter Adolphs < futzilogik at users dot sourceforge dot net >
-
************************************************/
#include "ruby.h"
@@ -16,62 +14,6 @@
#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
@@ -82,7 +24,7 @@ static void
rb_gdbm_fatal(msg)
char *msg;
{
- rb_raise(rb_eGDBMFatalError, "%s", msg);
+ rb_raise(rb_eGDBMFatalError, msg);
}
struct dbmdata {
@@ -112,17 +54,11 @@ 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;
@@ -136,12 +72,6 @@ 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;
@@ -150,9 +80,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;
}
@@ -166,29 +96,6 @@ 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;
@@ -201,13 +108,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 does not exist */
+ mode = -1; /* return nil if DB not exist */
}
else {
- mode = NUM2INT(vmode);
+ mode = NUM2INT(vmode);
}
if (!NIL_P(vflags))
@@ -253,25 +160,6 @@ 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;
@@ -303,10 +191,14 @@ rb_gdbm_fetch(dbm, key)
if (val.dptr == 0)
return Qnil;
- str = rb_str_new(val.dptr, val.dsize);
- free(val.dptr);
+ str = rb_obj_alloc(rb_cString);
+ RSTRING(str)->len = val.dsize;
+ RSTRING(str)->aux.capa = val.dsize;
+ RSTRING(str)->ptr = REALLOC_N(val.dptr,char,val.dsize+1);
+ RSTRING(str)->ptr[val.dsize] = '\0';
+
OBJ_TAINT(str);
- return str;
+ return (VALUE)str;
}
static VALUE
@@ -345,8 +237,12 @@ rb_gdbm_firstkey(dbm)
if (key.dptr == 0)
return Qnil;
- str = rb_str_new(key.dptr, key.dsize);
- free(key.dptr);
+ str = rb_obj_alloc(rb_cString);
+ RSTRING(str)->len = key.dsize;
+ RSTRING(str)->aux.capa = key.dsize;
+ RSTRING(str)->ptr = REALLOC_N(key.dptr,char,key.dsize+1);
+ RSTRING(str)->ptr[RSTRING(str)->len] = '\0';
+
OBJ_TAINT(str);
return str;
}
@@ -365,8 +261,12 @@ rb_gdbm_nextkey(dbm, keystr)
if (key2.dptr == 0)
return Qnil;
- str = rb_str_new(key2.dptr, key2.dsize);
- free(key2.dptr);
+ str = rb_obj_alloc(rb_cString);
+ RSTRING(str)->len = key2.dsize;
+ RSTRING(str)->aux.capa = key2.dsize;
+ RSTRING(str)->ptr = REALLOC_N(key2.dptr,char,key2.dsize+1);
+ RSTRING(str)->ptr[RSTRING(str)->len] = '\0';
+
OBJ_TAINT(str);
return str;
}
@@ -386,12 +286,6 @@ 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;
@@ -399,13 +293,6 @@ 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;
@@ -417,18 +304,11 @@ 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;
@@ -470,13 +350,6 @@ 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;
@@ -517,12 +390,6 @@ 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;
@@ -562,26 +429,19 @@ 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;
@@ -593,13 +453,6 @@ 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;
@@ -618,13 +471,6 @@ 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;
@@ -643,11 +489,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++)
@@ -658,12 +504,6 @@ 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;
@@ -678,11 +518,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) {
@@ -702,13 +542,6 @@ 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;
@@ -751,14 +584,6 @@ 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;
@@ -767,13 +592,6 @@ 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;
@@ -783,13 +601,6 @@ 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;
@@ -811,20 +622,13 @@ 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;
@@ -847,12 +651,6 @@ 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;
@@ -877,13 +675,6 @@ 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;
@@ -902,13 +693,6 @@ 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;
@@ -927,13 +711,6 @@ 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;
@@ -947,18 +724,12 @@ 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;
@@ -978,12 +749,6 @@ 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;
@@ -997,22 +762,14 @@ 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;
@@ -1031,14 +788,6 @@ 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;
@@ -1064,12 +813,6 @@ 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;
@@ -1089,14 +832,6 @@ 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;
@@ -1110,16 +845,6 @@ 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;
@@ -1133,12 +858,6 @@ 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;
@@ -1150,21 +869,11 @@ 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;
@@ -1179,24 +888,11 @@ 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;
@@ -1215,18 +911,12 @@ 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;
@@ -1246,13 +936,6 @@ 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;
@@ -1298,15 +981,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);
@@ -1318,29 +1001,22 @@ Init_gdbm()
rb_define_method(rb_cGDBM, "to_a", fgdbm_to_a, 0);
rb_define_method(rb_cGDBM, "to_hash", fgdbm_to_hash, 0);
- /* flag for #new and #open: open database as a reader */
+ /* flags for gdbm_open() */
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 d989b97df2..484abd203d 100644
--- a/ext/iconv/iconv.c
+++ b/ext/iconv/iconv.c
@@ -3,8 +3,8 @@
iconv.c -
- $Author$
- $Date$
+ $Author: matz $
+ $Date: 2005/12/12 00:36:51 $
created at: Wed Dec 1 20:28:09 JST 1999
All the files in this distribution are covered under the Ruby's
@@ -43,11 +43,7 @@
*
* == Examples
*
- * 1. Simple conversion between two charsets.
- *
- * converted_text = Iconv.conv('iso-8859-15', 'utf-8', text)
- *
- * 2. Instantiate a new Iconv and use method Iconv#iconv.
+ * 1. Instantiate a new Iconv and use method Iconv#iconv.
*
* cd = Iconv.new(to, from)
* begin
@@ -57,16 +53,20 @@
* cd.close
* end
*
- * 3. Invoke Iconv.open with a block.
+ * 2. Invoke Iconv.open with a block.
*
* Iconv.open(to, from) do |cd|
* input.each { |s| output << cd.iconv(s) }
* output << cd.iconv(nil)
* end
*
- * 4. Shorthand for (3).
+ * 3. Shorthand for (2).
*
* Iconv.iconv(to, from, *input.to_a)
+ *
+ * 4. Simple conversion between two charsets.
+ *
+ * converted_text = Iconv.new('iso-8859-15', 'utf-8').iconv(text)
*/
/* Invalid value for iconv_t is -1 but 0 for VALUE, I hope VALUE is
@@ -101,7 +101,7 @@ static void iconv_dfree _((void *cd));
static VALUE iconv_free _((VALUE cd));
static VALUE iconv_try _((iconv_t cd, const char **inptr, size_t *inlen, char **outptr, size_t *outlen));
static VALUE rb_str_derive _((VALUE str, const char* ptr, int len));
-static VALUE iconv_convert _((iconv_t cd, VALUE str, long start, long length, struct iconv_env_t* env));
+static VALUE iconv_convert _((iconv_t cd, VALUE str, int start, int length, struct iconv_env_t* env));
static VALUE iconv_s_allocate _((VALUE klass));
static VALUE iconv_initialize _((VALUE self, VALUE to, VALUE from));
static VALUE iconv_s_open _((VALUE self, VALUE to, VALUE from));
@@ -170,7 +170,7 @@ iconv_create
}
if (cd == (iconv_t)-1) {
int inval = errno == EINVAL;
- const char *s = inval ? "invalid encoding " : "iconv";
+ char *s = inval ? "invalid encoding " : "iconv";
volatile VALUE msg = rb_str_new(0, strlen(s) + RSTRING(to)->len +
RSTRING(from)->len + 8);
@@ -362,13 +362,13 @@ rb_str_derive
static VALUE
iconv_convert
#ifdef HAVE_PROTOTYPES
- (iconv_t cd, VALUE str, long start, long length, struct iconv_env_t* env)
+ (iconv_t cd, VALUE str, int start, int length, struct iconv_env_t* env)
#else /* HAVE_PROTOTYPES */
(cd, str, start, length, env)
iconv_t cd;
VALUE str;
- long start;
- long length;
+ int start;
+ int length;
struct iconv_env_t *env;
#endif /* HAVE_PROTOTYPES */
{
@@ -417,9 +417,17 @@ iconv_convert
slen = RSTRING(str)->len;
inptr = RSTRING(str)->ptr;
- inptr += start;
- if (length < 0 || length > start + slen)
- length = slen - start;
+ if (start < 0 ? (start += slen) < 0 : start >= slen)
+ length = 0;
+ else if (length < 0 && (length += slen + 1) < 0)
+ length = 0;
+ else if ((length -= start) < 0)
+ length = 0;
+ else {
+ inptr += start;
+ if (length > slen)
+ length = slen;
+ }
}
instart = inptr;
inlen = length;
@@ -601,7 +609,7 @@ iconv_s_convert
}
/*
- * Document-method: Iconv::iconv
+ * Document-method: iconv
* call-seq: Iconv.iconv(to, from, *strs)
*
* Shorthand for
@@ -644,7 +652,7 @@ iconv_s_iconv
/*
* Document-method: Iconv::conv
- * call-seq: Iconv.conv(to, from, str)
+ * call-seq: Iconv.iconv(to, from, *strs)
*
* Shorthand for
* Iconv.iconv(to, from, str).join
@@ -710,7 +718,7 @@ iconv_finish
}
/*
- * Document-method: Iconv#iconv
+ * Document-method: iconv
* call-seq: iconv(str, start=0, length=-1)
*
* Converts string and returns the result.
@@ -749,22 +757,14 @@ iconv_iconv
{
VALUE str, n1, n2;
VALUE cd = check_iconv(self);
- long start = 0, length = 0, slen = 0;
+ n1 = n2 = Qnil;
rb_scan_args(argc, argv, "12", &str, &n1, &n2);
- if (!NIL_P(str)) slen = RSTRING_LEN(StringValue(str));
- if (argc != 2 || !RTEST(rb_range_beg_len(n1, &start, &length, slen, 0))) {
- if (NIL_P(n1) || ((start = NUM2LONG(n1)) < 0 ? (start += slen) >= 0 : start < slen)) {
- if (NIL_P(n2)) {
- length = -1;
- }
- else if ((length = NUM2LONG(n2)) >= slen - start) {
- length = slen - start;
- }
- }
- }
- return iconv_convert(VALUE2ICONV(cd), str, start, length, NULL);
+ return iconv_convert(VALUE2ICONV(cd), str,
+ NIL_P(n1) ? 0 : NUM2INT(n1),
+ NIL_P(n2) ? -1 : NUM2INT(n2),
+ NULL);
}
/*
@@ -828,7 +828,7 @@ iconv_failure_inspect
VALUE self;
#endif /* HAVE_PROTOTYPES */
{
- const char *cname = rb_class2name(CLASS_OF(self));
+ char *cname = rb_class2name(CLASS_OF(self));
VALUE success = rb_attr_get(self, rb_success);
VALUE failed = rb_attr_get(self, rb_failed);
VALUE str = rb_str_buf_cat2(rb_str_new2("#<"), cname);
diff --git a/ext/io/wait/extconf.rb b/ext/io/wait/extconf.rb
index e8181d25f5..1352ef202e 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|
- have_macro("FIONREAD", h)
+ checking_for("FIONREAD") {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 02cb54a014..0e48f705d2 100644
--- a/ext/io/wait/wait.c
+++ b/ext/io/wait/wait.c
@@ -2,8 +2,8 @@
io/wait.c -
- $Author$
- $Date$
+ $Author: nobu $
+ $Date: 2005/07/18 03:24:04 $
created at: Tue Aug 28 09:08:06 JST 2001
All the files in this distribution are covered under the Ruby's
@@ -56,7 +56,7 @@ static VALUE
io_ready_p(io)
VALUE io;
{
- rb_io_t *fptr;
+ OpenFile *fptr;
FILE *fp;
ioctl_arg n;
@@ -84,7 +84,7 @@ io_wait(argc, argv, io)
VALUE *argv;
VALUE io;
{
- rb_io_t *fptr;
+ OpenFile *fptr;
fd_set rd;
FILE *fp;
int fd;
diff --git a/ext/nkf/lib/kconv.rb b/ext/nkf/lib/kconv.rb
index 4ffe8d984e..711a3c10a1 100644
--- a/ext/nkf/lib/kconv.rb
+++ b/ext/nkf/lib/kconv.rb
@@ -1,7 +1,7 @@
#
# kconv.rb - Kanji Converter.
#
-# $Id$
+# $Id: kconv.rb,v 1.3.6.6 2006/06/19 14:52:54 naruse Exp $
#
# ----
#
@@ -49,7 +49,7 @@ module Kconv
#
# Revision of kconv.rb
- REVISION = %q$Revision$
+ REVISION = %q$Revision: 1.3.6.6 $
#Regexp of Encoding
@@ -63,8 +63,8 @@ module Kconv
RegexpEucjp = /\A(?:
[\x00-\x7f] |
\x8e [\xa1-\xdf] |
- \x8f [\xa1-\xfe] [\xa1-\xfe] |
- [\xa1-\xfe] [\xa1-\xfe]
+ \x8f [\xa1-\xdf] [\xa1-\xfe] |
+ [\xa1-\xdf] [\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('-em', str)
+ ::NKF::nkf('-em0', str)
end
module_function :toeuc
diff --git a/ext/nkf/nkf-utf8/nkf.c b/ext/nkf/nkf-utf8/nkf.c
index 9a31c9d879..0d82562326 100644
--- a/ext/nkf/nkf-utf8/nkf.c
+++ b/ext/nkf/nkf-utf8/nkf.c
@@ -39,15 +39,15 @@
** E-Mail: furukawa@tcp-ip.or.jp
** $B$^$G8fO"Mm$r$*4j$$$7$^$9!#(B
***********************************************************************/
-/* $Id$ */
-#define NKF_VERSION "2.0.8"
-#define NKF_RELEASE_DATE "2008-11-08"
+/* $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"
#include "config.h"
#include "utf8tbl.h"
#define COPY_RIGHT \
"Copyright (C) 1987, FUJITSU LTD. (I.Ichikawa),2000 S. Kono, COW\n" \
- "Copyright (C) 2002-2008 Kono, Furukawa, Naruse, mastodon"
+ "Copyright (C) 2002-2006 Kono, Furukawa, Naruse, mastodon"
/*
@@ -62,7 +62,7 @@
**
** t no operation
**
-** j Output code is JIS 7 bit (DEFAULT SELECT)
+** j Outout code is JIS 7 bit (DEFAULT SELECT)
** s Output code is MS Kanji (DEFAULT SELECT)
** e Output code is AT&T JIS (DEFAULT SELECT)
** w Output code is AT&T JIS (DEFAULT SELECT)
@@ -219,7 +219,6 @@ 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
@@ -233,15 +232,8 @@ void djgpp_setbinmode(FILE *fp)
#define UTF8 12
#define UTF8_INPUT 13
-#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 UTF16BE_INPUT 14
+#define UTF16LE_INPUT 15
#define WISH_TRUE 15
@@ -361,8 +353,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);
@@ -374,21 +366,18 @@ 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 output_bom_f = FALSE;
-static int output_endian = ENDIAN_BIG;
+static int unicode_bom_f= 0; /* Output Unicode BOM */
+static int w_oconv16_LE = 0; /* utf-16 little endian */
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);
@@ -448,7 +437,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 = 0;
+static int hold_count;
/* MIME preprocessor fifo */
@@ -512,10 +501,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_UNICODE NKF_INT32_C(0x01000000)
+#define CLASS_UTF16 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_UNICODE)
+#define is_unicode_capsule(c) ((c & CLASS_MASK) == CLASS_UTF16)
#define is_unicode_bmp(c) ((c & VALUE_MASK) <= NKF_INT32_C(0xFFFF))
#ifdef NUMCHAR_OPTION
@@ -548,7 +537,7 @@ static int exec_f = 0;
#ifdef SHIFTJIS_CP932
/* invert IBM extended characters to others */
-static int cp51932_f = FALSE;
+static int cp51932_f = TRUE;
/* invert NEC-selected IBM extended characters to IBM extended characters */
static int cp932inv_f = TRUE;
@@ -576,13 +565,18 @@ 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}, NULL, w_iconv16, 0},
- {"UTF-32", 0, 0, 0, {0, 0, 0}, NULL, w_iconv32, 0},
+ {"UTF-16", 0, 0, 0, {0, 0, 0}, w16_status, w_iconv16, 0},
#endif
{0}
};
@@ -854,7 +848,6 @@ 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;
@@ -864,9 +857,7 @@ int main(int argc, char **argv)
#endif
if ((fin = fopen((origfname = *argv++), "r")) == NULL) {
perror(*--argv);
- *argv++;
- is_argument_error = TRUE;
- continue;
+ return(-1);
} else {
#ifdef OVERWRITE
int fd = 0;
@@ -1014,8 +1005,6 @@ int main(int argc, char **argv)
#endif
}
}
- if (is_argument_error)
- return(-1);
}
#ifdef EASYWIN /*Easy Win */
if (file_out_f == FALSE)
@@ -1196,19 +1185,13 @@ void options(unsigned char *cp)
codeset[i] = nkf_toupper(p[i]);
}
codeset[i] = 0;
- if(strcmp(codeset, "ISO-2022-JP") == 0){
- input_f = JIS_INPUT;
- }else if(strcmp(codeset, "X-ISO2022JP-CP932") == 0 ||
+ if(strcmp(codeset, "ISO-2022-JP") == 0 ||
+ strcmp(codeset, "X-ISO2022JP-CP932") == 0 ||
strcmp(codeset, "CP50220") == 0 ||
strcmp(codeset, "CP50221") == 0 ||
- strcmp(codeset, "CP50222") == 0){
+ strcmp(codeset, "CP50222") == 0 ||
+ strcmp(codeset, "ISO-2022-JP-MS") == 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
@@ -1222,11 +1205,13 @@ 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
@@ -1235,9 +1220,10 @@ void options(unsigned char *cp)
#endif
}else if(strcmp(codeset, "EUCJP") == 0 ||
strcmp(codeset, "EUC-JP") == 0){
- input_f = EUC_INPUT;
+ input_f = JIS_INPUT;
}else if(strcmp(codeset, "CP51932") == 0){
- input_f = EUC_INPUT;
+ input_f = JIS_INPUT;
+ x0201_f = FALSE;
#ifdef SHIFTJIS_CP932
cp51932_f = TRUE;
#endif
@@ -1247,7 +1233,8 @@ void options(unsigned char *cp)
}else if(strcmp(codeset, "EUC-JP-MS") == 0 ||
strcmp(codeset, "EUCJP-MS") == 0 ||
strcmp(codeset, "EUCJPMS") == 0){
- input_f = EUC_INPUT;
+ input_f = JIS_INPUT;
+ x0201_f = FALSE;
#ifdef SHIFTJIS_CP932
cp51932_f = FALSE;
#endif
@@ -1256,7 +1243,8 @@ void options(unsigned char *cp)
#endif
}else if(strcmp(codeset, "EUC-JP-ASCII") == 0 ||
strcmp(codeset, "EUCJP-ASCII") == 0){
- input_f = EUC_INPUT;
+ input_f = JIS_INPUT;
+ x0201_f = FALSE;
#ifdef SHIFTJIS_CP932
cp51932_f = FALSE;
#endif
@@ -1269,13 +1257,17 @@ 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 = EUC_INPUT;
+ input_f = JIS_INPUT;
+ x0201_f = FALSE;
x0213_f = TRUE;
#ifdef SHIFTJIS_CP932
cp51932_f = FALSE;
+ cp932inv_f = FALSE;
#endif
#ifdef UTF8_INPUT_ENABLE
}else if(strcmp(codeset, "UTF-8") == 0 ||
@@ -1288,69 +1280,43 @@ void options(unsigned char *cp)
input_f = UTF8_INPUT;
nfc_f = TRUE;
#endif
- }else if(strcmp(codeset, "UTF-16") == 0 ||
- strcmp(codeset, "UTF-16BE") == 0 ||
+ }else if(strcmp(codeset, "UTF-16") == 0){
+ input_f = UTF16BE_INPUT;
+ utf16_mode = UTF16BE_INPUT;
+ }else if(strcmp(codeset, "UTF-16BE") == 0 ||
strcmp(codeset, "UTF-16BE-BOM") == 0){
- input_f = UTF16_INPUT;
- input_endian = ENDIAN_BIG;
+ input_f = UTF16BE_INPUT;
+ utf16_mode = UTF16BE_INPUT;
}else if(strcmp(codeset, "UTF-16LE") == 0 ||
strcmp(codeset, "UTF-16LE-BOM") == 0){
- 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;
+ input_f = UTF16LE_INPUT;
+ utf16_mode = UTF16LE_INPUT;
#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){
+ if(strcmp(codeset, "ISO-2022-JP") == 0 ||
+ strcmp(codeset, "CP50220") == 0){
output_conv = j_oconv;
}else if(strcmp(codeset, "X-ISO2022JP-CP932") == 0){
output_conv = j_oconv;
no_cp932ext_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, "CP50220") == 0){
- output_conv = j_oconv;
- 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){
+ }else if(strcmp(codeset, "CP50221") == 0 ||
+ strcmp(codeset, "ISO-2022-JP-MS") == 0){
output_conv = j_oconv;
-#ifdef SHIFTJIS_CP932
- cp932inv_f = FALSE;
-#endif
-#ifdef UTF8_OUTPUT_ENABLE
- ms_ucs_map_f = UCS_MAP_CP932;
-#endif
+ x0201_f = FALSE;
}else if(strcmp(codeset, "ISO-2022-JP-1") == 0){
output_conv = j_oconv;
#ifdef X0212_ENABLE
x0212_f = TRUE;
#endif
#ifdef SHIFTJIS_CP932
- cp932inv_f = FALSE;
+ cp51932_f = FALSE;
#endif
}else if(strcmp(codeset, "ISO-2022-JP-3") == 0){
output_conv = j_oconv;
@@ -1359,7 +1325,16 @@ void options(unsigned char *cp)
#endif
x0213_f = TRUE;
#ifdef SHIFTJIS_CP932
- cp932inv_f = FALSE;
+ cp51932_f = FALSE;
+#endif
+ }else if(strcmp(codeset, "ISO-2022-JP-MS") == 0){
+ output_conv = j_oconv;
+ x0201_f = FALSE;
+#ifdef X0212_ENABLE
+ x0212_f = TRUE;
+#endif
+#ifdef SHIFTJIS_CP932
+ cp51932_f = FALSE;
#endif
}else if(strcmp(codeset, "SHIFT_JIS") == 0){
output_conv = s_oconv;
@@ -1368,6 +1343,11 @@ 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
@@ -1376,8 +1356,9 @@ 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
- cp932inv_f = FALSE;
+ cp51932_f = TRUE;
#endif
#ifdef UTF8_OUTPUT_ENABLE
ms_ucs_map_f = UCS_MAP_CP932;
@@ -1386,18 +1367,26 @@ 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
@@ -1416,42 +1405,32 @@ void options(unsigned char *cp)
#endif
x0213_f = TRUE;
#ifdef SHIFTJIS_CP932
- cp932inv_f = FALSE;
+ cp51932_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;
- output_bom_f = TRUE;
+ unicode_bom_f=2;
}else if(strcmp(codeset, "UTF-16BE") == 0){
- output_conv = w_oconv16;
+ output_conv = w_oconv16;
+ unicode_bom_f=1;
}else if(strcmp(codeset, "UTF-16") == 0 ||
strcmp(codeset, "UTF-16BE-BOM") == 0){
- output_conv = w_oconv16;
- output_bom_f = TRUE;
+ output_conv = w_oconv16;
+ unicode_bom_f=2;
}else if(strcmp(codeset, "UTF-16LE") == 0){
- output_conv = w_oconv16;
- output_endian = ENDIAN_LITTLE;
+ output_conv = w_oconv16;
+ w_oconv16_LE = 1;
+ unicode_bom_f=1;
}else if(strcmp(codeset, "UTF-16LE-BOM") == 0){
- 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;
+ output_conv = w_oconv16;
+ w_oconv16_LE = 1;
+ unicode_bom_f=2;
#endif
}
continue;
@@ -1670,7 +1649,6 @@ 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;
@@ -1717,71 +1695,56 @@ void options(unsigned char *cp)
#endif
#ifdef UTF8_OUTPUT_ENABLE
case 'w': /* UTF-8 output */
- 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 ('1'== cp[0] && '6'==cp[1]) {
+ output_conv = w_oconv16; cp+=2;
if (cp[0]=='L') {
- cp++;
- output_endian = ENDIAN_LITTLE;
+ unicode_bom_f=2; cp++;
+ w_oconv16_LE = 1;
+ if (cp[0] == '0'){
+ unicode_bom_f=1; cp++;
+ }
} else if (cp[0] == 'B') {
- cp++;
- } else {
- continue;
- }
+ 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;
if (cp[0] == '0'){
- cp++;
- } else {
- output_bom_f = TRUE;
+ unicode_bom_f=1; cp++;
}
- }
+ } else
+ output_conv = w_oconv;
continue;
#endif
#ifdef UTF8_INPUT_ENABLE
- 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;
- }
+ case 'W': /* UTF-8 input */
+ if ('1'== cp[0] && '6'==cp[1]) {
+ input_f = UTF16BE_INPUT;
+ utf16_mode = UTF16BE_INPUT;
+ cp += 2;
if (cp[0]=='L') {
cp++;
- input_endian = ENDIAN_LITTLE;
+ input_f = UTF16LE_INPUT;
+ utf16_mode = UTF16LE_INPUT;
} 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 */
- input_f = JIS_INPUT;
- continue;
case 'E': /* AT&T EUC input */
- input_f = EUC_INPUT;
+ input_f = JIS_INPUT;
continue;
case 'S': /* MS Kanji input */
input_f = SJIS_INPUT;
@@ -1911,7 +1874,12 @@ 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;
@@ -2167,6 +2135,52 @@ 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){
@@ -2186,9 +2200,6 @@ 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);
}
@@ -2211,17 +2222,6 @@ 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,12 +2232,6 @@ 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;
@@ -2380,17 +2374,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 == EUC_INPUT || input_f == LATIN1_INPUT) {
+ if (input_f == JIS_INPUT || input_f == LATIN1_INPUT) {
set_iconv(-TRUE, e_iconv);
} else if (input_f == SJIS_INPUT) {
set_iconv(-TRUE, s_iconv);
#ifdef UTF8_INPUT_ENABLE
} else if (input_f == UTF8_INPUT) {
set_iconv(-TRUE, w_iconv);
- } else if (input_f == UTF16_INPUT) {
+ } else if (input_f == UTF16BE_INPUT) {
+ set_iconv(-TRUE, w_iconv16);
+ } else if (input_f == UTF16LE_INPUT) {
set_iconv(-TRUE, w_iconv16);
- } else if (input_f == UTF32_INPUT) {
- set_iconv(-TRUE, w_iconv32);
#endif
} else {
set_iconv(FALSE, e_iconv);
@@ -2405,133 +2399,27 @@ 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 c3, c2=0, c1, c0=0;
+ nkf_char c1,
+ c2, c3;
int is_8bit = FALSE;
- if(input_f == SJIS_INPUT || input_f == EUC_INPUT
+ module_connection();
+ c2 = 0;
+
+ if(input_f == SJIS_INPUT
#ifdef UTF8_INPUT_ENABLE
- || input_f == UTF8_INPUT || input_f == UTF16_INPUT
+ || input_f == UTF8_INPUT || input_f == UTF16BE_INPUT || input_f == UTF16LE_INPUT
#endif
){
is_8bit = TRUE;
}
+
input_mode = ASCII;
output_mode = ASCII;
shift_mode = FALSE;
@@ -2540,9 +2428,6 @@ 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)
@@ -2550,7 +2435,7 @@ nkf_char kanji_convert(FILE *f)
code_status(c1);
if (c2) {
/* second byte */
- if (c2 > ((input_f == JIS_INPUT && ms_ucs_map_f) ? 0x92 : DEL)) {
+ if (c2 > DEL) {
/* in case of 8th bit is on */
if (!estab_f&&!mime_decode_mode) {
/* in case of not established yet */
@@ -2560,16 +2445,14 @@ nkf_char kanji_convert(FILE *f)
else
c2 = 0;
NEXT;
- } else {
- /* in case of already established */
- if (c1 < AT) {
- /* ignore bogus code and not CP5022x UCD */
- c2 = 0;
- NEXT;
- } else {
- SEND;
- }
- }
+ } else
+ /* in case of already established */
+ if (c1 < AT) {
+ /* ignore bogus code */
+ c2 = 0;
+ NEXT;
+ } else
+ SEND;
} else
/* second byte, 7 bit code */
/* it might be kanji shitfted */
@@ -2581,68 +2464,25 @@ nkf_char kanji_convert(FILE *f)
SEND;
} else {
/* first byte */
+ if (
#ifdef UTF8_INPUT_ENABLE
- 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
+ iconv == w_iconv16
+#else
+ 0
#endif
+ ) {
+ c2 = c1;
+ c1 = (*i_getc)(f);
+ SEND;
#ifdef NUMCHAR_OPTION
- if (is_unicode_capsule(c1)){
+ } else if (is_unicode_capsule(c1)){
SEND;
- } else
#endif
- if (c1 > ((input_f == JIS_INPUT && ms_ucs_map_f) ? 0x92 : DEL)) {
+ } else if (c1 > 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 */
@@ -2733,13 +2573,13 @@ nkf_char kanji_convert(FILE *f)
/* normal ASCII code */
SEND;
}
- } else if (c1 == SI && (!is_8bit || mime_decode_mode)) {
+ } else if (!is_8bit && c1 == SI) {
shift_mode = FALSE;
NEXT;
- } else if (c1 == SO && (!is_8bit || mime_decode_mode)) {
+ } else if (!is_8bit && c1 == SO) {
shift_mode = TRUE;
NEXT;
- } else if (c1 == ESC && (!is_8bit || mime_decode_mode)) {
+ } else if (!is_8bit && c1 == ESC ) {
if ((c1 = (*i_getc)(f)) == EOF) {
/* (*oconv)(0, ESC); don't send bogus code */
LAST;
@@ -2847,44 +2687,6 @@ 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;
@@ -2914,47 +2716,22 @@ 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:
- 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) {
+ if ((*iconv)(c2, c1, 0) < 0){ /* can be EUC/SJIS */
+ nkf_char c0 = (*i_getc)(f);
+ if (c0 != 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
@@ -2970,7 +2747,6 @@ nkf_char kanji_convert(FILE *f)
}
c2 = 0;
- c0 = 0;
continue;
/* goto next_word */
}
@@ -2995,8 +2771,7 @@ nkf_char kanji_convert(FILE *f)
nkf_char
h_conv(FILE *f, nkf_char c2, nkf_char c1)
{
- nkf_char ret, c3, c0;
- int hold_index;
+ nkf_char wc,c3;
/** it must NOT be in the kanji shifte sequence */
@@ -3025,12 +2800,12 @@ h_conv(FILE *f, nkf_char c2, nkf_char c1)
code_status(c1);
}
while (p->name){
- if (p->status_func && p->score < result->score){
+ if (p->score < result->score){
result = p;
}
++p;
}
- set_iconv(TRUE, result->iconv_func);
+ set_iconv(FALSE, result->iconv_func);
}
@@ -3043,10 +2818,10 @@ h_conv(FILE *f, nkf_char c2, nkf_char c1)
** Kanji codes by oconv and leave estab_f unchanged.
**/
- ret = c1;
- hold_index = 0;
- while (hold_index < hold_count){
- c2 = hold_buf[hold_index++];
+ c3=c1;
+ wc = 0;
+ while (wc < hold_count){
+ c2 = hold_buf[wc++];
if (c2 <= DEL
#ifdef NUMCHAR_OPTION
|| is_unicode_capsule(c2)
@@ -3058,8 +2833,8 @@ h_conv(FILE *f, nkf_char c2, nkf_char c1)
(*iconv)(X0201, c2, 0);
continue;
}
- if (hold_index < hold_count){
- c1 = hold_buf[hold_index++];
+ if (wc < hold_count){
+ c1 = hold_buf[wc++];
}else{
c1 = (*i_getc)(f);
if (c1 == EOF){
@@ -3068,48 +2843,28 @@ h_conv(FILE *f, nkf_char c2, nkf_char c1)
}
code_status(c1);
}
- 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 {
+ 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;
+ }
code_status(c0);
}
(*iconv)(c2, c1, c0);
- break;
- }
- if (c0 == EOF) break;
+ }
}
- return ret;
+ return c3;
}
-nkf_char push_hold_buf(nkf_char c2)
+
+
+nkf_char
+push_hold_buf(nkf_char c2)
{
if (hold_count >= HOLD_SIZE*2)
return (EOF);
@@ -3124,7 +2879,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 (!cp932inv_f && is_ibmext_in_sjis(c2)){
+ if (cp51932_f && is_ibmext_in_sjis(c2)){
#if 0
extern const unsigned short shiftjis_cp932[3][189];
#endif
@@ -3134,17 +2889,6 @@ 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)){
@@ -3154,7 +2898,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) & 0x7f);
+ c2 = PREFIX_EUCG3 | (val >> 8);
c1 = val & 0xff;
}else{
c2 = val >> 8;
@@ -3199,11 +2943,6 @@ 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;
@@ -3221,26 +2960,20 @@ nkf_char e_iconv(nkf_char c2, nkf_char c1, nkf_char c0)
if (c0 == 0){
return -1;
}
- 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;
+ 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;
- }
- }
- }
-#endif /* 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;
+ }
+ }
}
+#endif /* SHIFTJIS_CP932 */
#endif /* X0212_ENABLE */
} else if (c2 == SSO){
c2 = X0201;
@@ -3248,26 +2981,8 @@ nkf_char e_iconv(nkf_char c2, nkf_char c1, nkf_char c0)
} else if ((c2 == EOF) || (c2 == 0) || c2 < SPACE) {
/* NOP */
} else {
- 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 */
- }
+ c1 &= 0x7f;
+ c2 &= 0x7f;
}
(*oconv)(c2, c1);
return 0;
@@ -3286,7 +3001,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_UNICODE | ww16_conv(c2, c1, c0);
+ if (p1) *p1 = CLASS_UTF16 | ww16_conv(c2, c1, c0);
ret = 0;
}
#endif
@@ -3297,63 +3012,43 @@ 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};
- 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)
+ /* 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)
return 0;
- break;
- case 41:
- if (c0 == 0) return -2;
- if (c1 < 0x80 || 0xBF < c1 || (c0 & 0xc0c0) != 0x8080)
+ }else if(c2 == 0xED){
+ if(c1 < 0x80 || 0x9F < c1 || c0 < 0x80 || 0xBF < c0)
return 0;
- break;
- case 42:
- if (c0 == 0) return -2;
- if (c1 < 0x80 || 0x8F < c1 || (c0 & 0xc0c0) != 0x8080)
+ }else if((c2 & 0xf0) == 0xe0){
+ if(c1 < 0x80 || 0xBF < c1 || c0 < 0x80 || 0xBF < c0)
return 0;
- break;
- default:
- return 0;
- break;
- }
+ }else return 0;
}
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);
}
@@ -3380,10 +3075,6 @@ 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;
@@ -3396,14 +3087,8 @@ 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 >= 0xf8) {
+ if (c2 >= 0xf0){
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;
@@ -3431,7 +3116,7 @@ nkf_char w16e_conv(nkf_char val, nkf_char *p2, nkf_char *p1)
#ifdef NUMCHAR_OPTION
if (ret > 0){
*p2 = 0;
- *p1 = CLASS_UNICODE | val;
+ *p1 = CLASS_UTF16 | val;
ret = 0;
}
#endif
@@ -3443,19 +3128,27 @@ 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 = 0;
+ 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;
+ }
if ((c2==0 && c1 < 0x80) || c2==EOF) {
(*oconv)(c2, c1);
return 0;
- }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;
- */
+ }else if((c2>>3)==27){ /* surrogate pair */
return 1;
}else ret = w16e_conv(((c2 & 0xff)<<8) + c1, &c2, &c1);
if (ret) return ret;
@@ -3463,22 +3156,6 @@ 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
@@ -3527,7 +3204,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(!cp932inv_f){
+ }else if(cp51932_f){
switch(c2){
case 0xC2:
if(no_best_fit_chars_table_C2[c1&0x3F]) return 1;
@@ -3583,7 +3260,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 && !cp932inv_f) return 1;
+ if(c0 == 0x9E && cp51932_f) return 1;
break;
case 0xBF:
if(0xA0 <= c0 && c0 <= 0xA5) return 1;
@@ -3600,7 +3277,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 && !cp932inv_f && is_eucg3(*p2)) {
+ if (!ret && cp51932_f && is_eucg3(*p2)) {
nkf_char s2, s1;
if (e2s_conv(*p2, *p1, &s2, &s1) == 0) {
s2e_conv(s2, s1, p2, p1);
@@ -3779,19 +3456,18 @@ void w_oconv(nkf_char c2, nkf_char c1)
{
nkf_char c0;
nkf_char val;
-
- if (output_bom_f) {
- output_bom_f = FALSE;
- (*o_putc)('\357');
- (*o_putc)('\273');
- (*o_putc)('\277');
- }
-
if (c2 == EOF) {
(*o_putc)(EOF);
return;
}
+ if (unicode_bom_f==2) {
+ (*o_putc)('\357');
+ (*o_putc)('\273');
+ (*o_putc)('\277');
+ unicode_bom_f=1;
+ }
+
#ifdef NUMCHAR_OPTION
if (c2 == 0 && is_unicode_capsule(c1)){
val = c1 & VALUE_MASK;
@@ -3805,7 +3481,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)(0xF0 | ( val>>18));
+ (*o_putc)(0xE0 | ( val>>18));
(*o_putc)(0x80 | ((val>>12) & 0x3f));
(*o_putc)(0x80 | ((val>> 6) & 0x3f));
(*o_putc)(0x80 | ( val & 0x3f));
@@ -3836,20 +3512,20 @@ void w_oconv(nkf_char c2, nkf_char c1)
void w_oconv16(nkf_char c2, nkf_char c1)
{
- if (output_bom_f) {
- output_bom_f = FALSE;
- if (output_endian == ENDIAN_LITTLE){
+ if (c2 == EOF) {
+ (*o_putc)(EOF);
+ return;
+ }
+
+ if (unicode_bom_f==2) {
+ if (w_oconv16_LE){
(*o_putc)((unsigned char)'\377');
(*o_putc)('\376');
}else{
(*o_putc)('\376');
(*o_putc)((unsigned char)'\377');
}
- }
-
- if (c2 == EOF) {
- (*o_putc)(EOF);
- return;
+ unicode_bom_f=1;
}
if (c2 == ISO8859_1) {
@@ -3865,7 +3541,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 (output_endian == ENDIAN_LITTLE){
+ if (w_oconv16_LE){
(*o_putc)(c2 & 0xff);
(*o_putc)((c2 >> 8) & 0xff);
(*o_putc)(c1 & 0xff);
@@ -3884,9 +3560,8 @@ 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 (output_endian == ENDIAN_LITTLE){
+ if (w_oconv16_LE){
(*o_putc)(c1);
(*o_putc)(c2);
}else{
@@ -3895,50 +3570,6 @@ 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)
@@ -3947,26 +3578,8 @@ 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)){
- 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;
- }
+ if(encode_fallback)(*encode_fallback)(c1);
+ return;
}
}
#endif
@@ -3986,7 +3599,7 @@ void e_oconv(nkf_char c2, nkf_char c1)
} else if (is_eucg3(c2)){
output_mode = JAPANESE_EUC;
#ifdef SHIFTJIS_CP932
- if (!cp932inv_f){
+ if (cp51932_f){
nkf_char s2, s1;
if (e2s_conv(c2, c1, &s2, &s1) == 0){
s2e_conv(s2, s1, &c2, &c1);
@@ -4052,7 +3665,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 & 0x7f;
+ ndx = c2 & 0xff;
if (x0213_f){
if((0x21 <= ndx && ndx <= 0x2F)){
if (p2) *p2 = ((ndx - 1) >> 1) + 0xec - ndx / 8 * 3;
@@ -4099,21 +3712,9 @@ 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)){
- 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;
- }
- }
+ if(encode_fallback)(*encode_fallback)(c1);
+ return;
+ }
}
#endif
if (c2 == EOF) {
@@ -4172,16 +3773,8 @@ 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)){
- 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;
- }
+ if(encode_fallback)(*encode_fallback)(c1);
+ return;
}
}
#endif
@@ -4238,9 +3831,7 @@ void j_oconv(nkf_char c2, nkf_char c1)
}
(*o_putc)(c1);
} else {
- if(ms_ucs_map_f
- ? c2<0x20 || 0x92<c2 || c1<0x20 || 0x7e<c1
- : c2<0x20 || 0x7e<c2 || c1<0x20 || 0x7e<c1) return;
+ if(c2<0x20 || 0x7e<c2 || c1<0x20 || 0x7e<c1) return;
if(x0213_f){
if (output_mode!=X0213_1) {
output_mode = X0213_1;
@@ -4644,7 +4235,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_UNICODE | 0x3094;
+ c1 = CLASS_UTF16 | 0x3094;
(*o_hira_conv)(c2,c1);
return;
}
@@ -4655,7 +4246,7 @@ void hira_conv(nkf_char c2, nkf_char c1)
}
}
if (hira_f & 2) {
- if (c2 == 0 && c1 == (CLASS_UNICODE | 0x3094)) {
+ if (c2 == 0 && c1 == (CLASS_UTF16 | 0x3094)) {
c2 = 0x25;
c1 = 0x74;
} else if (c2 == 0x24 && 0x20 < c1 && c1 < 0x74) {
@@ -5043,7 +4634,7 @@ nkf_char numchar_getc(FILE *f)
}
}
if (c != -1){
- return CLASS_UNICODE | c;
+ return CLASS_UTF16 | c;
}
while (i > 0){
(*u)(buf[i], f);
@@ -5818,14 +5409,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
- output_bom_f = FALSE;
- output_endian = ENDIAN_BIG;
+ unicode_bom_f = 0;
+ w_oconv16_LE = 0;
#endif
#ifdef UNICODE_NORMALIZATION
nfc_f = FALSE;
@@ -5859,7 +5450,9 @@ void reinit(void)
prefix_table[i] = 0;
}
}
- hold_count = 0;
+#ifdef UTF8_INPUT_ENABLE
+ utf16_mode = UTF16BE_INPUT;
+#endif
mimeout_buf_count = 0;
mimeout_mode = 0;
base64_count = 0;
@@ -5932,16 +5525,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 Output code is JIS 7 bit, Shift_JIS (DEFAULT), EUC-JP, UTF-8N\n");
+ fprintf(stderr,"j,s,e,w Outout code is JIS 7 bit, Shift_JIS (DEFAULT), EUC-JP, UTF-8N\n");
#endif
#ifdef DEFAULT_CODE_JIS
- fprintf(stderr,"j,s,e,w Output code is JIS 7 bit (DEFAULT), Shift JIS, EUC-JP, UTF-8N\n");
+ fprintf(stderr,"j,s,e,w Outout code is JIS 7 bit (DEFAULT), Shift JIS, EUC-JP, UTF-8N\n");
#endif
#ifdef DEFAULT_CODE_EUC
- fprintf(stderr,"j,s,e,w Output code is JIS 7 bit, Shift JIS, EUC-JP (DEFAULT), UTF-8N\n");
+ fprintf(stderr,"j,s,e,w Outout code is JIS 7 bit, Shift JIS, EUC-JP (DEFAULT), UTF-8N\n");
#endif
#ifdef DEFAULT_CODE_UTF8
- fprintf(stderr,"j,s,e,w Output code is JIS 7 bit, Shift JIS, EUC-JP, UTF-8N (DEFAULT)\n");
+ fprintf(stderr,"j,s,e,w Outout 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 e43ad553d6..9e59956a0a 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, 0x81CA, 0xFA55, 0xFA56, 0xFA57,
+ 0xFA49, 0, 0xFA55, 0xFA56, 0xFA57,
},
};
#endif /* SHIFTJIS_CP932 */
diff --git a/ext/nkf/nkf.c b/ext/nkf/nkf.c
index 2bb0340a64..8bcb6d15f7 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$
+ * $Id: nkf.c,v 1.9.2.4 2006/03/27 13:28:14 naruse Exp $
*
*/
-#define RUBY_NKF_REVISION "$Revision$"
+#define RUBY_NKF_REVISION "$Revision: 1.9.2.4 $"
#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 = (unsigned char *)RSTRING(result)->ptr;
+ output = RSTRING(result)->ptr;
}
output[output_ctr++] = c;
@@ -158,13 +158,13 @@ rb_nkf_kconv(obj, opt, src)
input_ctr = 0;
StringValue(src);
- input = (unsigned char *)RSTRING(src)->ptr;
+ input = RSTRING(src)->ptr;
i_len = RSTRING(src)->len;
result = rb_str_new(0, i_len*3 + 10);
v = result;
output_ctr = 0;
- output = (unsigned char *)RSTRING(result)->ptr;
+ output = 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 = (unsigned char *)RSTRING(src)->ptr;
+ p = 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 = (unsigned char *)RSTRING(src)->ptr;
+ input = 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 02e06b7149..b2c5ca5ef8 100644
--- a/ext/openssl/extconf.rb
+++ b/ext/openssl/extconf.rb
@@ -1,5 +1,5 @@
=begin
-= $RCSfile$ -- Generator for Makefile
+= $RCSfile: extconf.rb,v $ -- Generator for Makefile
= Info
'OpenSSL for Ruby 2' project
@@ -11,7 +11,7 @@
(See the file 'LICENCE'.)
= Version
- $Id$
+ $Id: extconf.rb,v 1.21.2.9 2006/06/20 11:18:15 gotoyuzo Exp $
=end
require "mkmf"
@@ -36,6 +36,8 @@ 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"
@@ -59,8 +61,6 @@ unless have_header("openssl/conf_api.h")
exit 1
end
-%w"rb_str_set_len rb_block_call".each {|func| have_func(func, "ruby.h")}
-
message "=== Checking for OpenSSL features... ===\n"
have_func("ERR_peek_last_error")
have_func("BN_mod_add")
@@ -83,8 +83,6 @@ have_func("HMAC_CTX_cleanup")
have_func("HMAC_CTX_copy")
have_func("HMAC_CTX_init")
have_func("PEM_def_callback")
-have_func("PKCS5_PBKDF2_HMAC")
-have_func("PKCS5_PBKDF2_HMAC_SHA1")
have_func("X509V3_set_nconf")
have_func("X509V3_EXT_nconf_nid")
have_func("X509_CRL_add0_revoked")
@@ -94,7 +92,6 @@ have_func("X509_CRL_sort")
have_func("X509_STORE_get_ex_data")
have_func("X509_STORE_set_ex_data")
have_func("OBJ_NAME_do_all_sorted")
-have_func("SSL_SESSION_get_id")
have_func("OPENSSL_cleanse")
if try_compile("#define FOO(a, ...) foo(a, ##__VA_ARGS__)\n int x(){FOO(1);FOO(1,2);FOO(1,2,3);}\n")
$defs.push("-DHAVE_VA_ARGS_MACRO")
diff --git a/ext/openssl/lib/net/ftptls.rb b/ext/openssl/lib/net/ftptls.rb
index a21c1f6c3c..e82eff72fa 100644
--- a/ext/openssl/lib/net/ftptls.rb
+++ b/ext/openssl/lib/net/ftptls.rb
@@ -1,5 +1,5 @@
=begin
-= $RCSfile$ -- SSL/TLS enhancement for Net::HTTP.
+= $RCSfile: ftptls.rb,v $ -- SSL/TLS enhancement for Net::HTTP.
= Info
'OpenSSL for Ruby 2' project
@@ -13,7 +13,7 @@
= Requirements
= Version
- $Id$
+ $Id: ftptls.rb,v 1.1 2003/07/23 16:11:30 gotoyuzo Exp $
= Notes
Tested on FreeBSD 5-CURRENT and 4-STABLE
diff --git a/ext/openssl/lib/net/telnets.rb b/ext/openssl/lib/net/telnets.rb
index 2b69280432..c869b5da1c 100644
--- a/ext/openssl/lib/net/telnets.rb
+++ b/ext/openssl/lib/net/telnets.rb
@@ -1,5 +1,5 @@
=begin
-= $RCSfile$ -- SSL/TLS enhancement for Net::Telnet.
+= $RCSfile: telnets.rb,v $ -- SSL/TLS enhancement for Net::Telnet.
= Info
'OpenSSL for Ruby 2' project
@@ -11,7 +11,7 @@
(See the file 'LICENCE'.)
= Version
- $Id$
+ $Id: telnets.rb,v 1.1.2.1 2004/12/20 03:49:16 gotoyuzo Exp $
2001/11/06: Contiributed to Ruby/OpenSSL project.
diff --git a/ext/openssl/lib/openssl.rb b/ext/openssl/lib/openssl.rb
index f10985ed2c..58fd3887e3 100644
--- a/ext/openssl/lib/openssl.rb
+++ b/ext/openssl/lib/openssl.rb
@@ -1,5 +1,5 @@
=begin
-= $RCSfile$ -- Loader for all OpenSSL C-space and Ruby-space definitions
+= $RCSfile: openssl.rb,v $ -- 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$
+ $Id: openssl.rb,v 1.1 2003/07/23 16:11:29 gotoyuzo Exp $
=end
require 'openssl.so'
@@ -19,7 +19,6 @@ require 'openssl.so'
require 'openssl/bn'
require 'openssl/cipher'
require 'openssl/digest'
-require 'openssl/pkcs7'
require 'openssl/ssl'
require 'openssl/x509'
diff --git a/ext/openssl/lib/openssl/bn.rb b/ext/openssl/lib/openssl/bn.rb
index e7cbf2cfaf..4a1595c7ab 100644
--- a/ext/openssl/lib/openssl/bn.rb
+++ b/ext/openssl/lib/openssl/bn.rb
@@ -1,5 +1,5 @@
=begin
-= $RCSfile$ -- Ruby-space definitions that completes C-space funcs for BN
+= $RCSfile: bn.rb,v $ -- 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$
+ $Id: bn.rb,v 1.1 2003/07/23 16:11:30 gotoyuzo Exp $
=end
##
diff --git a/ext/openssl/lib/openssl/buffering.rb b/ext/openssl/lib/openssl/buffering.rb
index 761a017487..9eeb19d959 100644
--- a/ext/openssl/lib/openssl/buffering.rb
+++ b/ext/openssl/lib/openssl/buffering.rb
@@ -1,5 +1,5 @@
=begin
-= $RCSfile$ -- Buffering mix-in module.
+= $RCSfile: buffering.rb,v $ -- Buffering mix-in module.
= Info
'OpenSSL for Ruby 2' project
@@ -11,7 +11,7 @@
(See the file 'LICENCE'.)
= Version
- $Id$
+ $Id: buffering.rb,v 1.5.2.4 2005/09/04 22:03:24 gotoyuzo Exp $
=end
module Buffering
diff --git a/ext/openssl/lib/openssl/cipher.rb b/ext/openssl/lib/openssl/cipher.rb
index 290e9c1d2d..7825e5e9e6 100644
--- a/ext/openssl/lib/openssl/cipher.rb
+++ b/ext/openssl/lib/openssl/cipher.rb
@@ -1,5 +1,5 @@
=begin
-= $RCSfile$ -- Ruby-space predefined Cipher subclasses
+= $RCSfile: cipher.rb,v $ -- Ruby-space predefined Cipher subclasses
= Info
'OpenSSL for Ruby 2' project
@@ -11,7 +11,7 @@
(See the file 'LICENCE'.)
= Version
- $Id$
+ $Id: cipher.rb,v 1.1.2.2 2006/06/20 11:18:15 gotoyuzo Exp $
=end
##
@@ -19,7 +19,7 @@
#require 'openssl'
module OpenSSL
- class Cipher
+ module Cipher
%w(AES CAST5 BF DES IDEA RC2 RC4 RC5).each{|name|
klass = Class.new(Cipher){
define_method(:initialize){|*args|
@@ -41,25 +41,18 @@ module OpenSSL
const_set("AES#{keylen}", klass)
}
- # Generate, set, and return a random key.
- # You must call cipher.encrypt or cipher.decrypt before calling this method.
- def random_key
- str = OpenSSL::Random.random_bytes(self.key_len)
- self.key = str
- return str
- end
-
- # Generate, set, and return a random iv.
- # You must call cipher.encrypt or cipher.decrypt before calling this method.
- def random_iv
- str = OpenSSL::Random.random_bytes(self.iv_len)
- self.iv = str
- return str
- end
-
- # This class is only provided for backwards compatibility. Use OpenSSL::Digest in the future.
- class Cipher < Cipher
- # add warning
+ class Cipher
+ def random_key
+ str = OpenSSL::Random.random_bytes(self.key_len)
+ self.key = str
+ return str
+ end
+
+ def random_iv
+ str = OpenSSL::Random.random_bytes(self.iv_len)
+ self.iv = str
+ return str
+ end
end
end # Cipher
end # OpenSSL
diff --git a/ext/openssl/lib/openssl/digest.rb b/ext/openssl/lib/openssl/digest.rb
index 4810f0121b..6f2c998ff6 100644
--- a/ext/openssl/lib/openssl/digest.rb
+++ b/ext/openssl/lib/openssl/digest.rb
@@ -1,5 +1,5 @@
=begin
-= $RCSfile$ -- Ruby-space predefined Digest subclasses
+= $RCSfile: digest.rb,v $ -- Ruby-space predefined Digest subclasses
= Info
'OpenSSL for Ruby 2' project
@@ -11,7 +11,7 @@
(See the file 'LICENCE'.)
= Version
- $Id$
+ $Id: digest.rb,v 1.1.2.2 2006/06/20 11:18:15 gotoyuzo Exp $
=end
##
@@ -19,17 +19,13 @@
#require 'openssl'
module OpenSSL
- class Digest
+ module Digest
alg = %w(DSS DSS1 MD2 MD4 MD5 MDC2 RIPEMD160 SHA SHA1)
if OPENSSL_VERSION_NUMBER > 0x00908000
alg += %w(SHA224 SHA256 SHA384 SHA512)
end
- def self.digest(name, data)
- super(data, name)
- end
-
alg.each{|name|
klass = Class.new(Digest){
define_method(:initialize){|*data|
@@ -48,14 +44,6 @@ module OpenSSL
const_set(name, klass)
}
- # This class is only provided for backwards compatibility. Use OpenSSL::Digest in the future.
- class Digest < Digest
- def initialize(*args)
- # add warning
- super(*args)
- end
- end
-
end # Digest
end # OpenSSL
diff --git a/ext/openssl/lib/openssl/pkcs7.rb b/ext/openssl/lib/openssl/pkcs7.rb
deleted file mode 100644
index 1f88c1de5e..0000000000
--- a/ext/openssl/lib/openssl/pkcs7.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-=begin
-= $RCSfile$ -- PKCS7
-
-= Licence
- This program is licenced under the same licence as Ruby.
- (See the file 'LICENCE'.)
-
-= Version
- $Id: digest.rb 12148 2007-04-05 05:59:22Z technorama $
-=end
-
-module OpenSSL
- class PKCS7
- # This class is only provided for backwards compatibility. Use OpenSSL::PKCS7 in the future.
- class PKCS7 < PKCS7
- def initialize(*args)
- super(*args)
-
- warn("Warning: OpenSSL::PKCS7::PKCS7 is deprecated after Ruby 1.9; use OpenSSL::PKCS7 instead")
- end
- end
-
- end # PKCS7
-end # OpenSSL
-
diff --git a/ext/openssl/lib/openssl/ssl.rb b/ext/openssl/lib/openssl/ssl.rb
index f722cb0c45..d1007ce6d0 100644
--- a/ext/openssl/lib/openssl/ssl.rb
+++ b/ext/openssl/lib/openssl/ssl.rb
@@ -1,5 +1,5 @@
=begin
-= $RCSfile$ -- Ruby-space definitions that completes C-space funcs for SSL
+= $RCSfile: ssl.rb,v $ -- 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$
+ $Id: ssl.rb,v 1.5.2.6 2006/05/23 18:14:05 gotoyuzo Exp $
=end
require "openssl"
@@ -20,33 +20,6 @@ require "fcntl"
module OpenSSL
module SSL
- class SSLContext
- DEFAULT_PARAMS = {
- :ssl_version => "SSLv23",
- :verify_mode => OpenSSL::SSL::VERIFY_PEER,
- :ciphers => "ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW",
- :options => OpenSSL::SSL::OP_ALL,
- }
-
- DEFAULT_CERT_STORE = OpenSSL::X509::Store.new
- DEFAULT_CERT_STORE.set_default_paths
- if defined?(OpenSSL::X509::V_FLAG_CRL_CHECK_ALL)
- DEFAULT_CERT_STORE.flags = OpenSSL::X509::V_FLAG_CRL_CHECK_ALL
- end
-
- def set_params(params={})
- params = DEFAULT_PARAMS.merge(params)
- self.ssl_version = params.delete(:ssl_version)
- params.each{|name, value| self.__send__("#{name}=", value) }
- if self.verify_mode != OpenSSL::SSL::VERIFY_NONE
- unless self.ca_file or self.ca_path or self.cert_store
- self.cert_store = DEFAULT_CERT_STORE
- end
- end
- return params
- end
- end
-
module SocketForwarder
def addr
to_io.addr
@@ -86,49 +59,36 @@ module OpenSSL
end
end
- def verify_certificate_identity(cert, hostname)
- should_verify_common_name = true
- cert.extensions.each{|ext|
- next if ext.oid != "subjectAltName"
- ext.value.split(/,\s+/).each{|general_name|
- if /\ADNS:(.*)/ =~ general_name
- should_verify_common_name = false
- reg = Regexp.escape($1).gsub(/\\\*/, "[^.]+")
- return true if /\A#{reg}\z/i =~ hostname
- elsif /\AIP Address:(.*)/ =~ general_name
- should_verify_common_name = false
- return true if $1 == hostname
- end
- }
- }
- if should_verify_common_name
- cert.subject.to_a.each{|oid, value|
- if oid == "CN"
- reg = Regexp.escape(value).gsub(/\\\*/, "[^.]+")
- return true if /\A#{reg}\z/i =~ hostname
- end
- }
- end
- return false
- end
- module_function :verify_certificate_identity
-
class SSLSocket
include Buffering
include SocketForwarder
include Nonblock
def post_connection_check(hostname)
- unless OpenSSL::SSL.verify_certificate_identity(peer_cert, hostname)
- raise SSLError, "hostname was not match with the server certificate"
+ check_common_name = true
+ cert = peer_cert
+ cert.extensions.each{|ext|
+ next if ext.oid != "subjectAltName"
+ ext.value.split(/,\s+/).each{|general_name|
+ if /\ADNS:(.*)/ =~ general_name
+ check_common_name = false
+ reg = Regexp.escape($1).gsub(/\\\*/, "[^.]+")
+ return true if /\A#{reg}\z/i =~ hostname
+ elsif /\AIP Address:(.*)/ =~ general_name
+ check_common_name = false
+ return true if $1 == hostname
+ end
+ }
+ }
+ if check_common_name
+ cert.subject.to_a.each{|oid, value|
+ if oid == "CN"
+ reg = Regexp.escape(value).gsub(/\\\*/, "[^.]+")
+ return true if /\A#{reg}\z/i =~ hostname
+ end
+ }
end
- return true
- end
-
- def session
- SSL::Session.new(self)
- rescue SSL::Session::SessionError
- nil
+ raise SSLError, "hostname was not match with the server certificate"
end
end
@@ -154,10 +114,6 @@ module OpenSSL
@svr.listen(backlog)
end
- def shutdown(how=Socket::SHUT_RDWR)
- @svr.shutdown(how)
- end
-
def accept
sock = @svr.accept
begin
diff --git a/ext/openssl/lib/openssl/x509.rb b/ext/openssl/lib/openssl/x509.rb
index e711bda39c..2ad3f8e96e 100644
--- a/ext/openssl/lib/openssl/x509.rb
+++ b/ext/openssl/lib/openssl/x509.rb
@@ -1,5 +1,5 @@
=begin
-= $RCSfile$ -- Ruby-space definitions that completes C-space funcs for X509 and subclasses
+= $RCSfile: x509.rb,v $ -- 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$
+ $Id: x509.rb,v 1.4.2.2 2004/12/19 08:28:33 gotoyuzo Exp $
=end
require "openssl"
diff --git a/ext/openssl/openssl_missing.c b/ext/openssl/openssl_missing.c
index 724f36b8ae..2c005f41e5 100644
--- a/ext/openssl/openssl_missing.c
+++ b/ext/openssl/openssl_missing.c
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: openssl_missing.c,v 1.2.2.4 2006/06/02 10:02:56 gotoyuzo Exp $
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -22,15 +22,17 @@
#include "openssl_missing.h"
#if !defined(HAVE_HMAC_CTX_COPY)
-void
+int
HMAC_CTX_copy(HMAC_CTX *out, HMAC_CTX *in)
{
- if (!out || !in) return;
+ if (!out || !in) return 0;
memcpy(out, in, sizeof(HMAC_CTX));
- EVP_MD_CTX_copy(&out->md_ctx, &in->md_ctx);
- EVP_MD_CTX_copy(&out->i_ctx, &in->i_ctx);
- EVP_MD_CTX_copy(&out->o_ctx, &in->o_ctx);
+ if (!EVP_MD_CTX_copy(&out->md_ctx, &in->md_ctx)
+ || !EVP_MD_CTX_copy(&out->i_ctx, &in->i_ctx)
+ || !EVP_MD_CTX_copy(&out->o_ctx, &in->o_ctx))
+ return 0;
+ return 1;
}
#endif /* HAVE_HMAC_CTX_COPY */
#endif /* NO_HMAC */
diff --git a/ext/openssl/openssl_missing.h b/ext/openssl/openssl_missing.h
index 5a71f73c64..8d580f5ee8 100644
--- a/ext/openssl/openssl_missing.h
+++ b/ext/openssl/openssl_missing.h
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: openssl_missing.h,v 1.2.2.2 2005/04/15 19:16:18 gotoyuzo Exp $
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -15,10 +15,6 @@
extern "C" {
#endif
-#ifndef TYPEDEF_D2I_OF
-typedef char *d2i_of_void();
-#endif
-
/*
* These functions are not included in headers of OPENSSL <= 0.9.6b
*/
@@ -60,33 +56,14 @@ typedef char *d2i_of_void();
(char *(*)())d2i_PKCS7_RECIP_INFO, (char *)ri)
#endif
-#if !defined(HAVE_EVP_MD_CTX_INIT)
void HMAC_CTX_init(HMAC_CTX *ctx);
-#endif
-
-#if !defined(HAVE_HMAC_CTX_COPY)
-void HMAC_CTX_copy(HMAC_CTX *out, HMAC_CTX *in);
-#endif
-
-#if !defined(HAVE_HMAC_CTX_CLEANUP)
+int HMAC_CTX_copy(HMAC_CTX *out, HMAC_CTX *in);
void HMAC_CTX_cleanup(HMAC_CTX *ctx);
-#endif
-#if !defined(HAVE_EVP_MD_CTX_CREATE)
EVP_MD_CTX *EVP_MD_CTX_create(void);
-#endif
-
-#if !defined(HAVE_EVP_MD_CTX_INIT)
void EVP_MD_CTX_init(EVP_MD_CTX *ctx);
-#endif
-
-#if !defined(HAVE_EVP_MD_CTX_CLEANUP)
int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx);
-#endif
-
-#if !defined(HAVE_EVP_MD_CTX_DESTROY)
void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx);
-#endif
#if !defined(HAVE_EVP_CIPHER_CTX_COPY)
int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, EVP_CIPHER_CTX *in);
@@ -130,54 +107,19 @@ int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, EVP_CIPHER_CTX *in);
#define OPENSSL_cleanse(p, l) memset(p, 0, l)
#endif
-#if !defined(HAVE_X509_STORE_SET_EX_DATA)
void *X509_STORE_get_ex_data(X509_STORE *str, int idx);
int X509_STORE_set_ex_data(X509_STORE *str, int idx, void *data);
-#endif
-
-#if !defined(HAVE_X509_CRL_SET_VERSION)
int X509_CRL_set_version(X509_CRL *x, long version);
-#endif
-
-#if !defined(HAVE_X509_CRL_SET_ISSUER_NAME)
int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name);
-#endif
-
-#if !defined(HAVE_X509_CRL_SORT)
int X509_CRL_sort(X509_CRL *c);
-#endif
-
-#if !defined(HAVE_X509_CRL_ADD0_REVOKED)
int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev);
-#endif
-
-#if !defined(HAVE_BN_MOD_SQR)
int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
-#endif
-
-#if !defined(HAVE_BN_MOD_ADD)
int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx);
-#endif
-
-#if !defined(HAVE_BN_MOD_SUB)
int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx);
-#endif
-
-#if !defined(HAVE_BN_RAND_RANGE)
int BN_rand_range(BIGNUM *r, BIGNUM *range);
-#endif
-
-#if !defined(HAVE_BN_PSEUDO_RAND_RANGE)
int BN_pseudo_rand_range(BIGNUM *r, BIGNUM *range);
-#endif
-
-#if !defined(HAVE_CONF_GET1_DEFAULT_CONFIG_FILE)
char *CONF_get1_default_config_file(void);
-#endif
-
-#if !defined(HAVE_PEM_DEF_CALLBACK)
int PEM_def_callback(char *buf, int num, int w, void *key);
-#endif
#if defined(__cplusplus)
}
diff --git a/ext/openssl/ossl.c b/ext/openssl/ossl.c
index 53f476fd65..01c5ca2a04 100644
--- a/ext/openssl/ossl.c
+++ b/ext/openssl/ossl.c
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl.c,v 1.11.2.6 2005/11/01 01:52:13 gotoyuzo Exp $
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -59,7 +59,7 @@ ossl_x509_ary2sk0(VALUE ary)
sk = sk_X509_new_null();
if (!sk) ossl_raise(eOSSLError, NULL);
- for (i = 0; i < RARRAY_LEN(ary); i++) {
+ for (i = 0; i < RARRAY(ary)->len; i++) {
val = rb_ary_entry(ary, i);
if (!rb_obj_is_kind_of(val, cX509Cert)) {
sk_X509_pop_free(sk, X509_free);
@@ -131,7 +131,7 @@ ossl_buf2str(char *buf, int len)
int status = 0;
str = rb_protect((VALUE(*)_((VALUE)))ossl_str_new, len, &status);
- if(!NIL_P(str)) memcpy(RSTRING_PTR(str), buf, len);
+ if(!NIL_P(str)) memcpy(RSTRING(str)->ptr, buf, len);
OPENSSL_free(buf);
if(status) rb_jump_tag(status);
@@ -170,7 +170,7 @@ ossl_pem_passwd_cb(char *buf, int max_len, int flag, void *pwd)
rflag = flag ? Qtrue : Qfalse;
pass = rb_protect(ossl_pem_passwd_cb0, rflag, &status);
if (status) return -1; /* exception was raised. */
- len = RSTRING_LEN(pass);
+ len = RSTRING(pass)->len;
if (len < 4) { /* 4 is OpenSSL hardcoded limit */
rb_warning("password must be longer than 4 bytes");
continue;
@@ -179,7 +179,7 @@ ossl_pem_passwd_cb(char *buf, int max_len, int flag, void *pwd)
rb_warning("password must be shorter then %d bytes", max_len-1);
continue;
}
- memcpy(buf, RSTRING_PTR(pass), len);
+ memcpy(buf, RSTRING(pass)->ptr, len);
break;
}
return len;
@@ -310,14 +310,6 @@ ossl_raise(VALUE exc, const char *fmt, ...)
rb_exc_raise(rb_exc_new(exc, buf, len));
}
-/*
- * call-seq:
- * OpenSSL.errors -> [String...]
- *
- * See any remaining errors held in queue.
- *
- * Any errors you see here are probably due to a bug in ruby's OpenSSL implementation.
- */
VALUE
ossl_get_errors()
{
@@ -353,23 +345,12 @@ ossl_debug(const char *fmt, ...)
}
#endif
-/*
- * call-seq:
- * OpenSSL.debug -> true | false
- */
static VALUE
ossl_debug_get(VALUE self)
{
return dOSSL;
}
-/*
- * call-seq:
- * OpenSSL.debug = boolean -> boolean
- *
- * Turns on or off CRYPTO_MEM_CHECK.
- * Also shows some debugging message on stderr.
- */
static VALUE
ossl_debug_set(VALUE self, VALUE val)
{
@@ -446,8 +427,8 @@ Init_openssl()
/*
* Verify callback Proc index for ext-data
*/
- if ((ossl_verify_cb_idx = X509_STORE_CTX_get_ex_new_index(0, "ossl_verify_cb_idx", 0, 0, 0)) < 0)
- ossl_raise(eOSSLError, "X509_STORE_CTX_get_ex_new_index");
+ ossl_verify_cb_idx =
+ X509_STORE_CTX_get_ex_new_index(0, "ossl_verify_cb_idx", 0, 0, 0);
/*
* Init debug core
@@ -473,7 +454,6 @@ Init_openssl()
Init_ossl_ns_spki();
Init_ossl_pkcs12();
Init_ossl_pkcs7();
- Init_ossl_pkcs5();
Init_ossl_pkey();
Init_ossl_rand();
Init_ossl_ssl();
diff --git a/ext/openssl/ossl.h b/ext/openssl/ossl.h
index 3cc30ae2e8..336b468eb2 100644
--- a/ext/openssl/ossl.h
+++ b/ext/openssl/ossl.h
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl.h,v 1.14.2.4.2.1 2006/12/25 11:16:49 shyouhei Exp $
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -17,19 +17,11 @@
extern "C" {
#endif
-#if 0
- mOSSL = rb_define_module("OpenSSL");
- mX509 = rb_define_module_under(mOSSL, "X509");
-#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>
+ *_FILE_OFFSET_BITS needs to be defined before some system headers on
+ * Solaris.
+ */
+#include "config.h"
/*
* Check the OpenSSL version
@@ -45,12 +37,8 @@ extern "C" {
#endif
#if defined(_WIN32)
+# define OpenFile WINAPI_OpenFile
# define OSSL_NO_CONF_API 1
-# ifdef USE_WINSOCK2
-# include <winsock2.h>
-# else
-# include <winsock.h>
-# endif
#endif
#include <errno.h>
#include <openssl/err.h>
@@ -73,6 +61,18 @@ extern "C" {
# define OSSL_OCSP_ENABLED
# include <openssl/ocsp.h>
#endif
+#if defined(_WIN32)
+# undef OpenFile
+#endif
+
+/*
+ * OpenSSL has defined RFILE and Ruby has defined RFILE - so undef it!
+ */
+#if defined(RFILE) /*&& !defined(OSSL_DEBUG)*/
+# undef RFILE
+#endif
+#include <ruby.h>
+#include <rubyio.h>
/*
* Common Module
@@ -123,10 +123,11 @@ VALUE ossl_x509crl_sk2ary(STACK_OF(X509_CRL) *crl);
VALUE ossl_buf2str(char *buf, int len);
#define ossl_str_adjust(str, p) \
do{\
- int len = RSTRING_LEN(str);\
- int newlen = (p) - (unsigned char*)RSTRING_PTR(str);\
+ int len = RSTRING(str)->len;\
+ int newlen = (p) - (unsigned char*)RSTRING(str)->ptr;\
assert(newlen <= len);\
- rb_str_set_len(str, newlen);\
+ RSTRING(str)->len = newlen;\
+ RSTRING(str)->ptr[newlen] = 0;\
}while(0)
/*
diff --git a/ext/openssl/ossl_asn1.c b/ext/openssl/ossl_asn1.c
index 8ceea95021..6bc5b88e8f 100644
--- a/ext/openssl/ossl_asn1.c
+++ b/ext/openssl/ossl_asn1.c
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_asn1.c,v 1.5.2.9 2006/04/29 13:52:15 gotoyuzo Exp $
* 'OpenSSL for Ruby' team members
* Copyright (C) 2003
* All rights reserved.
@@ -214,7 +214,7 @@ obj_to_asn1bstr(VALUE obj, long unused_bits)
StringValue(obj);
if(!(bstr = ASN1_BIT_STRING_new()))
ossl_raise(eASN1Error, NULL);
- ASN1_BIT_STRING_set(bstr, RSTRING_PTR(obj), RSTRING_LEN(obj));
+ ASN1_BIT_STRING_set(bstr, RSTRING(obj)->ptr, RSTRING(obj)->len);
bstr->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07); /* clear */
bstr->flags |= ASN1_STRING_FLAG_BITS_LEFT|(unused_bits&0x07);
@@ -229,7 +229,7 @@ obj_to_asn1str(VALUE obj)
StringValue(obj);
if(!(str = ASN1_STRING_new()))
ossl_raise(eASN1Error, NULL);
- ASN1_STRING_set(str, RSTRING_PTR(obj), RSTRING_LEN(obj));
+ ASN1_STRING_set(str, RSTRING(obj)->ptr, RSTRING(obj)->len);
return str;
}
@@ -253,8 +253,8 @@ obj_to_asn1obj(VALUE obj)
ASN1_OBJECT *a1obj;
StringValue(obj);
- a1obj = OBJ_txt2obj(RSTRING_PTR(obj), 0);
- if(!a1obj) a1obj = OBJ_txt2obj(RSTRING_PTR(obj), 1);
+ a1obj = OBJ_txt2obj(RSTRING(obj)->ptr, 0);
+ if(!a1obj) a1obj = OBJ_txt2obj(RSTRING(obj)->ptr, 1);
if(!a1obj) ossl_raise(eASN1Error, "invalid OBJECT ID");
return a1obj;
@@ -295,7 +295,7 @@ obj_to_asn1derstr(VALUE obj)
str = ossl_to_der(obj);
if(!(a1str = ASN1_STRING_new()))
ossl_raise(eASN1Error, NULL);
- ASN1_STRING_set(a1str, RSTRING_PTR(str), RSTRING_LEN(str));
+ ASN1_STRING_set(a1str, RSTRING(str)->ptr, RSTRING(str)->len);
return a1str;
}
@@ -445,7 +445,7 @@ decode_time(unsigned char* der, int length)
/********/
typedef struct {
- const char *name;
+ char *name;
VALUE *klass;
} ossl_asn1_info_t;
@@ -678,7 +678,7 @@ static VALUE
join_der(VALUE enumerable)
{
VALUE str = rb_str_new(0, 0);
- rb_block_call(enumerable, rb_intern("each"), 0, 0, join_der_i, str);
+ rb_iterate(rb_each, enumerable, join_der_i, str);
return str;
}
@@ -699,13 +699,13 @@ ossl_asn1data_to_der(VALUE self)
tag = ossl_asn1_tag(self);
tag_class = ossl_asn1_tag_class(self);
- if((length = ASN1_object_size(1, RSTRING_LEN(value), tag)) <= 0)
+ if((length = ASN1_object_size(1, RSTRING(value)->len, tag)) <= 0)
ossl_raise(eASN1Error, NULL);
der = rb_str_new(0, length);
- p = RSTRING_PTR(der);
- ASN1_put_object(&p, is_cons, RSTRING_LEN(value), tag, tag_class);
- memcpy(p, RSTRING_PTR(value), RSTRING_LEN(value));
- p += RSTRING_LEN(value);
+ p = RSTRING(der)->ptr;
+ ASN1_put_object(&p, is_cons, RSTRING(value)->len, tag, tag_class);
+ memcpy(p, RSTRING(value)->ptr, RSTRING(value)->len);
+ p += RSTRING(value)->len;
ossl_str_adjust(der, p);
return der;
@@ -824,8 +824,8 @@ ossl_asn1_traverse(VALUE self, VALUE obj)
obj = ossl_to_der_if_possible(obj);
tmp = rb_str_new4(StringValue(obj));
- p = RSTRING_PTR(tmp);
- ossl_asn1_decode0(&p, RSTRING_LEN(tmp), &offset, 0, 0, 1);
+ p = RSTRING(tmp)->ptr;
+ ossl_asn1_decode0(&p, RSTRING(tmp)->len, &offset, 0, 0, 1);
return Qnil;
}
@@ -840,8 +840,8 @@ ossl_asn1_decode(VALUE self, VALUE obj)
obj = ossl_to_der_if_possible(obj);
tmp = rb_str_new4(StringValue(obj));
- p = RSTRING_PTR(tmp);
- ary = ossl_asn1_decode0(&p, RSTRING_LEN(tmp), &offset, 0, 1, 0);
+ p = RSTRING(tmp)->ptr;
+ ary = ossl_asn1_decode0(&p, RSTRING(tmp)->len, &offset, 0, 1, 0);
ret = rb_ary_entry(ary, 0);
return ret;
@@ -857,8 +857,8 @@ ossl_asn1_decode_all(VALUE self, VALUE obj)
obj = ossl_to_der_if_possible(obj);
tmp = rb_str_new4(StringValue(obj));
- p = RSTRING_PTR(tmp);
- ret = ossl_asn1_decode0(&p, RSTRING_LEN(tmp), &offset, 0, 0, 0);
+ p = RSTRING(tmp)->ptr;
+ ret = ossl_asn1_decode0(&p, RSTRING(tmp)->len, &offset, 0, 0, 0);
return ret;
}
@@ -973,21 +973,21 @@ ossl_asn1cons_to_der(VALUE self)
explicit = ossl_asn1_is_explicit(self);
value = join_der(ossl_asn1_get_value(self));
- seq_len = ASN1_object_size(1, RSTRING_LEN(value), tag);
+ seq_len = ASN1_object_size(1, RSTRING(value)->len, tag);
length = ASN1_object_size(1, seq_len, tn);
str = rb_str_new(0, length);
- p = RSTRING_PTR(str);
+ p = RSTRING(str)->ptr;
if(tc == V_ASN1_UNIVERSAL)
- ASN1_put_object(&p, 1, RSTRING_LEN(value), tn, tc);
+ ASN1_put_object(&p, 1, RSTRING(value)->len, tn, tc);
else{
if(explicit){
ASN1_put_object(&p, 1, seq_len, tn, tc);
- ASN1_put_object(&p, 1, RSTRING_LEN(value), tag, V_ASN1_UNIVERSAL);
+ ASN1_put_object(&p, 1, RSTRING(value)->len, tag, V_ASN1_UNIVERSAL);
}
- else ASN1_put_object(&p, 1, RSTRING_LEN(value), tn, tc);
+ else ASN1_put_object(&p, 1, RSTRING(value)->len, tn, tc);
}
- memcpy(p, RSTRING_PTR(value), RSTRING_LEN(value));
- p += RSTRING_LEN(value);
+ memcpy(p, RSTRING(value)->ptr, RSTRING(value)->len);
+ p += RSTRING(value)->len;
ossl_str_adjust(str, p);
return str;
@@ -1007,7 +1007,7 @@ ossl_asn1obj_s_register(VALUE self, VALUE oid, VALUE sn, VALUE ln)
StringValue(sn);
StringValue(ln);
- if(!OBJ_create(RSTRING_PTR(oid), RSTRING_PTR(sn), RSTRING_PTR(ln)))
+ if(!OBJ_create(RSTRING(oid)->ptr, RSTRING(sn)->ptr, RSTRING(ln)->ptr))
ossl_raise(eASN1Error, NULL);
return Qtrue;
@@ -1087,10 +1087,6 @@ 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");
@@ -1112,9 +1108,9 @@ Init_ossl_asn1()
}
cASN1Data = rb_define_class_under(mASN1, "ASN1Data", rb_cObject);
- rb_attr(cASN1Data, rb_intern("value"), 1, 1, 0);
- rb_attr(cASN1Data, rb_intern("tag"), 1, 1, 0);
- rb_attr(cASN1Data, rb_intern("tag_class"), 1, 1, 0);
+ rb_attr(cASN1Data, rb_intern("value"), 1, 1, Qtrue);
+ rb_attr(cASN1Data, rb_intern("tag"), 1, 1, Qtrue);
+ rb_attr(cASN1Data, rb_intern("tag_class"), 1, 1, Qtrue);
rb_define_method(cASN1Data, "initialize", ossl_asn1data_initialize, 3);
rb_define_method(cASN1Data, "to_der", ossl_asn1data_to_der, 0);
@@ -1166,5 +1162,5 @@ do{\
rb_define_method(cASN1ObjectId, "oid", ossl_asn1obj_get_oid, 0);
rb_define_alias(cASN1ObjectId, "short_name", "sn");
rb_define_alias(cASN1ObjectId, "long_name", "ln");
- rb_attr(cASN1BitString, rb_intern("unused_bits"), 1, 1, 0);
+ rb_attr(cASN1BitString, rb_intern("unused_bits"), 1, 1, Qtrue);
}
diff --git a/ext/openssl/ossl_asn1.h b/ext/openssl/ossl_asn1.h
index 8aad9f970d..6a1c97b902 100644
--- a/ext/openssl/ossl_asn1.h
+++ b/ext/openssl/ossl_asn1.h
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_asn1.h,v 1.3.2.1 2005/09/10 01:17:00 gotoyuzo Exp $
* '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 6db1fb9a62..4e3248eb1d 100644
--- a/ext/openssl/ossl_bio.c
+++ b/ext/openssl/ossl_bio.c
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_bio.c,v 1.2.2.1 2005/06/19 16:29:17 gotoyuzo Exp $
* 'OpenSSL for Ruby' team members
* Copyright (C) 2003
* All rights reserved.
@@ -19,29 +19,16 @@ ossl_obj2bio(VALUE obj)
BIO *bio;
if (TYPE(obj) == T_FILE) {
- rb_io_t *fptr;
- FILE *fp;
- int fd;
-
+ OpenFile *fptr;
GetOpenFile(obj, fptr);
rb_io_check_readable(fptr);
- if ((fd = dup(FPTR_TO_FD(fptr))) < 0){
- rb_sys_fail(0);
- }
- if (!(fp = fdopen(fd, "r"))){
- close(fd);
- rb_sys_fail(0);
- }
- if (!(bio = BIO_new_fp(fp, BIO_CLOSE))){
- fclose(fp);
- ossl_raise(eOSSLError, NULL);
- }
- }
+ bio = BIO_new_fp(fptr->f, BIO_NOCLOSE);
+ }
else {
StringValue(obj);
- bio = BIO_new_mem_buf(RSTRING_PTR(obj), RSTRING_LEN(obj));
- if (!bio) ossl_raise(eOSSLError, NULL);
+ bio = BIO_new_mem_buf(RSTRING(obj)->ptr, RSTRING(obj)->len);
}
+ if (!bio) ossl_raise(eOSSLError, NULL);
return bio;
}
diff --git a/ext/openssl/ossl_bio.h b/ext/openssl/ossl_bio.h
index 2d8f675c5b..ca312679fa 100644
--- a/ext/openssl/ossl_bio.h
+++ b/ext/openssl/ossl_bio.h
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_bio.h,v 1.2 2003/09/17 09:05:01 gotoyuzo Exp $
* '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 6856476261..fb86c8721c 100644
--- a/ext/openssl/ossl_bn.c
+++ b/ext/openssl/ossl_bn.c
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_bn.c,v 1.5.2.1 2004/12/15 01:54:39 matz Exp $
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Technorama team <oss-ruby@technorama.net>
* All rights reserved.
@@ -40,7 +40,7 @@ VALUE eBNError;
* Public
*/
VALUE
-ossl_bn_new(const BIGNUM *bn)
+ossl_bn_new(BIGNUM *bn)
{
BIGNUM *newbn;
VALUE obj;
@@ -100,13 +100,6 @@ ossl_bn_alloc(VALUE klass)
return obj;
}
-/*
- * call-seq:
- * BN.new => aBN
- * BN.new(bn) => aBN
- * BN.new(string) => aBN
- * BN.new(string, 0 | 2 | 10 | 16) => aBN
- */
static VALUE
ossl_bn_initialize(int argc, VALUE *argv, VALUE self)
{
@@ -131,22 +124,22 @@ ossl_bn_initialize(int argc, VALUE *argv, VALUE self)
switch (base) {
case 0:
- if (!BN_mpi2bn(RSTRING_PTR(str), RSTRING_LEN(str), bn)) {
+ if (!BN_mpi2bn(RSTRING(str)->ptr, RSTRING(str)->len, bn)) {
ossl_raise(eBNError, NULL);
}
break;
case 2:
- if (!BN_bin2bn(RSTRING_PTR(str), RSTRING_LEN(str), bn)) {
+ if (!BN_bin2bn(RSTRING(str)->ptr, RSTRING(str)->len, bn)) {
ossl_raise(eBNError, NULL);
}
break;
case 10:
- if (!BN_dec2bn(&bn, RSTRING_PTR(str))) {
+ if (!BN_dec2bn(&bn, RSTRING(str)->ptr)) {
ossl_raise(eBNError, NULL);
}
break;
case 16:
- if (!BN_hex2bn(&bn, RSTRING_PTR(str))) {
+ if (!BN_hex2bn(&bn, RSTRING(str)->ptr)) {
ossl_raise(eBNError, NULL);
}
break;
@@ -156,19 +149,6 @@ ossl_bn_initialize(int argc, VALUE *argv, VALUE self)
return self;
}
-/*
- * call-seq:
- * bn.to_s => string
- * bn.to_s(base) => string
- *
- * === Parameters
- * * +base+ - integer
- * * * Valid values:
- * * * * 0 - MPI
- * * * * 2 - binary
- * * * * 10 - the default
- * * * * 16 - hex
- */
static VALUE
ossl_bn_to_s(int argc, VALUE *argv, VALUE self)
{
@@ -185,13 +165,13 @@ ossl_bn_to_s(int argc, VALUE *argv, VALUE self)
case 0:
len = BN_bn2mpi(bn, NULL);
str = rb_str_new(0, len);
- if (BN_bn2mpi(bn, RSTRING_PTR(str)) != len)
+ if (BN_bn2mpi(bn, RSTRING(str)->ptr) != len)
ossl_raise(eBNError, NULL);
break;
case 2:
len = BN_num_bytes(bn);
str = rb_str_new(0, len);
- if (BN_bn2bin(bn, RSTRING_PTR(str)) != len)
+ if (BN_bn2bin(bn, RSTRING(str)->ptr) != len)
ossl_raise(eBNError, NULL);
break;
case 10:
@@ -209,10 +189,6 @@ ossl_bn_to_s(int argc, VALUE *argv, VALUE self)
return str;
}
-/*
- * call-seq:
- * bn.to_i => integer
- */
static VALUE
ossl_bn_to_i(VALUE self)
{
@@ -257,11 +233,6 @@ ossl_bn_coerce(VALUE self, VALUE other)
}
#define BIGNUM_BOOL1(func) \
- /* \
- * call-seq: \
- * bn.##func -> true | false \
- * \
- */ \
static VALUE \
ossl_bn_##func(VALUE self) \
{ \
@@ -277,11 +248,6 @@ BIGNUM_BOOL1(is_one);
BIGNUM_BOOL1(is_odd);
#define BIGNUM_1c(func) \
- /* \
- * call-seq: \
- * bn.##func -> aBN \
- * \
- */ \
static VALUE \
ossl_bn_##func(VALUE self) \
{ \
@@ -301,11 +267,6 @@ BIGNUM_BOOL1(is_odd);
BIGNUM_1c(sqr);
#define BIGNUM_2(func) \
- /* \
- * call-seq: \
- * bn.##func(bn2) -> aBN \
- * \
- */ \
static VALUE \
ossl_bn_##func(VALUE self, VALUE other) \
{ \
@@ -326,11 +287,6 @@ BIGNUM_2(add);
BIGNUM_2(sub);
#define BIGNUM_2c(func) \
- /* \
- * call-seq: \
- * bn.##func(bn2) -> aBN \
- * \
- */ \
static VALUE \
ossl_bn_##func(VALUE self, VALUE other) \
{ \
@@ -354,10 +310,6 @@ BIGNUM_2c(gcd);
BIGNUM_2c(mod_sqr);
BIGNUM_2c(mod_inverse);
-/*
- * call-seq:
- * bn1 / bn2 => [result, remainder]
- */
static VALUE
ossl_bn_div(VALUE self, VALUE other)
{
@@ -385,11 +337,6 @@ ossl_bn_div(VALUE self, VALUE other)
}
#define BIGNUM_3c(func) \
- /* \
- * call-seq: \
- * bn.##func(bn1, bn2) -> aBN \
- * \
- */ \
static VALUE \
ossl_bn_##func(VALUE self, VALUE other1, VALUE other2) \
{ \
@@ -413,11 +360,6 @@ BIGNUM_3c(mod_mul);
BIGNUM_3c(mod_exp);
#define BIGNUM_BIT(func) \
- /* \
- * call-seq: \
- * bn.##func(bit) -> self \
- * \
- */ \
static VALUE \
ossl_bn_##func(VALUE self, VALUE bit) \
{ \
@@ -432,10 +374,6 @@ BIGNUM_BIT(set_bit);
BIGNUM_BIT(clear_bit);
BIGNUM_BIT(mask_bits);
-/*
- * call-seq:
- * bn.bit_set?(bit) => true | false
- */
static VALUE
ossl_bn_is_bit_set(VALUE self, VALUE bit)
{
@@ -451,11 +389,6 @@ ossl_bn_is_bit_set(VALUE self, VALUE bit)
}
#define BIGNUM_SHIFT(func) \
- /* \
- * call-seq: \
- * bn.##func(bits) -> aBN \
- * \
- */ \
static VALUE \
ossl_bn_##func(VALUE self, VALUE bits) \
{ \
@@ -477,32 +410,7 @@ ossl_bn_is_bit_set(VALUE self, VALUE bit)
BIGNUM_SHIFT(lshift);
BIGNUM_SHIFT(rshift);
-#define BIGNUM_SELF_SHIFT(func) \
- /* \
- * call-seq: \
- * bn.##func!(bits) -> self \
- * \
- */ \
- static VALUE \
- ossl_bn_self_##func(VALUE self, VALUE bits) \
- { \
- BIGNUM *bn; \
- int b; \
- b = NUM2INT(bits); \
- GetBN(self, bn); \
- if (!BN_##func(bn, bn, b)) \
- ossl_raise(eBNError, NULL); \
- return self; \
- }
-BIGNUM_SELF_SHIFT(lshift);
-BIGNUM_SELF_SHIFT(rshift);
-
#define BIGNUM_RAND(func) \
- /* \
- * call-seq: \
- * BN.##func(bits [, fill [, odd]]) -> aBN \
- * \
- */ \
static VALUE \
ossl_bn_s_##func(int argc, VALUE *argv, VALUE klass) \
{ \
@@ -515,7 +423,7 @@ BIGNUM_SELF_SHIFT(rshift);
bottom = (odd == Qtrue) ? 1 : 0; \
/* FALLTHROUGH */ \
case 2: \
- top = NUM2INT(fill); \
+ top = FIX2INT(fill); \
} \
b = NUM2INT(bits); \
if (!(result = BN_new())) { \
@@ -532,11 +440,6 @@ BIGNUM_RAND(rand);
BIGNUM_RAND(pseudo_rand);
#define BIGNUM_RAND_RANGE(func) \
- /* \
- * call-seq: \
- * BN.##func(range) -> aBN \
- * \
- */ \
static VALUE \
ossl_bn_s_##func##_range(VALUE klass, VALUE range) \
{ \
@@ -555,16 +458,6 @@ BIGNUM_RAND(pseudo_rand);
BIGNUM_RAND_RANGE(rand);
BIGNUM_RAND_RANGE(pseudo_rand);
-/*
- * call-seq:
- * BN.generate_prime(bits, [, safe [, add [, rem]]]) => bn
- *
- * === Parameters
- * * +bits+ - integer
- * * +safe+ - boolean
- * * +add+ - BN
- * * +rem+ - BN
- */
static VALUE
ossl_bn_s_generate_prime(int argc, VALUE *argv, VALUE klass)
{
@@ -580,8 +473,12 @@ ossl_bn_s_generate_prime(int argc, VALUE *argv, VALUE klass)
safe = 0;
}
if (!NIL_P(vadd)) {
+ if (NIL_P(vrem)) {
+ ossl_raise(rb_eArgError,
+ "if ADD is specified, REM must be also given");
+ }
add = GetBNPtr(vadd);
- rem = NIL_P(vrem) ? NULL : GetBNPtr(vrem);
+ rem = GetBNPtr(vrem);
}
if (!(result = BN_new())) {
ossl_raise(eBNError, NULL);
@@ -592,15 +489,10 @@ ossl_bn_s_generate_prime(int argc, VALUE *argv, VALUE klass)
}
WrapBN(klass, obj, result);
- return obj;
+ return obj;
}
#define BIGNUM_NUM(func) \
- /* \
- * call-seq: \
- * bn.##func -> integer \
- * \
- */ \
static VALUE \
ossl_bn_##func(VALUE self) \
{ \
@@ -630,11 +522,6 @@ ossl_bn_copy(VALUE self, VALUE other)
}
#define BIGNUM_CMP(func) \
- /* \
- * call-seq: \
- * bn.##func(bn2) -> integer \
- * \
- */ \
static VALUE \
ossl_bn_##func(VALUE self, VALUE other) \
{ \
@@ -654,14 +541,6 @@ ossl_bn_eql(VALUE self, VALUE other)
return Qfalse;
}
-/*
- * call-seq:
- * bn.prime? => true | false
- * bn.prime?(checks) => true | false
- *
- * === Parameters
- * * +checks+ - integer
- */
static VALUE
ossl_bn_is_prime(int argc, VALUE *argv, VALUE self)
{
@@ -685,16 +564,6 @@ ossl_bn_is_prime(int argc, VALUE *argv, VALUE self)
return Qnil;
}
-/*
- * call-seq:
- * bn.prime_fasttest? => true | false
- * bn.prime_fasttest?(checks) => true | false
- * bn.prime_fasttest?(checks, trial_div) => true | false
- *
- * === Parameters
- * * +checks+ - integer
- * * +trial_div+ - boolean
- */
static VALUE
ossl_bn_is_prime_fasttest(int argc, VALUE *argv, VALUE self)
{
@@ -731,10 +600,6 @@ 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");
}
@@ -807,10 +672,8 @@ Init_ossl_bn()
rb_define_method(cBN, "bit_set?", ossl_bn_is_bit_set, 1);
rb_define_method(cBN, "mask_bits!", ossl_bn_mask_bits, 1);
rb_define_method(cBN, "<<", ossl_bn_lshift, 1);
- rb_define_method(cBN, ">>", ossl_bn_rshift, 1);
- rb_define_method(cBN, "lshift!", ossl_bn_self_lshift, 1);
- rb_define_method(cBN, "rshift!", ossl_bn_self_rshift, 1);
/* lshift1 - DON'T IMPL. */
+ rb_define_method(cBN, ">>", ossl_bn_rshift, 1);
/* rshift1 - DON'T IMPL. */
/*
diff --git a/ext/openssl/ossl_bn.h b/ext/openssl/ossl_bn.h
index d6c396227b..bccdbc0cd6 100644
--- a/ext/openssl/ossl_bn.h
+++ b/ext/openssl/ossl_bn.h
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_bn.h,v 1.1 2003/07/23 16:11:29 gotoyuzo Exp $
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -14,12 +14,9 @@
extern VALUE cBN;
extern VALUE eBNError;
-extern BN_CTX *ossl_bn_ctx;
-
-VALUE ossl_bn_new(const BIGNUM *);
+VALUE ossl_bn_new(BIGNUM *);
BIGNUM *GetBNPtr(VALUE);
void Init_ossl_bn(void);
-
#endif /* _OSS_BN_H_ */
diff --git a/ext/openssl/ossl_cipher.c b/ext/openssl/ossl_cipher.c
index b680dc6e64..8d96d0b35a 100644
--- a/ext/openssl/ossl_cipher.c
+++ b/ext/openssl/ossl_cipher.c
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_cipher.c,v 1.4.2.6 2006/06/20 11:18:15 gotoyuzo Exp $
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -26,6 +26,7 @@
/*
* Classes
*/
+VALUE mCipher;
VALUE cCipher;
VALUE eCipherError;
@@ -83,14 +84,6 @@ ossl_cipher_alloc(VALUE klass)
return obj;
}
-/*
- * call-seq:
- * Cipher.new(string) -> cipher
- *
- * The string must contain a valid cipher name like "AES-128-CBC" or "3DES".
- *
- * A list of cipher names is available by calling OpenSSL::Cipher.ciphers.
- */
static VALUE
ossl_cipher_initialize(VALUE self, VALUE str)
{
@@ -131,12 +124,6 @@ add_cipher_name_to_ary(const OBJ_NAME *name, VALUE ary)
return NULL;
}
-/*
- * call-seq:
- * Cipher.ciphers -> array[string...]
- *
- * Returns the names of all available ciphers in an array.
- */
static VALUE
ossl_s_ciphers(VALUE self)
{
@@ -154,12 +141,6 @@ ossl_s_ciphers(VALUE self)
#endif
}
-/*
- * call-seq:
- * cipher.reset -> self
- *
- * Internally calls EVP_CipherInit_ex(ctx, NULL, NULL, NULL, NULL, -1).
- */
static VALUE
ossl_cipher_reset(VALUE self)
{
@@ -186,23 +167,22 @@ ossl_cipher_init(int argc, VALUE *argv, VALUE self, int mode)
* We deprecated the arguments for this method, but we decided
* keeping this behaviour for backward compatibility.
*/
- char *cname = rb_class2name(rb_obj_class(self));
- rb_warn("argumtents for %s#encrypt and %s#decrypt were deprecated; "
- "use %s#pkcs5_keyivgen to derive key and IV",
- cname, cname, cname);
StringValue(pass);
GetCipher(self, ctx);
if (NIL_P(init_v)) memcpy(iv, "OpenSSL for Ruby rulez!", sizeof(iv));
else{
+ char *cname = rb_class2name(rb_obj_class(self));
+ rb_warning("key derivation by %s#encrypt is deprecated; "
+ "use %s::pkcs5_keyivgen instead", cname, cname);
StringValue(init_v);
- if (EVP_MAX_IV_LENGTH > RSTRING_LEN(init_v)) {
+ if (EVP_MAX_IV_LENGTH > RSTRING(init_v)->len) {
memset(iv, 0, EVP_MAX_IV_LENGTH);
- memcpy(iv, RSTRING_PTR(init_v), RSTRING_LEN(init_v));
+ memcpy(iv, RSTRING(init_v)->ptr, RSTRING(init_v)->len);
}
- else memcpy(iv, RSTRING_PTR(init_v), sizeof(iv));
+ else memcpy(iv, RSTRING(init_v)->ptr, sizeof(iv));
}
EVP_BytesToKey(EVP_CIPHER_CTX_cipher(ctx), EVP_md5(), iv,
- RSTRING_PTR(pass), RSTRING_LEN(pass), 1, key, NULL);
+ RSTRING(pass)->ptr, RSTRING(pass)->len, 1, key, NULL);
p_key = key;
p_iv = iv;
}
@@ -216,54 +196,18 @@ ossl_cipher_init(int argc, VALUE *argv, VALUE self, int mode)
return self;
}
-/*
- * call-seq:
- * cipher.encrypt -> self
- *
- * Make sure to call .encrypt or .decrypt before using any of the following methods:
- * * [key=, iv=, random_key, random_iv, pkcs5_keyivgen]
- *
- * Internally calls EVP_CipherInit_ex(ctx, NULL, NULL, NULL, NULL, 1).
- */
static VALUE
ossl_cipher_encrypt(int argc, VALUE *argv, VALUE self)
{
return ossl_cipher_init(argc, argv, self, 1);
}
-/*
- * call-seq:
- * cipher.decrypt -> self
- *
- * Make sure to call .encrypt or .decrypt before using any of the following methods:
- * * [key=, iv=, random_key, random_iv, pkcs5_keyivgen]
- *
- * Internally calls EVP_CipherInit_ex(ctx, NULL, NULL, NULL, NULL, 0).
- */
static VALUE
ossl_cipher_decrypt(int argc, VALUE *argv, VALUE self)
{
return ossl_cipher_init(argc, argv, self, 0);
}
-/*
- * call-seq:
- * cipher.pkcs5_keyivgen(pass [, salt [, iterations [, digest]]] ) -> nil
- *
- * Generates and sets the key/iv based on a password.
- *
- * WARNING: This method is only PKCS5 v1.5 compliant when using RC2, RC4-40, or DES
- * with MD5 or SHA1. Using anything else (like AES) will generate the key/iv using an
- * OpenSSL specific method. Use a PKCS5 v2 key generation method instead.
- *
- * === Parameters
- * +salt+ must be an 8 byte string if provided.
- * +iterations+ is a integer with a default of 2048.
- * +digest+ is a Digest object that defaults to 'MD5'
- *
- * A minimum of 1000 iterations is recommended.
- *
- */
static VALUE
ossl_cipher_pkcs5_keyivgen(int argc, VALUE *argv, VALUE self)
{
@@ -277,15 +221,15 @@ ossl_cipher_pkcs5_keyivgen(int argc, VALUE *argv, VALUE self)
StringValue(vpass);
if(!NIL_P(vsalt)){
StringValue(vsalt);
- if(RSTRING_LEN(vsalt) != PKCS5_SALT_LEN)
+ if(RSTRING(vsalt)->len != PKCS5_SALT_LEN)
rb_raise(eCipherError, "salt must be an 8-octet string");
- salt = RSTRING_PTR(vsalt);
+ salt = RSTRING(vsalt)->ptr;
}
iter = NIL_P(viter) ? 2048 : NUM2INT(viter);
digest = NIL_P(vdigest) ? EVP_md5() : GetDigestPtr(vdigest);
GetCipher(self, ctx);
EVP_BytesToKey(EVP_CIPHER_CTX_cipher(ctx), digest, salt,
- RSTRING_PTR(vpass), RSTRING_LEN(vpass), iter, key, iv);
+ RSTRING(vpass)->ptr, RSTRING(vpass)->len, iter, key, iv);
if (EVP_CipherInit_ex(ctx, NULL, NULL, key, iv, -1) != 1)
ossl_raise(eCipherError, NULL);
OPENSSL_cleanse(key, sizeof key);
@@ -294,75 +238,39 @@ ossl_cipher_pkcs5_keyivgen(int argc, VALUE *argv, VALUE self)
return Qnil;
}
-
-/*
- * call-seq:
- * cipher << data -> string
- *
- * === Parameters
- * +data+ is a nonempty string.
- *
- * This method is deprecated and not available in 1.9.x or later.
- */
-static VALUE
-ossl_cipher_update_deprecated(VALUE self, VALUE data)
-{
- char *cname;
-
- cname = rb_class2name(rb_obj_class(self));
- rb_warning("%s#<< is deprecated; use %s#update instead", cname, cname);
- return rb_funcall(self, rb_intern("update"), 1, data);
-}
-
-
-/*
- * call-seq:
- * cipher.update(data [, buffer]) -> string or buffer
- *
- * === Parameters
- * +data+ is a nonempty string.
- * +buffer+ is an optional string to store the result.
- */
static VALUE
-ossl_cipher_update(int argc, VALUE *argv, VALUE self)
+ossl_cipher_update(VALUE self, VALUE data)
{
EVP_CIPHER_CTX *ctx;
char *in;
int in_len, out_len;
- VALUE data, str;
-
- rb_scan_args(argc, argv, "11", &data, &str);
+ VALUE str;
StringValue(data);
- in = RSTRING_PTR(data);
- if ((in_len = RSTRING_LEN(data)) == 0)
+ in = RSTRING(data)->ptr;
+ if ((in_len = RSTRING(data)->len) == 0)
rb_raise(rb_eArgError, "data must not be empty");
GetCipher(self, ctx);
- out_len = in_len+EVP_CIPHER_CTX_block_size(ctx);
-
- if (NIL_P(str)) {
- str = rb_str_new(0, out_len);
- } else {
- StringValue(str);
- rb_str_resize(str, out_len);
- }
-
- if (!EVP_CipherUpdate(ctx, RSTRING_PTR(str), &out_len, in, in_len))
+ str = rb_str_new(0, in_len+EVP_CIPHER_CTX_block_size(ctx));
+ if (!EVP_CipherUpdate(ctx, RSTRING(str)->ptr, &out_len, in, in_len))
ossl_raise(eCipherError, NULL);
- assert(out_len < RSTRING_LEN(str));
- rb_str_set_len(str, out_len);
+ assert(out_len < RSTRING(str)->len);
+ RSTRING(str)->len = out_len;
+ RSTRING(str)->ptr[out_len] = 0;
return str;
}
-/*
- * call-seq:
- * cipher.final -> aString
- *
- * Returns the remaining data held in the cipher object. Further calls to update() or final() will return garbage.
- *
- * See EVP_CipherFinal_ex for further information.
- */
+static VALUE
+ossl_cipher_update_deprecated(VALUE self, VALUE data)
+{
+ char *cname;
+
+ cname = rb_class2name(rb_obj_class(self));
+ rb_warning("%s#<< is deprecated; use %s#update instead", cname, cname);
+ return ossl_cipher_update(self, data);
+}
+
static VALUE
ossl_cipher_final(VALUE self)
{
@@ -372,20 +280,15 @@ ossl_cipher_final(VALUE self)
GetCipher(self, ctx);
str = rb_str_new(0, EVP_CIPHER_CTX_block_size(ctx));
- if (!EVP_CipherFinal_ex(ctx, RSTRING_PTR(str), &out_len))
+ if (!EVP_CipherFinal_ex(ctx, RSTRING(str)->ptr, &out_len))
ossl_raise(eCipherError, NULL);
- assert(out_len <= RSTRING_LEN(str));
- rb_str_set_len(str, out_len);
+ assert(out_len <= RSTRING(str)->len);
+ RSTRING(str)->len = out_len;
+ RSTRING(str)->ptr[out_len] = 0;
return str;
}
-/*
- * call-seq:
- * cipher.name -> string
- *
- * Returns the name of the cipher which may differ slightly from the original name provided.
- */
static VALUE
ossl_cipher_name(VALUE self)
{
@@ -396,14 +299,6 @@ ossl_cipher_name(VALUE self)
return rb_str_new2(EVP_CIPHER_name(EVP_CIPHER_CTX_cipher(ctx)));
}
-/*
- * call-seq:
- * cipher.key = string -> string
- *
- * Sets the cipher key.
- *
- * Only call this method after calling cipher.encrypt or cipher.decrypt.
- */
static VALUE
ossl_cipher_set_key(VALUE self, VALUE key)
{
@@ -412,23 +307,15 @@ ossl_cipher_set_key(VALUE self, VALUE key)
StringValue(key);
GetCipher(self, ctx);
- if (RSTRING_LEN(key) < EVP_CIPHER_CTX_key_length(ctx))
+ if (RSTRING(key)->len < EVP_CIPHER_CTX_key_length(ctx))
ossl_raise(eCipherError, "key length too short");
- if (EVP_CipherInit_ex(ctx, NULL, NULL, RSTRING_PTR(key), NULL, -1) != 1)
+ if (EVP_CipherInit_ex(ctx, NULL, NULL, RSTRING(key)->ptr, NULL, -1) != 1)
ossl_raise(eCipherError, NULL);
return key;
}
-/*
- * call-seq:
- * cipher.iv = string -> string
- *
- * Sets the cipher iv.
- *
- * Only call this method after calling cipher.encrypt or cipher.decrypt.
- */
static VALUE
ossl_cipher_set_iv(VALUE self, VALUE iv)
{
@@ -437,32 +324,20 @@ ossl_cipher_set_iv(VALUE self, VALUE iv)
StringValue(iv);
GetCipher(self, ctx);
- if (RSTRING_LEN(iv) < EVP_CIPHER_CTX_iv_length(ctx))
+ if (RSTRING(iv)->len < EVP_CIPHER_CTX_iv_length(ctx))
ossl_raise(eCipherError, "iv length too short");
- if (EVP_CipherInit_ex(ctx, NULL, NULL, NULL, RSTRING_PTR(iv), -1) != 1)
+ if (EVP_CipherInit_ex(ctx, NULL, NULL, NULL, RSTRING(iv)->ptr, -1) != 1)
ossl_raise(eCipherError, NULL);
return iv;
}
-
-/*
- * call-seq:
- * cipher.key_length = integer -> integer
- *
- * Sets the key length of the cipher. If the cipher is a fixed length cipher then attempting to set the key
- * length to any value other than the fixed value is an error.
- *
- * Under normal circumstances you do not need to call this method (and probably shouldn't).
- *
- * See EVP_CIPHER_CTX_set_key_length for further information.
- */
static VALUE
ossl_cipher_set_key_length(VALUE self, VALUE key_length)
{
- int len = NUM2INT(key_length);
EVP_CIPHER_CTX *ctx;
+ int len = NUM2INT(key_length);
GetCipher(self, ctx);
if (EVP_CIPHER_CTX_set_key_length(ctx, len) != 1)
@@ -471,16 +346,6 @@ ossl_cipher_set_key_length(VALUE self, VALUE key_length)
return key_length;
}
-/*
- * call-seq:
- * cipher.padding = integer -> integer
- *
- * Enables or disables padding. By default encryption operations are padded using standard block padding and the
- * padding is checked and removed when decrypting. If the pad parameter is zero then no padding is performed, the
- * total amount of data encrypted or decrypted must then be a multiple of the block size or an error will occur.
- *
- * See EVP_CIPHER_CTX_set_padding for further information.
- */
static VALUE
ossl_cipher_set_padding(VALUE self, VALUE padding)
{
@@ -509,51 +374,26 @@ CIPHER_0ARG_INT(key_length)
CIPHER_0ARG_INT(iv_length)
CIPHER_0ARG_INT(block_size)
-#if 0
-/*
- * call-seq:
- * cipher.key_length -> integer
- *
- */
-static VALUE ossl_cipher_key_length() { }
-/*
- * call-seq:
- * cipher.iv_length -> integer
- *
- */
-static VALUE ossl_cipher_iv_length() { }
-/*
- * call-seq:
- * cipher.block_size -> integer
- *
- */
-static VALUE ossl_cipher_block_size() { }
-#endif
-
/*
* INIT
*/
void
Init_ossl_cipher(void)
{
-#if 0 /* let rdoc know about mOSSL */
- mOSSL = rb_define_module("OpenSSL");
-#endif
- cCipher = rb_define_class_under(mOSSL, "Cipher", rb_cObject);
- eCipherError = rb_define_class_under(cCipher, "CipherError", eOSSLError);
+ mCipher = rb_define_module_under(mOSSL, "Cipher");
+ eCipherError = rb_define_class_under(mOSSL, "CipherError", eOSSLError);
+ cCipher = rb_define_class_under(mCipher, "Cipher", rb_cObject);
rb_define_alloc_func(cCipher, ossl_cipher_alloc);
rb_define_copy_func(cCipher, ossl_cipher_copy);
- rb_define_module_function(cCipher, "ciphers", ossl_s_ciphers, 0);
+ rb_define_module_function(mCipher, "ciphers", ossl_s_ciphers, 0);
rb_define_method(cCipher, "initialize", ossl_cipher_initialize, 1);
rb_define_method(cCipher, "reset", ossl_cipher_reset, 0);
rb_define_method(cCipher, "encrypt", ossl_cipher_encrypt, -1);
rb_define_method(cCipher, "decrypt", ossl_cipher_decrypt, -1);
rb_define_method(cCipher, "pkcs5_keyivgen", ossl_cipher_pkcs5_keyivgen, -1);
- rb_define_method(cCipher, "update", ossl_cipher_update, -1);
-#if RUBY_VERSION_CODE < 190
+ rb_define_method(cCipher, "update", ossl_cipher_update, 1);
rb_define_method(cCipher, "<<", ossl_cipher_update_deprecated, 1);
-#endif
rb_define_method(cCipher, "final", ossl_cipher_final, 0);
rb_define_method(cCipher, "name", ossl_cipher_name, 0);
rb_define_method(cCipher, "key=", ossl_cipher_set_key, 1);
@@ -564,4 +404,3 @@ Init_ossl_cipher(void)
rb_define_method(cCipher, "block_size", ossl_cipher_block_size, 0);
rb_define_method(cCipher, "padding=", ossl_cipher_set_padding, 1);
}
-
diff --git a/ext/openssl/ossl_cipher.h b/ext/openssl/ossl_cipher.h
index bed4fa853b..870927c37c 100644
--- a/ext/openssl/ossl_cipher.h
+++ b/ext/openssl/ossl_cipher.h
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_cipher.h,v 1.2 2003/09/05 09:08:40 gotoyuzo Exp $
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -11,6 +11,7 @@
#if !defined(_OSSL_CIPHER_H_)
#define _OSSL_CIPHER_H_
+extern VALUE mCipher;
extern VALUE cCipher;
extern VALUE eCipherError;
diff --git a/ext/openssl/ossl_config.c b/ext/openssl/ossl_config.c
index cc8e324029..64998bb86a 100644
--- a/ext/openssl/ossl_config.c
+++ b/ext/openssl/ossl_config.c
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_config.c,v 1.8.2.3 2004/12/15 01:54:39 matz Exp $
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -171,16 +171,16 @@ ossl_config_add_value(VALUE self, VALUE section, VALUE name, VALUE value)
StringValue(name);
StringValue(value);
GetConfig(self, conf);
- if(!(sv = _CONF_get_section(conf, RSTRING_PTR(section)))){
- if(!(sv = _CONF_new_section(conf, RSTRING_PTR(section)))){
+ if(!(sv = _CONF_get_section(conf, RSTRING(section)->ptr))){
+ if(!(sv = _CONF_new_section(conf, RSTRING(section)->ptr))){
ossl_raise(eConfigError, NULL);
}
}
if(!(cv = OPENSSL_malloc(sizeof(CONF_VALUE)))){
ossl_raise(eConfigError, NULL);
}
- cv->name = BUF_strdup(RSTRING_PTR(name));
- cv->value = BUF_strdup(RSTRING_PTR(value));
+ cv->name = BUF_strdup(RSTRING(name)->ptr);
+ cv->value = BUF_strdup(RSTRING(value)->ptr);
if(!cv->name || !cv->value || !_CONF_add_string(conf, sv, cv)){
OPENSSL_free(cv->name);
OPENSSL_free(cv->value);
@@ -201,7 +201,7 @@ ossl_config_get_value(VALUE self, VALUE section, VALUE name)
StringValue(section);
StringValue(name);
GetConfig(self, conf);
- str = NCONF_get_string(conf, RSTRING_PTR(section), RSTRING_PTR(name));
+ str = NCONF_get_string(conf, RSTRING(section)->ptr, RSTRING(name)->ptr);
if(!str){
ERR_clear_error();
return Qnil;
@@ -249,7 +249,7 @@ ossl_config_set_section(VALUE self, VALUE section, VALUE hash)
arg[0] = self;
arg[1] = section;
- rb_block_call(hash, rb_intern("each"), 0, 0, set_conf_section_i, (VALUE)arg);
+ 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 cb226b27e5..452d430b5e 100644
--- a/ext/openssl/ossl_config.h
+++ b/ext/openssl/ossl_config.h
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_config.h,v 1.2 2003/09/08 10:31:38 gotoyuzo Exp $
* '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 879d399fe7..8b9c273f4d 100644
--- a/ext/openssl/ossl_digest.c
+++ b/ext/openssl/ossl_digest.c
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_digest.c,v 1.4.2.2 2004/12/15 01:54:39 matz Exp $
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -24,6 +24,7 @@
/*
* Classes
*/
+VALUE mDigest;
VALUE cDigest;
VALUE eDigestError;
@@ -35,23 +36,11 @@ static VALUE ossl_digest_alloc(VALUE klass);
const EVP_MD *
GetDigestPtr(VALUE obj)
{
- const EVP_MD *md;
-
- if (TYPE(obj) == T_STRING) {
- const char *name = STR2CSTR(obj);
-
- md = EVP_get_digestbyname(name);
- if (!md)
- ossl_raise(rb_eRuntimeError, "Unsupported digest algorithm (%s).", name);
- } else {
- EVP_MD_CTX *ctx;
-
- SafeGetDigest(obj, ctx);
+ EVP_MD_CTX *ctx;
- md = EVP_MD_CTX_md(ctx);
- }
+ SafeGetDigest(obj, ctx);
- return md;
+ return EVP_MD_CTX_md(ctx); /*== ctx->digest*/
}
VALUE
@@ -62,6 +51,7 @@ ossl_digest_new(const EVP_MD *md)
ret = ossl_digest_alloc(cDigest);
GetDigest(ret, ctx);
+ EVP_MD_CTX_init(ctx);
EVP_DigestInit_ex(ctx, md, NULL);
return ret;
@@ -79,18 +69,14 @@ ossl_digest_alloc(VALUE klass)
ctx = EVP_MD_CTX_create();
if (ctx == NULL)
ossl_raise(rb_eRuntimeError, "EVP_MD_CTX_create() failed");
+ EVP_MD_CTX_init(ctx);
obj = Data_Wrap_Struct(klass, 0, EVP_MD_CTX_destroy, ctx);
-
+
return obj;
}
VALUE ossl_digest_update(VALUE, VALUE);
-/*
- * call-seq:
- * Digest.new(string) -> digest
- *
- */
static VALUE
ossl_digest_initialize(int argc, VALUE *argv, VALUE self)
{
@@ -100,9 +86,14 @@ ossl_digest_initialize(int argc, VALUE *argv, VALUE self)
VALUE type, data;
rb_scan_args(argc, argv, "11", &type, &data);
- md = GetDigestPtr(type);
+ StringValue(type);
if (!NIL_P(data)) StringValue(data);
-
+ name = StringValuePtr(type);
+
+ md = EVP_get_digestbyname(name);
+ if (!md) {
+ ossl_raise(rb_eRuntimeError, "Unsupported digest algorithm (%s).", name);
+ }
GetDigest(self, ctx);
EVP_DigestInit_ex(ctx, md, NULL);
@@ -127,11 +118,6 @@ ossl_digest_copy(VALUE self, VALUE other)
return self;
}
-/*
- * call-seq:
- * digest.reset -> self
- *
- */
static VALUE
ossl_digest_reset(VALUE self)
{
@@ -143,11 +129,6 @@ ossl_digest_reset(VALUE self)
return self;
}
-/*
- * call-seq:
- * digest.update(string) -> aString
- *
- */
VALUE
ossl_digest_update(VALUE self, VALUE data)
{
@@ -155,77 +136,126 @@ ossl_digest_update(VALUE self, VALUE data)
StringValue(data);
GetDigest(self, ctx);
- EVP_DigestUpdate(ctx, RSTRING_PTR(data), RSTRING_LEN(data));
+ EVP_DigestUpdate(ctx, RSTRING(data)->ptr, RSTRING(data)->len);
return self;
}
-/*
- * call-seq:
- * digest.finish -> aString
- *
- */
+static void
+digest_final(EVP_MD_CTX *ctx, char **buf, int *buf_len)
+{
+ EVP_MD_CTX final;
+
+ if (!EVP_MD_CTX_copy(&final, ctx)) {
+ ossl_raise(eDigestError, NULL);
+ }
+ if (!(*buf = OPENSSL_malloc(EVP_MD_CTX_size(&final)))) {
+ EVP_MD_CTX_cleanup(&final);
+ ossl_raise(eDigestError, "Cannot allocate mem for digest");
+ }
+ EVP_DigestFinal_ex(&final, *buf, buf_len);
+ EVP_MD_CTX_cleanup(&final);
+}
+
static VALUE
-ossl_digest_finish(int argc, VALUE *argv, VALUE self)
+ossl_digest_digest(VALUE self)
{
EVP_MD_CTX *ctx;
- VALUE str;
+ char *buf;
+ int buf_len;
+ VALUE digest;
+
+ GetDigest(self, ctx);
+ digest_final(ctx, &buf, &buf_len);
+ digest = ossl_buf2str(buf, buf_len);
+
+ return digest;
+}
- rb_scan_args(argc, argv, "01", &str);
+static VALUE
+ossl_digest_hexdigest(VALUE self)
+{
+ EVP_MD_CTX *ctx;
+ char *buf, *hexbuf;
+ int buf_len;
+ VALUE hexdigest;
GetDigest(self, ctx);
-
- if (NIL_P(str)) {
- str = rb_str_new(NULL, EVP_MD_CTX_size(ctx));
- } else {
- StringValue(str);
- rb_str_resize(str, EVP_MD_CTX_size(ctx));
+ digest_final(ctx, &buf, &buf_len);
+ if (string2hex(buf, buf_len, &hexbuf, NULL) != 2 * buf_len) {
+ OPENSSL_free(buf);
+ ossl_raise(eDigestError, "Memory alloc error");
}
+ OPENSSL_free(buf);
+ hexdigest = ossl_buf2str(hexbuf, 2 * buf_len);
+
+ return hexdigest;
+}
+
+static VALUE
+ossl_digest_s_digest(VALUE klass, VALUE str, VALUE data)
+{
+ VALUE obj = rb_class_new_instance(1, &str, klass);
- EVP_DigestFinal_ex(ctx, RSTRING_PTR(str), NULL);
+ ossl_digest_update(obj, data);
- return str;
+ return ossl_digest_digest(obj);
}
-/*
- * call-seq:
- * digest.name -> string
- *
- */
static VALUE
-ossl_digest_name(VALUE self)
+ossl_digest_s_hexdigest(VALUE klass, VALUE str, VALUE data)
+{
+ VALUE obj = rb_class_new_instance(1, &str, klass);
+
+ ossl_digest_update(obj, data);
+
+ return ossl_digest_hexdigest(obj);
+}
+
+static VALUE
+ossl_digest_equal(VALUE self, VALUE other)
{
EVP_MD_CTX *ctx;
+ VALUE str1, str2;
+ if (rb_obj_is_kind_of(other, cDigest) == Qtrue) {
+ str2 = ossl_digest_digest(other);
+ } else {
+ StringValue(other);
+ str2 = other;
+ }
GetDigest(self, ctx);
+ if (RSTRING(str2)->len == EVP_MD_CTX_size(ctx)) {
+ str1 = ossl_digest_digest(self);
+ } else {
+ str1 = ossl_digest_hexdigest(self);
+ }
+ if (RSTRING(str1)->len == RSTRING(str2)->len
+ && rb_str_cmp(str1, str2) == 0) {
+ return Qtrue;
+ }
- return rb_str_new2(EVP_MD_name(EVP_MD_CTX_md(ctx)));
+ return Qfalse;
}
-/*
- * call-seq:
- * digest.digest_size -> integer
- *
- * Returns the output size of the digest.
- */
static VALUE
-ossl_digest_size(VALUE self)
+ossl_digest_name(VALUE self)
{
EVP_MD_CTX *ctx;
GetDigest(self, ctx);
- return INT2NUM(EVP_MD_CTX_size(ctx));
+ return rb_str_new2(EVP_MD_name(EVP_MD_CTX_md(ctx)));
}
static VALUE
-ossl_digest_block_length(VALUE self)
+ossl_digest_size(VALUE self)
{
EVP_MD_CTX *ctx;
GetDigest(self, ctx);
- return INT2NUM(EVP_MD_CTX_block_size(ctx));
+ return INT2NUM(EVP_MD_CTX_size(ctx));
}
/*
@@ -234,26 +264,31 @@ ossl_digest_block_length(VALUE self)
void
Init_ossl_digest()
{
- rb_require("openssl");
- rb_require("digest");
-
-#if 0 /* let rdoc know about mOSSL */
- mOSSL = rb_define_module("OpenSSL");
-#endif
-
- cDigest = rb_define_class_under(mOSSL, "Digest", rb_path2class("Digest::Class"));
- eDigestError = rb_define_class_under(cDigest, "DigestError", eOSSLError);
+ mDigest = rb_define_module_under(mOSSL, "Digest");
+
+ eDigestError = rb_define_class_under(mDigest, "DigestError", eOSSLError);
+
+ cDigest = rb_define_class_under(mDigest, "Digest", rb_cObject);
rb_define_alloc_func(cDigest, ossl_digest_alloc);
-
+ rb_define_singleton_method(cDigest, "digest", ossl_digest_s_digest, 2);
+ rb_define_singleton_method(cDigest, "hexdigest", ossl_digest_s_hexdigest, 2);
+
rb_define_method(cDigest, "initialize", ossl_digest_initialize, -1);
- rb_define_copy_func(cDigest, ossl_digest_copy);
rb_define_method(cDigest, "reset", ossl_digest_reset, 0);
+
+ rb_define_copy_func(cDigest, ossl_digest_copy);
+
+ rb_define_method(cDigest, "digest", ossl_digest_digest, 0);
+ rb_define_method(cDigest, "hexdigest", ossl_digest_hexdigest, 0);
+ rb_define_alias(cDigest, "inspect", "hexdigest");
+ rb_define_alias(cDigest, "to_s", "hexdigest");
+
rb_define_method(cDigest, "update", ossl_digest_update, 1);
rb_define_alias(cDigest, "<<", "update");
- rb_define_private_method(cDigest, "finish", ossl_digest_finish, -1);
- rb_define_method(cDigest, "digest_length", ossl_digest_size, 0);
- rb_define_method(cDigest, "block_length", ossl_digest_block_length, 0);
-
+
+ rb_define_method(cDigest, "==", ossl_digest_equal, 1);
+
rb_define_method(cDigest, "name", ossl_digest_name, 0);
+ rb_define_method(cDigest, "size", ossl_digest_size, 0);
}
diff --git a/ext/openssl/ossl_digest.h b/ext/openssl/ossl_digest.h
index 8cc5b1bc56..b35bd217b3 100644
--- a/ext/openssl/ossl_digest.h
+++ b/ext/openssl/ossl_digest.h
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_digest.h,v 1.2 2003/09/05 09:08:40 gotoyuzo Exp $
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -11,6 +11,7 @@
#if !defined(_OSSL_DIGEST_H_)
#define _OSSL_DIGEST_H_
+extern VALUE mDigest;
extern VALUE cDigest;
extern VALUE eDigestError;
diff --git a/ext/openssl/ossl_engine.c b/ext/openssl/ossl_engine.c
index cd835d1237..6cc0183c0e 100644
--- a/ext/openssl/ossl_engine.c
+++ b/ext/openssl/ossl_engine.c
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_engine.c,v 1.4.2.6 2005/09/18 22:56:11 gotoyuzo Exp $
* 'OpenSSL for Ruby' project
* Copyright (C) 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
* All rights reserved.
@@ -40,7 +40,7 @@ VALUE eEngineError;
*/
#define OSSL_ENGINE_LOAD_IF_MATCH(x) \
do{\
- if(!strcmp(#x, RSTRING_PTR(name))){\
+ if(!strcmp(#x, RSTRING(name)->ptr)){\
ENGINE_load_##x();\
return Qtrue;\
}\
@@ -75,7 +75,7 @@ ossl_engine_s_load(int argc, VALUE *argv, VALUE klass)
OSSL_ENGINE_LOAD_IF_MATCH(openbsd_dev_crypto);
#endif
OSSL_ENGINE_LOAD_IF_MATCH(openssl);
- rb_warning("no such builtin loader for `%s'", RSTRING_PTR(name));
+ rb_warning("no such builtin loader for `%s'", RSTRING(name)->ptr);
return Qnil;
#endif /* HAVE_ENGINE_LOAD_BUILTIN_ENGINES */
}
@@ -112,7 +112,7 @@ ossl_engine_s_by_id(VALUE klass, VALUE id)
StringValue(id);
ossl_engine_s_load(1, &id, klass);
- if(!(e = ENGINE_by_id(RSTRING_PTR(id))))
+ if(!(e = ENGINE_by_id(RSTRING(id)->ptr)))
ossl_raise(eEngineError, NULL);
WrapEngine(klass, obj, e);
if(rb_block_given_p()) rb_yield(obj);
@@ -281,8 +281,8 @@ ossl_engine_ctrl_cmd(int argc, VALUE *argv, VALUE self)
rb_scan_args(argc, argv, "11", &cmd, &val);
StringValue(cmd);
if (!NIL_P(val)) StringValue(val);
- ret = ENGINE_ctrl_cmd_string(e, RSTRING_PTR(cmd),
- NIL_P(val) ? NULL : RSTRING_PTR(val), 0);
+ ret = ENGINE_ctrl_cmd_string(e, RSTRING(cmd)->ptr,
+ NIL_P(val) ? NULL : RSTRING(val)->ptr, 0);
if (!ret) ossl_raise(eEngineError, NULL);
return self;
diff --git a/ext/openssl/ossl_engine.h b/ext/openssl/ossl_engine.h
index ea2f256912..ccc426481a 100644
--- a/ext/openssl/ossl_engine.h
+++ b/ext/openssl/ossl_engine.h
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_engine.h,v 1.1 2003/10/02 08:47:11 gotoyuzo Exp $
* '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 ef77d6c427..cd66ab6e2c 100644
--- a/ext/openssl/ossl_hmac.c
+++ b/ext/openssl/ossl_hmac.c
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_hmac.c,v 1.4.2.2 2004/12/15 01:54:39 matz Exp $
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -57,12 +57,6 @@ ossl_hmac_alloc(VALUE klass)
return obj;
}
-
-/*
- * call-seq:
- * HMAC.new(key, digest) -> hmac
- *
- */
static VALUE
ossl_hmac_initialize(VALUE self, VALUE key, VALUE digest)
{
@@ -70,7 +64,7 @@ ossl_hmac_initialize(VALUE self, VALUE key, VALUE digest)
StringValue(key);
GetHMAC(self, ctx);
- HMAC_Init_ex(ctx, RSTRING_PTR(key), RSTRING_LEN(key),
+ HMAC_Init_ex(ctx, RSTRING(key)->ptr, RSTRING(key)->len,
GetDigestPtr(digest), NULL);
return self;
@@ -87,15 +81,12 @@ ossl_hmac_copy(VALUE self, VALUE other)
GetHMAC(self, ctx1);
SafeGetHMAC(other, ctx2);
- HMAC_CTX_copy(ctx1, ctx2);
+ if (!HMAC_CTX_copy(ctx1, ctx2)) {
+ ossl_raise(eHMACError, NULL);
+ }
return self;
}
-/*
- * call-seq:
- * hmac.update(string) -> self
- *
- */
static VALUE
ossl_hmac_update(VALUE self, VALUE data)
{
@@ -103,7 +94,7 @@ ossl_hmac_update(VALUE self, VALUE data)
StringValue(data);
GetHMAC(self, ctx);
- HMAC_Update(ctx, RSTRING_PTR(data), RSTRING_LEN(data));
+ HMAC_Update(ctx, RSTRING(data)->ptr, RSTRING(data)->len);
return self;
}
@@ -113,7 +104,9 @@ hmac_final(HMAC_CTX *ctx, char **buf, int *buf_len)
{
HMAC_CTX final;
- HMAC_CTX_copy(&final, ctx);
+ if (!HMAC_CTX_copy(&final, ctx)) {
+ ossl_raise(eHMACError, NULL);
+ }
if (!(*buf = OPENSSL_malloc(HMAC_size(&final)))) {
HMAC_CTX_cleanup(&final);
OSSL_Debug("Allocating %d mem", HMAC_size(&final));
@@ -123,11 +116,6 @@ hmac_final(HMAC_CTX *ctx, char **buf, int *buf_len)
HMAC_CTX_cleanup(&final);
}
-/*
- * call-seq:
- * hmac.digest -> aString
- *
- */
static VALUE
ossl_hmac_digest(VALUE self)
{
@@ -143,11 +131,6 @@ ossl_hmac_digest(VALUE self)
return digest;
}
-/*
- * call-seq:
- * hmac.hexdigest -> aString
- *
- */
static VALUE
ossl_hmac_hexdigest(VALUE self)
{
@@ -168,27 +151,6 @@ ossl_hmac_hexdigest(VALUE self)
return hexdigest;
}
-/*
- * call-seq:
- * hmac.reset -> self
- *
- */
-static VALUE
-ossl_hmac_reset(VALUE self)
-{
- HMAC_CTX *ctx;
-
- GetHMAC(self, ctx);
- HMAC_Init_ex(ctx, NULL, 0, NULL, NULL);
-
- return self;
-}
-
-/*
- * call-seq:
- * HMAC.digest(digest, key, data) -> aString
- *
- */
static VALUE
ossl_hmac_s_digest(VALUE klass, VALUE digest, VALUE key, VALUE data)
{
@@ -197,17 +159,12 @@ ossl_hmac_s_digest(VALUE klass, VALUE digest, VALUE key, VALUE data)
StringValue(key);
StringValue(data);
- buf = HMAC(GetDigestPtr(digest), RSTRING_PTR(key), RSTRING_LEN(key),
- RSTRING_PTR(data), RSTRING_LEN(data), NULL, &buf_len);
+ buf = HMAC(GetDigestPtr(digest), RSTRING(key)->ptr, RSTRING(key)->len,
+ RSTRING(data)->ptr, RSTRING(data)->len, NULL, &buf_len);
return rb_str_new(buf, buf_len);
}
-/*
- * call-seq:
- * HMAC.digest(digest, key, data) -> aString
- *
- */
static VALUE
ossl_hmac_s_hexdigest(VALUE klass, VALUE digest, VALUE key, VALUE data)
{
@@ -218,8 +175,8 @@ ossl_hmac_s_hexdigest(VALUE klass, VALUE digest, VALUE key, VALUE data)
StringValue(key);
StringValue(data);
- buf = HMAC(GetDigestPtr(digest), RSTRING_PTR(key), RSTRING_LEN(key),
- RSTRING_PTR(data), RSTRING_LEN(data), NULL, &buf_len);
+ buf = HMAC(GetDigestPtr(digest), RSTRING(key)->ptr, RSTRING(key)->len,
+ RSTRING(data)->ptr, RSTRING(data)->len, NULL, &buf_len);
if (string2hex(buf, buf_len, &hexbuf, NULL) != 2 * buf_len) {
ossl_raise(eHMACError, "Cannot convert buf to hexbuf");
}
@@ -234,10 +191,6 @@ 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);
@@ -249,7 +202,6 @@ Init_ossl_hmac()
rb_define_method(cHMAC, "initialize", ossl_hmac_initialize, 2);
rb_define_copy_func(cHMAC, ossl_hmac_copy);
- rb_define_method(cHMAC, "reset", ossl_hmac_reset, 0);
rb_define_method(cHMAC, "update", ossl_hmac_update, 1);
rb_define_alias(cHMAC, "<<", "update");
rb_define_method(cHMAC, "digest", ossl_hmac_digest, 0);
diff --git a/ext/openssl/ossl_hmac.h b/ext/openssl/ossl_hmac.h
index 1a2978b39a..2c8d69c177 100644
--- a/ext/openssl/ossl_hmac.h
+++ b/ext/openssl/ossl_hmac.h
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_hmac.h,v 1.1 2003/07/23 16:11:29 gotoyuzo Exp $
* '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 738a203d93..bd8c59faf9 100644
--- a/ext/openssl/ossl_ns_spki.c
+++ b/ext/openssl/ossl_ns_spki.c
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_ns_spki.c,v 1.3.2.5 2006/03/17 10:10:53 gotoyuzo Exp $
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -62,15 +62,14 @@ ossl_spki_initialize(int argc, VALUE *argv, VALUE self)
return self;
}
StringValue(buffer);
- if (!(spki = NETSCAPE_SPKI_b64_decode(RSTRING_PTR(buffer), -1))) {
- p = RSTRING_PTR(buffer);
- if (!(spki = d2i_NETSCAPE_SPKI(NULL, &p, RSTRING_LEN(buffer)))) {
+ if (!(spki = NETSCAPE_SPKI_b64_decode(RSTRING(buffer)->ptr, -1))) {
+ p = RSTRING(buffer)->ptr;
+ if (!(spki = d2i_NETSCAPE_SPKI(NULL, &p, RSTRING(buffer)->len))) {
ossl_raise(eSPKIError, NULL);
}
}
NETSCAPE_SPKI_free(DATA_PTR(self));
DATA_PTR(self) = spki;
- ERR_clear_error();
return self;
}
@@ -87,7 +86,7 @@ ossl_spki_to_der(VALUE self)
if ((len = i2d_NETSCAPE_SPKI(spki, NULL)) <= 0)
ossl_raise(eX509CertError, NULL);
str = rb_str_new(0, len);
- p = RSTRING_PTR(str);
+ p = RSTRING(str)->ptr;
if (i2d_NETSCAPE_SPKI(spki, &p) <= 0)
ossl_raise(eX509CertError, NULL);
ossl_str_adjust(str, p);
@@ -183,8 +182,8 @@ ossl_spki_set_challenge(VALUE self, VALUE str)
StringValue(str);
GetSPKI(self, spki);
- if (!ASN1_STRING_set(spki->spkac->challenge, RSTRING_PTR(str),
- RSTRING_LEN(str))) {
+ if (!ASN1_STRING_set(spki->spkac->challenge, RSTRING(str)->ptr,
+ RSTRING(str)->len)) {
ossl_raise(eSPKIError, NULL);
}
diff --git a/ext/openssl/ossl_ns_spki.h b/ext/openssl/ossl_ns_spki.h
index 9977035a9c..2ca1fdcd62 100644
--- a/ext/openssl/ossl_ns_spki.h
+++ b/ext/openssl/ossl_ns_spki.h
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_ns_spki.h,v 1.1 2003/07/23 16:11:29 gotoyuzo Exp $
* '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 1e8e5903bd..f2097b967e 100644
--- a/ext/openssl/ossl_ocsp.c
+++ b/ext/openssl/ossl_ocsp.c
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_ocsp.c,v 1.4.2.2 2005/01/22 20:28:02 gotoyuzo Exp $
* 'OpenSSL for Ruby' project
* Copyright (C) 2003 Michal Rokos <m.rokos@sh.cvut.cz>
* Copyright (C) 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
@@ -109,9 +109,9 @@ ossl_ocspreq_initialize(int argc, VALUE *argv, VALUE self)
if(!NIL_P(arg)){
arg = ossl_to_der_if_possible(arg);
StringValue(arg);
- p = (unsigned char*)RSTRING_PTR(arg);
+ p = (unsigned char*)RSTRING(arg)->ptr;
if(!d2i_OCSP_REQUEST((OCSP_REQUEST**)&DATA_PTR(self), &p,
- RSTRING_LEN(arg))){
+ RSTRING(arg)->len)){
ossl_raise(eOCSPError, "cannot load DER encoded request");
}
}
@@ -134,7 +134,7 @@ ossl_ocspreq_add_nonce(int argc, VALUE *argv, VALUE self)
else{
StringValue(val);
GetOCSPReq(self, req);
- ret = OCSP_request_add1_nonce(req, RSTRING_PTR(val), RSTRING_LEN(val));
+ ret = OCSP_request_add1_nonce(req, RSTRING(val)->ptr, RSTRING(val)->len);
}
if(!ret) ossl_raise(eOCSPError, NULL);
@@ -265,7 +265,7 @@ ossl_ocspreq_to_der(VALUE self)
if((len = i2d_OCSP_REQUEST(req, NULL)) <= 0)
ossl_raise(eOCSPError, NULL);
str = rb_str_new(0, len);
- p = RSTRING_PTR(str);
+ p = RSTRING(str)->ptr;
if(i2d_OCSP_REQUEST(req, &p) <= 0)
ossl_raise(eOCSPError, NULL);
ossl_str_adjust(str, p);
@@ -316,9 +316,9 @@ ossl_ocspres_initialize(int argc, VALUE *argv, VALUE self)
if(!NIL_P(arg)){
arg = ossl_to_der_if_possible(arg);
StringValue(arg);
- p = RSTRING_PTR(arg);
+ p = RSTRING(arg)->ptr;
if(!d2i_OCSP_RESPONSE((OCSP_RESPONSE**)&DATA_PTR(self), &p,
- RSTRING_LEN(arg))){
+ RSTRING(arg)->len)){
ossl_raise(eOCSPError, "cannot load DER encoded response");
}
}
@@ -377,7 +377,7 @@ ossl_ocspres_to_der(VALUE self)
if((len = i2d_OCSP_RESPONSE(res, NULL)) <= 0)
ossl_raise(eOCSPError, NULL);
str = rb_str_new(0, len);
- p = RSTRING_PTR(str);
+ p = RSTRING(str)->ptr;
if(i2d_OCSP_RESPONSE(res, NULL) <= 0)
ossl_raise(eOCSPError, NULL);
ossl_str_adjust(str, p);
@@ -436,7 +436,7 @@ ossl_ocspbres_add_nonce(int argc, VALUE *argv, VALUE self)
else{
StringValue(val);
GetOCSPBasicRes(self, bs);
- ret = OCSP_basic_add1_nonce(bs, RSTRING_PTR(val), RSTRING_LEN(val));
+ ret = OCSP_basic_add1_nonce(bs, RSTRING(val)->ptr, RSTRING(val)->len);
}
if(!ret) ossl_raise(eOCSPError, NULL);
@@ -461,8 +461,8 @@ ossl_ocspbres_add_status(VALUE self, VALUE cid, VALUE status,
if(!NIL_P(ext)){
/* All ary's members should be X509Extension */
Check_Type(ext, T_ARRAY);
- for (i = 0; i < RARRAY_LEN(ext); i++)
- OSSL_Check_Kind(RARRAY_PTR(ext)[i], cX509Ext);
+ for (i = 0; i < RARRAY(ext)->len; i++)
+ OSSL_Check_Kind(RARRAY(ext)->ptr[i], cX509Ext);
}
error = 0;
@@ -490,8 +490,8 @@ ossl_ocspbres_add_status(VALUE self, VALUE cid, VALUE status,
X509_EXTENSION *x509ext;
sk_X509_EXTENSION_pop_free(single->singleExtensions, X509_EXTENSION_free);
single->singleExtensions = NULL;
- for(i = 0; i < RARRAY_LEN(ext); i++){
- x509ext = DupX509ExtPtr(RARRAY_PTR(ext)[i]);
+ for(i = 0; i < RARRAY(ext)->len; i++){
+ x509ext = DupX509ExtPtr(RARRAY(ext)->ptr[i]);
if(!OCSP_SINGLERESP_add_ext(single, x509ext, -1)){
X509_EXTENSION_free(x509ext);
error = 1;
@@ -681,7 +681,7 @@ Init_ossl_ocsp()
{
mOCSP = rb_define_module_under(mOSSL, "OCSP");
- eOCSPError = rb_define_class_under(mOCSP, "OCSPError", eOSSLError);
+ eOCSPError = rb_define_class_under(mOCSP, "OCSPError", rb_cObject);
cOCSPReq = rb_define_class_under(mOCSP, "Request", rb_cObject);
rb_define_alloc_func(cOCSPReq, ossl_ocspreq_alloc);
diff --git a/ext/openssl/ossl_ocsp.h b/ext/openssl/ossl_ocsp.h
index 65b4f2e23f..244fbb2a74 100644
--- a/ext/openssl/ossl_ocsp.h
+++ b/ext/openssl/ossl_ocsp.h
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_ocsp.h,v 1.1 2003/07/23 16:11:29 gotoyuzo Exp $
* '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 2ec69ba8db..e4b334c67e 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$
+ * $Id: ossl_pkcs12.c,v 1.2 2003/12/15 00:30:12 usa Exp $
*/
#include "ossl.h"
@@ -30,6 +30,7 @@
/*
* Classes
*/
+VALUE mPKCS12;
VALUE cPKCS12;
VALUE ePKCS12Error;
@@ -48,85 +49,32 @@ ossl_pkcs12_s_allocate(VALUE klass)
return obj;
}
-/*
- * call-seq:
- * PKCS12.create(pass, name, key, cert [, ca, [, key_pbe [, cert_pbe [, key_iter [, mac_iter [, keytype]]]]]])
- *
- * === Parameters
- * * +pass+ - string
- * * +name+ - A string describing the key.
- * * +key+ - Any PKey.
- * * +cert+ - A X509::Certificate.
- * * * The public_key portion of the certificate must contain a valid public key.
- * * * The not_before and not_after fields must be filled in.
- * * +ca+ - An optional array of X509::Certificate's.
- * * +key_pbe+ - string
- * * +cert_pbe+ - string
- * * +key_iter+ - integer
- * * +mac_iter+ - integer
- * * +keytype+ - An integer representing an MSIE specific extension.
- *
- * Any optional arguments may be supplied as nil to preserve the OpenSSL defaults.
- *
- * See the OpenSSL documentation for PKCS12_create().
- */
static VALUE
ossl_pkcs12_s_create(int argc, VALUE *argv, VALUE self)
{
- VALUE pass, name, pkey, cert, ca, key_nid, cert_nid, key_iter, mac_iter, keytype;
+ VALUE pass, name, pkey, cert, ca;
VALUE obj;
char *passphrase, *friendlyname;
EVP_PKEY *key;
X509 *x509;
STACK_OF(X509) *x509s;
- int nkey = 0, ncert = 0, kiter = 0, miter = 0, ktype = 0;
PKCS12 *p12;
- rb_scan_args(argc, argv, "46", &pass, &name, &pkey, &cert, &ca, &key_nid, &cert_nid, &key_iter, &mac_iter, &keytype);
+ rb_scan_args(argc, argv, "41", &pass, &name, &pkey, &cert, &ca);
passphrase = NIL_P(pass) ? NULL : StringValuePtr(pass);
friendlyname = NIL_P(name) ? NULL : StringValuePtr(name);
key = GetPKeyPtr(pkey);
x509 = GetX509CertPtr(cert);
x509s = NIL_P(ca) ? NULL : ossl_x509_ary2sk(ca);
-/* TODO: make a VALUE to nid function */
- if (!NIL_P(key_nid)) {
- if ((nkey = OBJ_txt2nid(StringValuePtr(key_nid))) == NID_undef)
- rb_raise(rb_eArgError, "Unknown PBE algorithm %s", StringValuePtr(key_nid));
- }
- if (!NIL_P(cert_nid)) {
- if ((ncert = OBJ_txt2nid(StringValuePtr(cert_nid))) == NID_undef)
- rb_raise(rb_eArgError, "Unknown PBE algorithm %s", StringValuePtr(cert_nid));
- }
- if (!NIL_P(key_iter))
- kiter = NUM2INT(key_iter);
- if (!NIL_P(mac_iter))
- miter = NUM2INT(mac_iter);
- if (!NIL_P(keytype))
- ktype = NUM2INT(keytype);
-
p12 = PKCS12_create(passphrase, friendlyname, key, x509, x509s,
- nkey, ncert, kiter, miter, ktype);
+ 0, 0, 0, 0, 0);
sk_X509_pop_free(x509s, X509_free);
if(!p12) ossl_raise(ePKCS12Error, NULL);
WrapPKCS12(cPKCS12, obj, p12);
- ossl_pkcs12_set_key(obj, pkey);
- ossl_pkcs12_set_cert(obj, cert);
- ossl_pkcs12_set_ca_certs(obj, ca);
-
return obj;
}
-/*
- * call-seq:
- * PKCS12.new -> pkcs12
- * PKCS12.new(str) -> pkcs12
- * PKCS12.new(str, pass) -> pkcs12
- *
- * === Parameters
- * * +str+ - Must be a DER encoded PKCS12 string.
- * * +pass+ - string
- */
static VALUE
ossl_pkcs12_initialize(int argc, VALUE *argv, VALUE self)
{
@@ -146,7 +94,7 @@ ossl_pkcs12_initialize(int argc, VALUE *argv, VALUE self)
pkey = cert = ca = Qnil;
if(!PKCS12_parse((PKCS12*)DATA_PTR(self), passphrase, &key, &x509, &x509s))
- ossl_raise(ePKCS12Error, "PKCS12_parse");
+ ossl_raise(ePKCS12Error, NULL);
pkey = rb_protect((VALUE(*)_((VALUE)))ossl_pkey_new, (VALUE)key,
&st); /* NO DUP */
if(st) goto err;
@@ -181,7 +129,7 @@ ossl_pkcs12_to_der(VALUE self)
if((len = i2d_PKCS12(p12, NULL)) <= 0)
ossl_raise(ePKCS12Error, NULL);
str = rb_str_new(0, len);
- p = RSTRING_PTR(str);
+ p = RSTRING(str)->ptr;
if(i2d_PKCS12(p12, &p) <= 0)
ossl_raise(ePKCS12Error, NULL);
ossl_str_adjust(str, p);
@@ -192,14 +140,10 @@ ossl_pkcs12_to_der(VALUE self)
void
Init_ossl_pkcs12()
{
- /*
- * Defines a file format commonly used to store private keys with
- * accompanying public key certificates, protected with a password-based
- * symmetric key.
- */
- cPKCS12 = rb_define_class_under(mOSSL, "PKCS12", rb_cObject);
- ePKCS12Error = rb_define_class_under(cPKCS12, "PKCS12Error", eOSSLError);
- rb_define_singleton_method(cPKCS12, "create", ossl_pkcs12_s_create, -1);
+ mPKCS12 = rb_define_module_under(mOSSL, "PKCS12");
+ cPKCS12 = rb_define_class_under(mPKCS12, "PKCS12", rb_cObject);
+ ePKCS12Error = rb_define_class_under(mPKCS12, "PKCS12Error", eOSSLError);
+ rb_define_module_function(mPKCS12, "create", ossl_pkcs12_s_create, -1);
rb_define_alloc_func(cPKCS12, ossl_pkcs12_s_allocate);
rb_attr(cPKCS12, rb_intern("key"), 1, 0, Qfalse);
diff --git a/ext/openssl/ossl_pkcs12.h b/ext/openssl/ossl_pkcs12.h
index 24d25d00bb..95b29de9b5 100644
--- a/ext/openssl/ossl_pkcs12.h
+++ b/ext/openssl/ossl_pkcs12.h
@@ -1,11 +1,12 @@
/*
* This program is licenced under the same licence as Ruby.
* (See the file 'LICENCE'.)
- * $Id$
+ * $Id: ossl_pkcs12.h,v 1.1.2.1 2005/06/19 16:29:17 gotoyuzo Exp $
*/
#if !defined(_OSSL_PKCS12_H_)
#define _OSSL_PKCS12_H_
+extern VALUE mPKCS12;
extern VALUE cPKCS12;
extern VALUE ePKCS12Error;
diff --git a/ext/openssl/ossl_pkcs5.c b/ext/openssl/ossl_pkcs5.c
deleted file mode 100644
index 007889fc94..0000000000
--- a/ext/openssl/ossl_pkcs5.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * $Id$
- * Copyright (C) 2007 Technorama Ltd. <oss-ruby@technorama.net>
- */
-#include "ossl.h"
-
-VALUE mPKCS5;
-VALUE ePKCS5;
-
-/*
- * call-seq:
- * PKCS5.pbkdf2_hmac(pass, salt, iter, keylen, digest) => string
- *
- * === Parameters
- * * +pass+ - string
- * * +salt+ - string
- * * +iter+ - integer - should be greater than 1000. 2000 is better.
- * * +keylen+ - integer
- * * +digest+ - a string or OpenSSL::Digest object.
- *
- * Available in OpenSSL 0.9.9?.
- *
- * Digests other than SHA1 may not be supported by other cryptography libraries.
- */
-static VALUE
-ossl_pkcs5_pbkdf2_hmac(VALUE self, VALUE pass, VALUE salt, VALUE iter, VALUE keylen, VALUE digest)
-{
-#ifdef HAVE_PKCS5_PBKDF2_HMAC
- VALUE str;
- const EVP_MD *md;
- int len = NUM2INT(keylen);
-
- StringValue(pass);
- StringValue(salt);
- md = GetDigestPtr(digest);
-
- str = rb_str_new(0, len);
-
- if (PKCS5_PBKDF2_HMAC(RSTRING_PTR(pass), RSTRING_LEN(pass), RSTRING_PTR(salt), RSTRING_LEN(salt), NUM2INT(iter), md, len, RSTRING_PTR(str)) != 1)
- ossl_raise(ePKCS5, "PKCS5_PBKDF2_HMAC");
-
- return str;
-#else
- rb_notimplement();
-#endif
-}
-
-
-/*
- * call-seq:
- * PKCS5.pbkdf2_hmac_sha1(pass, salt, iter, keylen) => string
- *
- * === Parameters
- * * +pass+ - string
- * * +salt+ - string
- * * +iter+ - integer - should be greater than 1000. 2000 is better.
- * * +keylen+ - integer
- *
- * This method is available almost any version OpenSSL.
- *
- * Conforms to rfc2898.
- */
-static VALUE
-ossl_pkcs5_pbkdf2_hmac_sha1(VALUE self, VALUE pass, VALUE salt, VALUE iter, VALUE keylen)
-{
-#ifdef HAVE_PKCS5_PBKDF2_HMAC_SHA1
- VALUE str;
- int len = NUM2INT(keylen);
-
- StringValue(pass);
- StringValue(salt);
-
- str = rb_str_new(0, len);
-
- if (PKCS5_PBKDF2_HMAC_SHA1(RSTRING_PTR(pass), RSTRING_LEN(pass), RSTRING_PTR(salt), RSTRING_LEN(salt), NUM2INT(iter), len, RSTRING_PTR(str)) != 1)
- ossl_raise(ePKCS5, "PKCS5_PBKDF2_HMAC_SHA1");
-
- return str;
-#else
- rb_notimplement();
-#endif
-}
-
-void
-Init_ossl_pkcs5()
-{
- /*
- * Password-based Encryption
- *
- */
- mPKCS5 = rb_define_module_under(mOSSL, "PKCS5");
- ePKCS5 = rb_define_class_under(mPKCS5, "PKCS5Error", eOSSLError);
-
- rb_define_module_function(mPKCS5, "pbkdf2_hmac", ossl_pkcs5_pbkdf2_hmac, 5);
- rb_define_module_function(mPKCS5, "pbkdf2_hmac_sha1", ossl_pkcs5_pbkdf2_hmac_sha1, 4);
-}
diff --git a/ext/openssl/ossl_pkcs7.c b/ext/openssl/ossl_pkcs7.c
index 6918844779..0fa85299aa 100644
--- a/ext/openssl/ossl_pkcs7.c
+++ b/ext/openssl/ossl_pkcs7.c
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_pkcs7.c,v 1.5.2.3 2005/09/10 01:11:15 gotoyuzo Exp $
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -71,6 +71,7 @@
/*
* Classes
*/
+VALUE mPKCS7;
VALUE cPKCS7;
VALUE cPKCS7Signer;
VALUE cPKCS7Recipient;
@@ -133,8 +134,7 @@ DupPKCS7RecipientPtr(VALUE obj)
}
/*
- * call-seq:
- * PKCS7.read_smime(string) => pkcs7
+ * Private
*/
static VALUE
ossl_pkcs7_s_read_smime(VALUE klass, VALUE arg)
@@ -156,10 +156,6 @@ ossl_pkcs7_s_read_smime(VALUE klass, VALUE arg)
return ret;
}
-/*
- * call-seq:
- * PKCS7.write_smime(pkcs7 [, data [, flags]]) => string
- */
static VALUE
ossl_pkcs7_s_write_smime(int argc, VALUE *argv, VALUE klass)
{
@@ -191,10 +187,6 @@ ossl_pkcs7_s_write_smime(int argc, VALUE *argv, VALUE klass)
return str;
}
-/*
- * call-seq:
- * PKCS7.sign(cert, key, data, [, certs [, flags]]) => pkcs7
- */
static VALUE
ossl_pkcs7_s_sign(int argc, VALUE *argv, VALUE klass)
{
@@ -234,10 +226,6 @@ ossl_pkcs7_s_sign(int argc, VALUE *argv, VALUE klass)
return ret;
}
-/*
- * call-seq:
- * PKCS7.encrypt(certs, data, [, cipher [, flags]]) => pkcs7
- */
static VALUE
ossl_pkcs7_s_encrypt(int argc, VALUE *argv, VALUE klass)
{
@@ -299,13 +287,6 @@ ossl_pkcs7_alloc(VALUE klass)
return obj;
}
-/*
- * call-seq:
- * PKCS7.new => pkcs7
- * PKCS7.new(string) => pkcs7
- *
- * Many methods in this class aren't documented.
- */
static VALUE
ossl_pkcs7_initialize(int argc, VALUE *argv, VALUE self)
{
@@ -354,7 +335,7 @@ static int
ossl_pkcs7_sym2typeid(VALUE sym)
{
int i, ret = Qnil;
- const char *s;
+ char *s;
static struct {
const char *name;
@@ -383,10 +364,6 @@ ossl_pkcs7_sym2typeid(VALUE sym)
return ret;
}
-/*
- * call-seq:
- * pkcs7.type = type => type
- */
static VALUE
ossl_pkcs7_set_type(VALUE self, VALUE type)
{
@@ -399,10 +376,6 @@ ossl_pkcs7_set_type(VALUE self, VALUE type)
return type;
}
-/*
- * call-seq:
- * pkcs7.type => string or nil
- */
static VALUE
ossl_pkcs7_get_type(VALUE self)
{
@@ -610,7 +583,7 @@ ossl_pkcs7_set_certificates(VALUE self, VALUE ary)
certs = pkcs7_get_certs_or_crls(self, 1);
while((cert = sk_X509_pop(certs))) X509_free(cert);
- rb_block_call(ary, rb_intern("each"), 0, 0, ossl_pkcs7_set_certs_i, self);
+ rb_iterate(rb_each, ary, ossl_pkcs7_set_certs_i, self);
return ary;
}
@@ -650,7 +623,7 @@ ossl_pkcs7_set_crls(VALUE self, VALUE ary)
crls = pkcs7_get_certs_or_crls(self, 0);
while((crl = sk_X509_CRL_pop(crls))) X509_CRL_free(crl);
- rb_block_call(ary, rb_intern("each"), 0, 0, ossl_pkcs7_set_crls_i, self);
+ rb_iterate(rb_each, ary, ossl_pkcs7_set_crls_i, self);
return ary;
}
@@ -694,10 +667,8 @@ 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);
@@ -778,7 +749,7 @@ ossl_pkcs7_to_der(VALUE self)
if((len = i2d_PKCS7(pkcs7, NULL)) <= 0)
ossl_raise(ePKCS7Error, NULL);
str = rb_str_new(0, len);
- p = RSTRING_PTR(str);
+ p = RSTRING(str)->ptr;
if(i2d_PKCS7(pkcs7, &p) <= 0)
ossl_raise(ePKCS7Error, NULL);
ossl_str_adjust(str, p);
@@ -953,12 +924,15 @@ ossl_pkcs7ri_get_enc_key(VALUE self)
void
Init_ossl_pkcs7()
{
- cPKCS7 = rb_define_class_under(mOSSL, "PKCS7", rb_cObject);
- ePKCS7Error = rb_define_class_under(cPKCS7, "PKCS7Error", eOSSLError);
- rb_define_singleton_method(cPKCS7, "read_smime", ossl_pkcs7_s_read_smime, 1);
- rb_define_singleton_method(cPKCS7, "write_smime", ossl_pkcs7_s_write_smime, -1);
- rb_define_singleton_method(cPKCS7, "sign", ossl_pkcs7_s_sign, -1);
- rb_define_singleton_method(cPKCS7, "encrypt", ossl_pkcs7_s_encrypt, -1);
+ mPKCS7 = rb_define_module_under(mOSSL, "PKCS7");
+
+ ePKCS7Error = rb_define_class_under(mPKCS7, "PKCS7Error", eOSSLError);
+
+ cPKCS7 = rb_define_class_under(mPKCS7, "PKCS7", rb_cObject);
+ rb_define_singleton_method(mPKCS7, "read_smime", ossl_pkcs7_s_read_smime, 1);
+ rb_define_singleton_method(mPKCS7, "write_smime", ossl_pkcs7_s_write_smime, -1);
+ rb_define_singleton_method(mPKCS7, "sign", ossl_pkcs7_s_sign, -1);
+ rb_define_singleton_method(mPKCS7, "encrypt", ossl_pkcs7_s_encrypt, -1);
rb_attr(cPKCS7, rb_intern("data"), 1, 0, Qfalse);
rb_attr(cPKCS7, rb_intern("error_string"), 1, 1, Qfalse);
rb_define_alloc_func(cPKCS7, ossl_pkcs7_alloc);
@@ -988,8 +962,8 @@ Init_ossl_pkcs7()
rb_define_alias(cPKCS7, "to_s", "to_pem");
rb_define_method(cPKCS7, "to_der", ossl_pkcs7_to_der, 0);
- cPKCS7Signer = rb_define_class_under(cPKCS7, "SignerInfo", rb_cObject);
- rb_define_const(cPKCS7, "Signer", cPKCS7Signer);
+ cPKCS7Signer = rb_define_class_under(mPKCS7, "SignerInfo", rb_cObject);
+ rb_define_const(mPKCS7, "Signer", cPKCS7Signer);
rb_define_alloc_func(cPKCS7Signer, ossl_pkcs7si_alloc);
rb_define_method(cPKCS7Signer, "initialize", ossl_pkcs7si_initialize,3);
rb_define_method(cPKCS7Signer, "issuer", ossl_pkcs7si_get_issuer, 0);
@@ -997,14 +971,14 @@ Init_ossl_pkcs7()
rb_define_method(cPKCS7Signer, "serial", ossl_pkcs7si_get_serial,0);
rb_define_method(cPKCS7Signer,"signed_time",ossl_pkcs7si_get_signed_time,0);
- cPKCS7Recipient = rb_define_class_under(cPKCS7,"RecipientInfo",rb_cObject);
+ cPKCS7Recipient = rb_define_class_under(mPKCS7,"RecipientInfo",rb_cObject);
rb_define_alloc_func(cPKCS7Recipient, ossl_pkcs7ri_alloc);
rb_define_method(cPKCS7Recipient, "initialize", ossl_pkcs7ri_initialize,1);
rb_define_method(cPKCS7Recipient, "issuer", ossl_pkcs7ri_get_issuer,0);
rb_define_method(cPKCS7Recipient, "serial", ossl_pkcs7ri_get_serial,0);
rb_define_method(cPKCS7Recipient, "enc_key", ossl_pkcs7ri_get_enc_key,0);
-#define DefPKCS7Const(x) rb_define_const(cPKCS7, #x, INT2NUM(PKCS7_##x))
+#define DefPKCS7Const(x) rb_define_const(mPKCS7, #x, INT2NUM(PKCS7_##x))
DefPKCS7Const(TEXT);
DefPKCS7Const(NOCERTS);
diff --git a/ext/openssl/ossl_pkcs7.h b/ext/openssl/ossl_pkcs7.h
index 371c421103..fdf0d9fb34 100644
--- a/ext/openssl/ossl_pkcs7.h
+++ b/ext/openssl/ossl_pkcs7.h
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_pkcs7.h,v 1.1.2.1 2005/09/10 01:17:00 gotoyuzo Exp $
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -11,6 +11,7 @@
#if !defined(_OSSL_PKCS7_H_)
#define _OSSL_PKCS7_H_
+extern VALUE mPKCS7;
extern VALUE cPKCS7;
extern VALUE cPKCS7Signer;
extern VALUE cPKCS7Recipient;
diff --git a/ext/openssl/ossl_pkey.c b/ext/openssl/ossl_pkey.c
index b295cfc25e..5a061597f6 100644
--- a/ext/openssl/ossl_pkey.c
+++ b/ext/openssl/ossl_pkey.c
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_pkey.c,v 1.4.2.2 2005/04/08 09:26:54 gotoyuzo Exp $
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -55,10 +55,6 @@ ossl_pkey_new(EVP_PKEY *pkey)
case EVP_PKEY_DH:
return ossl_dh_new(pkey);
#endif
-#if !defined(OPENSSL_NO_EC) && (OPENSSL_VERSION_NUMBER >= 0x0090802fL)
- case EVP_PKEY_EC:
- return ossl_ec_new(pkey);
-#endif
default:
ossl_raise(ePKeyError, "unsupported key type");
}
@@ -72,7 +68,7 @@ ossl_pkey_new_from_file(VALUE filename)
EVP_PKEY *pkey;
SafeStringValue(filename);
- if (!(fp = fopen(RSTRING_PTR(filename), "r"))) {
+ if (!(fp = fopen(RSTRING(filename)->ptr, "r"))) {
ossl_raise(ePKeyError, "%s", strerror(errno));
}
@@ -112,7 +108,7 @@ EVP_PKEY *
DupPKeyPtr(VALUE obj)
{
EVP_PKEY *pkey;
-
+
SafeGetPKey(obj, pkey);
CRYPTO_add(&pkey->references, 1, CRYPTO_LOCK_EVP_PKEY);
@@ -173,12 +169,13 @@ ossl_pkey_sign(VALUE self, VALUE digest, VALUE data)
GetPKey(self, pkey);
EVP_SignInit(&ctx, GetDigestPtr(digest));
StringValue(data);
- EVP_SignUpdate(&ctx, RSTRING_PTR(data), RSTRING_LEN(data));
+ EVP_SignUpdate(&ctx, RSTRING(data)->ptr, RSTRING(data)->len);
str = rb_str_new(0, EVP_PKEY_size(pkey)+16);
- if (!EVP_SignFinal(&ctx, RSTRING_PTR(str), &buf_len, pkey))
+ if (!EVP_SignFinal(&ctx, RSTRING(str)->ptr, &buf_len, pkey))
ossl_raise(ePKeyError, NULL);
- assert(buf_len <= RSTRING_LEN(str));
- rb_str_set_len(str, buf_len);
+ assert(buf_len <= RSTRING(str)->len);
+ RSTRING(str)->len = buf_len;
+ RSTRING(str)->ptr[buf_len] = 0;
return str;
}
@@ -193,8 +190,8 @@ ossl_pkey_verify(VALUE self, VALUE digest, VALUE sig, VALUE data)
EVP_VerifyInit(&ctx, GetDigestPtr(digest));
StringValue(sig);
StringValue(data);
- EVP_VerifyUpdate(&ctx, RSTRING_PTR(data), RSTRING_LEN(data));
- switch (EVP_VerifyFinal(&ctx, RSTRING_PTR(sig), RSTRING_LEN(sig), pkey)) {
+ EVP_VerifyUpdate(&ctx, RSTRING(data)->ptr, RSTRING(data)->len);
+ switch (EVP_VerifyFinal(&ctx, RSTRING(sig)->ptr, RSTRING(sig)->len, pkey)) {
case 0:
return Qfalse;
case 1:
@@ -211,10 +208,6 @@ 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);
@@ -230,11 +223,10 @@ Init_ossl_pkey()
id_private_q = rb_intern("private?");
/*
- * INIT rsa, dsa, dh, ec
+ * INIT rsa, dsa
*/
Init_ossl_rsa();
Init_ossl_dsa();
Init_ossl_dh();
- Init_ossl_ec();
}
diff --git a/ext/openssl/ossl_pkey.h b/ext/openssl/ossl_pkey.h
index 67ff1fddd0..224f0f4634 100644
--- a/ext/openssl/ossl_pkey.h
+++ b/ext/openssl/ossl_pkey.h
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_pkey.h,v 1.2.2.2 2005/09/18 22:56:11 gotoyuzo Exp $
* 'OpenSSL for Ruby' project
* Copyright (C) 2001 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -77,24 +77,7 @@ extern DH *OSSL_DEFAULT_DH_1024;
VALUE ossl_dh_new(EVP_PKEY *);
void Init_ossl_dh(void);
-/*
- * EC
- */
-extern VALUE cEC;
-extern VALUE eECError;
-extern VALUE cEC_GROUP;
-extern VALUE eEC_GROUP;
-extern VALUE cEC_POINT;
-extern VALUE eEC_POINT;
-VALUE ossl_ec_new(EVP_PKEY *);
-void Init_ossl_ec(void);
-
-
#define OSSL_PKEY_BN(keytype, name) \
-/* \
- * call-seq: \
- * key.##name -> aBN \
- */ \
static VALUE ossl_##keytype##_get_##name(VALUE self) \
{ \
EVP_PKEY *pkey; \
@@ -106,10 +89,6 @@ static VALUE ossl_##keytype##_get_##name(VALUE self) \
return Qnil; \
return ossl_bn_new(bn); \
} \
-/* \
- * call-seq: \
- * key.##name = bn -> bn \
- */ \
static VALUE ossl_##keytype##_set_##name(VALUE self, VALUE bignum) \
{ \
EVP_PKEY *pkey; \
diff --git a/ext/openssl/ossl_pkey_dh.c b/ext/openssl/ossl_pkey_dh.c
index 02c3d99ed8..79692f2f47 100644
--- a/ext/openssl/ossl_pkey_dh.c
+++ b/ext/openssl/ossl_pkey_dh.c
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_pkey_dh.c,v 1.4.2.3 2005/04/08 09:26:54 gotoyuzo Exp $
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -99,15 +99,6 @@ dh_generate(int size, int gen)
return dh;
}
-/*
- * call-seq:
- * DH.generate(size [, generator]) -> dh
- *
- * === Parameters
- * * +size+ is an integer representing the desired key size. Keys smaller than 1024 should be considered insecure.
- * * +generator+ is a small number > 1, typically 2 or 5.
- *
- */
static VALUE
ossl_dh_s_generate(int argc, VALUE *argv, VALUE klass)
{
@@ -116,9 +107,9 @@ ossl_dh_s_generate(int argc, VALUE *argv, VALUE klass)
VALUE size, gen, obj;
if (rb_scan_args(argc, argv, "11", &size, &gen) == 2) {
- g = NUM2INT(gen);
+ g = FIX2INT(gen);
}
- dh = dh_generate(NUM2INT(size), g);
+ dh = dh_generate(FIX2INT(size), g);
obj = dh_instance(klass, dh);
if (obj == Qfalse) {
DH_free(dh);
@@ -128,21 +119,6 @@ ossl_dh_s_generate(int argc, VALUE *argv, VALUE klass)
return obj;
}
-/*
- * call-seq:
- * DH.new([size [, generator] | string]) -> dh
- *
- * === Parameters
- * * +size+ is an integer representing the desired key size. Keys smaller than 1024 should be considered insecure.
- * * +generator+ is a small number > 1, typically 2 or 5.
- * * +string+ contains the DER or PEM encoded key.
- *
- * === Examples
- * * DH.new -> dh
- * * DH.new(1024) -> dh
- * * DH.new(1024, 5) -> dh
- * * DH.new(File.read('key.pem')) -> dh
- */
static VALUE
ossl_dh_initialize(int argc, VALUE *argv, VALUE self)
{
@@ -158,7 +134,7 @@ ossl_dh_initialize(int argc, VALUE *argv, VALUE self)
}
else if (FIXNUM_P(arg)) {
if (!NIL_P(gen)) {
- g = NUM2INT(gen);
+ g = FIX2INT(gen);
}
if (!(dh = dh_generate(FIX2INT(arg), g))) {
ossl_raise(eDHError, NULL);
@@ -182,26 +158,19 @@ ossl_dh_initialize(int argc, VALUE *argv, VALUE self)
return self;
}
-/*
- * call-seq:
- * dh.public? -> true | false
- *
- */
static VALUE
ossl_dh_is_public(VALUE self)
{
EVP_PKEY *pkey;
GetPKeyDH(self, pkey);
-
+ /*
+ * Do we need to check dhp->dh->public_pkey?
+ * return Qtrue;
+ */
return (pkey->pkey.dh->pub_key) ? Qtrue : Qfalse;
}
-/*
- * call-seq:
- * dh.private? -> true | false
- *
- */
static VALUE
ossl_dh_is_private(VALUE self)
{
@@ -212,11 +181,6 @@ ossl_dh_is_private(VALUE self)
return (DH_PRIVATE(pkey->pkey.dh)) ? Qtrue : Qfalse;
}
-/*
- * call-seq:
- * dh.to_pem -> aString
- *
- */
static VALUE
ossl_dh_export(VALUE self)
{
@@ -237,11 +201,6 @@ ossl_dh_export(VALUE self)
return str;
}
-/*
- * call-seq:
- * dh.to_der -> aString
- *
- */
static VALUE
ossl_dh_to_der(VALUE self)
{
@@ -254,7 +213,7 @@ ossl_dh_to_der(VALUE self)
if((len = i2d_DHparams(pkey->pkey.dh, NULL)) <= 0)
ossl_raise(eDHError, NULL);
str = rb_str_new(0, len);
- p = RSTRING_PTR(str);
+ p = RSTRING(str)->ptr;
if(i2d_DHparams(pkey->pkey.dh, &p) < 0)
ossl_raise(eDHError, NULL);
ossl_str_adjust(str, p);
@@ -263,9 +222,6 @@ ossl_dh_to_der(VALUE self)
}
/*
- * call-seq:
- * dh.params -> hash
- *
* Stores all parameters of key to the hash
* INSECURE: PRIVATE INFORMATIONS CAN LEAK OUT!!!
* Don't use :-)) (I's up to you)
@@ -289,9 +245,6 @@ ossl_dh_get_params(VALUE self)
}
/*
- * call-seq:
- * dh.to_text -> aString
- *
* Prints all parameters of key to buffer
* INSECURE: PRIVATE INFORMATIONS CAN LEAK OUT!!!
* Don't use :-)) (I's up to you)
@@ -317,10 +270,7 @@ ossl_dh_to_text(VALUE self)
}
/*
- * call-seq:
- * dh.public_key -> aDH
- *
- * Makes new instance DH PUBLIC_KEY from PRIVATE_KEY
+ * Makes new instance DH PUBLIC_KEY from PRIVATE_KEY
*/
static VALUE
ossl_dh_to_public_key(VALUE self)
@@ -340,11 +290,6 @@ ossl_dh_to_public_key(VALUE self)
return obj;
}
-/*
- * call-seq:
- * dh.check_params -> true | false
- *
- */
static VALUE
ossl_dh_check_params(VALUE self)
{
@@ -362,11 +307,6 @@ ossl_dh_check_params(VALUE self)
return codes == 0 ? Qtrue : Qfalse;
}
-/*
- * call-seq:
- * dh.generate_key -> self
- *
- */
static VALUE
ossl_dh_generate_key(VALUE self)
{
@@ -381,18 +321,6 @@ ossl_dh_generate_key(VALUE self)
return self;
}
-/*
- * call-seq:
- * dh.compute_key(pub_bn) -> aString
- *
- * === Parameters
- * * +pub_bn+ is a OpenSSL::BN.
- *
- * Returns aString containing a shared secret computed from the other parties public value.
- *
- * See DH_compute_key() for further information.
- *
- */
static VALUE
ossl_dh_compute_key(VALUE self, VALUE pub)
{
@@ -407,10 +335,11 @@ ossl_dh_compute_key(VALUE self, VALUE pub)
pub_key = GetBNPtr(pub);
len = DH_size(dh);
str = rb_str_new(0, len);
- if ((len = DH_compute_key(RSTRING_PTR(str), pub_key, dh)) < 0) {
+ if ((len = DH_compute_key(RSTRING(str)->ptr, pub_key, dh)) < 0) {
ossl_raise(eDHError, NULL);
}
- rb_str_set_len(str, len);
+ RSTRING(str)->len = len;
+ RSTRING(str)->ptr[len] = 0;
return str;
}
@@ -438,7 +367,7 @@ static unsigned char DEFAULT_DH_512_PRIM[] = {
};
static unsigned char DEFAULT_DH_512_GEN[] = { 0x02 };
DH *OSSL_DEFAULT_DH_512 = NULL;
-
+
/*
* -----BEGIN DH PARAMETERS-----
* MIGHAoGBAJ0lOVy0VIr/JebWn0zDwY2h+rqITFOpdNr6ugsgvkDXuucdcChhYExJ
@@ -477,7 +406,7 @@ ossl_create_dh(unsigned char *p, size_t plen, unsigned char *g, size_t glen)
dh->g = BN_bin2bn(g, glen, NULL);
if (dh->p == NULL || dh->g == NULL){
DH_free(dh);
- ossl_raise(eDHError, NULL);
+ ossl_raise(eDHError, NULL);
}
return dh;
@@ -489,11 +418,6 @@ 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);
@@ -524,9 +448,11 @@ Init_ossl_dh()
}
#else /* defined NO_DH */
+# warning >>> OpenSSL is compiled without DH support <<<
void
Init_ossl_dh()
{
+ rb_warning("OpenSSL is compiled without DH support");
}
#endif /* NO_DH */
diff --git a/ext/openssl/ossl_pkey_dsa.c b/ext/openssl/ossl_pkey_dsa.c
index d9c7fcbe78..2a6060fe77 100644
--- a/ext/openssl/ossl_pkey_dsa.c
+++ b/ext/openssl/ossl_pkey_dsa.c
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_pkey_dsa.c,v 1.5.2.3 2005/09/18 22:56:11 gotoyuzo Exp $
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -99,18 +99,10 @@ dsa_generate(int size)
return dsa;
}
-/*
- * call-seq:
- * DSA.generate(size) -> dsa
- *
- * === Parameters
- * * +size+ is an integer representing the desired key size.
- *
- */
static VALUE
ossl_dsa_s_generate(VALUE klass, VALUE size)
{
- DSA *dsa = dsa_generate(NUM2INT(size)); /* err handled by dsa_instance */
+ DSA *dsa = dsa_generate(FIX2INT(size)); /* err handled by dsa_instance */
VALUE obj = dsa_instance(klass, dsa);
if (obj == Qfalse) {
@@ -121,22 +113,6 @@ ossl_dsa_s_generate(VALUE klass, VALUE size)
return obj;
}
-/*
- * call-seq:
- * DSA.new([size | string [, pass]) -> dsa
- *
- * === Parameters
- * * +size+ is an integer representing the desired key size.
- * * +string+ contains a DER or PEM encoded key.
- * * +pass+ is a string that contains a optional password.
- *
- * === Examples
- * * DSA.new -> dsa
- * * DSA.new(1024) -> dsa
- * * DSA.new(File.read('dsa.pem')) -> dsa
- * * DSA.new(File.read('dsa.pem'), 'mypassword') -> dsa
- *
- */
static VALUE
ossl_dsa_initialize(int argc, VALUE *argv, VALUE self)
{
@@ -187,11 +163,6 @@ ossl_dsa_initialize(int argc, VALUE *argv, VALUE self)
return self;
}
-/*
- * call-seq:
- * dsa.public? -> true | false
- *
- */
static VALUE
ossl_dsa_is_public(VALUE self)
{
@@ -199,14 +170,13 @@ ossl_dsa_is_public(VALUE self)
GetPKeyDSA(self, pkey);
+ /*
+ * Do we need to check dsap->dsa->public_pkey?
+ * return Qtrue;
+ */
return (pkey->pkey.dsa->pub_key) ? Qtrue : Qfalse;
}
-/*
- * call-seq:
- * dsa.private? -> true | false
- *
- */
static VALUE
ossl_dsa_is_private(VALUE self)
{
@@ -217,19 +187,6 @@ ossl_dsa_is_private(VALUE self)
return (DSA_PRIVATE(self, pkey->pkey.dsa)) ? Qtrue : Qfalse;
}
-/*
- * call-seq:
- * dsa.to_pem([cipher, password]) -> aString
- *
- * === Parameters
- * +cipher+ is an OpenSSL::Cipher.
- * +password+ is a string containing your password.
- *
- * === Examples
- * * DSA.to_pem -> aString
- * * DSA.to_pem(cipher, 'mypassword') -> aString
- *
- */
static VALUE
ossl_dsa_export(int argc, VALUE *argv, VALUE self)
{
@@ -267,11 +224,6 @@ ossl_dsa_export(int argc, VALUE *argv, VALUE self)
return str;
}
-/*
- * call-seq:
- * dsa.to_der -> aString
- *
- */
static VALUE
ossl_dsa_to_der(VALUE self)
{
@@ -289,7 +241,7 @@ ossl_dsa_to_der(VALUE self)
if((len = i2d_func(pkey->pkey.dsa, NULL)) <= 0)
ossl_raise(eDSAError, NULL);
str = rb_str_new(0, len);
- p = RSTRING_PTR(str);
+ p = RSTRING(str)->ptr;
if(i2d_func(pkey->pkey.dsa, &p) < 0)
ossl_raise(eDSAError, NULL);
ossl_str_adjust(str, p);
@@ -298,9 +250,6 @@ ossl_dsa_to_der(VALUE self)
}
/*
- * call-seq:
- * dsa.params -> hash
- *
* Stores all parameters of key to the hash
* INSECURE: PRIVATE INFORMATIONS CAN LEAK OUT!!!
* Don't use :-)) (I's up to you)
@@ -325,9 +274,6 @@ ossl_dsa_get_params(VALUE self)
}
/*
- * call-seq:
- * dsa.to_text -> aString
- *
* Prints all parameters of key to buffer
* INSECURE: PRIVATE INFORMATIONS CAN LEAK OUT!!!
* Don't use :-)) (I's up to you)
@@ -353,9 +299,6 @@ ossl_dsa_to_text(VALUE self)
}
/*
- * call-seq:
- * dsa.public_key -> aDSA
- *
* Makes new instance DSA PUBLIC_KEY from PRIVATE_KEY
*/
static VALUE
@@ -378,11 +321,6 @@ ossl_dsa_to_public_key(VALUE self)
#define ossl_dsa_buf_size(pkey) (DSA_size((pkey)->pkey.dsa)+16)
-/*
- * call-seq:
- * dsa.syssign(string) -> aString
- *
- */
static VALUE
ossl_dsa_sign(VALUE self, VALUE data)
{
@@ -396,20 +334,16 @@ ossl_dsa_sign(VALUE self, VALUE data)
ossl_raise(eDSAError, "Private DSA key needed!");
}
str = rb_str_new(0, ossl_dsa_buf_size(pkey));
- if (!DSA_sign(0, RSTRING_PTR(data), RSTRING_LEN(data), RSTRING_PTR(str),
+ if (!DSA_sign(0, RSTRING(data)->ptr, RSTRING(data)->len, RSTRING(str)->ptr,
&buf_len, pkey->pkey.dsa)) { /* type is ignored (0) */
ossl_raise(eDSAError, NULL);
}
- rb_str_set_len(str, buf_len);
+ RSTRING(str)->len = buf_len;
+ RSTRING(str)->ptr[buf_len] = 0;
return str;
}
-/*
- * call-seq:
- * dsa.sysverify(digest, sig) -> true | false
- *
- */
static VALUE
ossl_dsa_verify(VALUE self, VALUE digest, VALUE sig)
{
@@ -420,8 +354,8 @@ ossl_dsa_verify(VALUE self, VALUE digest, VALUE sig)
StringValue(digest);
StringValue(sig);
/* type is ignored (0) */
- ret = DSA_verify(0, RSTRING_PTR(digest), RSTRING_LEN(digest),
- RSTRING_PTR(sig), RSTRING_LEN(sig), pkey->pkey.dsa);
+ ret = DSA_verify(0, RSTRING(digest)->ptr, RSTRING(digest)->len,
+ RSTRING(sig)->ptr, RSTRING(sig)->len, pkey->pkey.dsa);
if (ret < 0) {
ossl_raise(eDSAError, NULL);
}
@@ -444,11 +378,6 @@ 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);
@@ -477,8 +406,12 @@ Init_ossl_dsa()
}
#else /* defined NO_DSA */
+# warning >>> OpenSSL is compiled without DSA support <<<
+
void
Init_ossl_dsa()
{
+ rb_warning("OpenSSL is compiled without DSA support");
}
+
#endif /* NO_DSA */
diff --git a/ext/openssl/ossl_pkey_ec.c b/ext/openssl/ossl_pkey_ec.c
deleted file mode 100644
index 210054121d..0000000000
--- a/ext/openssl/ossl_pkey_ec.c
+++ /dev/null
@@ -1,1582 +0,0 @@
-/*
- * Copyright (C) 2006-2007 Technorama Ltd. <oss-ruby@technorama.net>
- */
-
-#include "ossl.h"
-
-#if !defined(OPENSSL_NO_EC) && (OPENSSL_VERSION_NUMBER >= 0x0090802fL)
-
-typedef struct {
- EC_GROUP *group;
- int dont_free;
-} ossl_ec_group;
-
-typedef struct {
- EC_POINT *point;
- int dont_free;
-} ossl_ec_point;
-
-
-#define EXPORT_PEM 0
-#define EXPORT_DER 1
-
-
-#define GetPKeyEC(obj, pkey) do { \
- GetPKey(obj, pkey); \
- if (EVP_PKEY_type(pkey->type) != EVP_PKEY_EC) { \
- ossl_raise(rb_eRuntimeError, "THIS IS NOT A EC PKEY!"); \
- } \
-} while (0)
-
-#define SafeGet_ec_group(obj, group) do { \
- OSSL_Check_Kind(obj, cEC_GROUP); \
- Data_Get_Struct(obj, ossl_ec_group, group); \
-} while(0)
-
-#define Get_EC_KEY(obj, key) do { \
- EVP_PKEY *pkey; \
- GetPKeyEC(obj, pkey); \
- key = pkey->pkey.ec; \
-} while(0)
-
-#define Require_EC_KEY(obj, key) do { \
- Get_EC_KEY(obj, key); \
- if (key == NULL) \
- rb_raise(eECError, "EC_KEY is not initialized"); \
-} while(0)
-
-#define SafeRequire_EC_KEY(obj, key) do { \
- OSSL_Check_Kind(obj, cEC); \
- Require_EC_KEY(obj, key); \
-} while (0)
-
-#define Get_EC_GROUP(obj, g) do { \
- ossl_ec_group *ec_group; \
- Data_Get_Struct(obj, ossl_ec_group, ec_group); \
- if (ec_group == NULL) \
- rb_raise(eEC_GROUP, "missing ossl_ec_group structure"); \
- g = ec_group->group; \
-} while(0)
-
-#define Require_EC_GROUP(obj, group) do { \
- Get_EC_GROUP(obj, group); \
- if (group == NULL) \
- rb_raise(eEC_GROUP, "EC_GROUP is not initialized"); \
-} while(0)
-
-#define SafeRequire_EC_GROUP(obj, group) do { \
- OSSL_Check_Kind(obj, cEC_GROUP); \
- Require_EC_GROUP(obj, group); \
-} while(0)
-
-#define Get_EC_POINT(obj, p) do { \
- ossl_ec_point *ec_point; \
- Data_Get_Struct(obj, ossl_ec_point, ec_point); \
- if (ec_point == NULL) \
- rb_raise(eEC_POINT, "missing ossl_ec_point structure"); \
- p = ec_point->point; \
-} while(0)
-
-#define Require_EC_POINT(obj, point) do { \
- Get_EC_POINT(obj, point); \
- if (point == NULL) \
- rb_raise(eEC_POINT, "EC_POINT is not initialized"); \
-} while(0)
-
-#define SafeRequire_EC_POINT(obj, point) do { \
- OSSL_Check_Kind(obj, cEC_POINT); \
- Require_EC_POINT(obj, point); \
-} while(0)
-
-VALUE cEC;
-VALUE eECError;
-VALUE cEC_GROUP;
-VALUE eEC_GROUP;
-VALUE cEC_POINT;
-VALUE eEC_POINT;
-
-static ID s_GFp;
-static ID s_GFp_simple;
-static ID s_GFp_mont;
-static ID s_GFp_nist;
-static ID s_GF2m;
-static ID s_GF2m_simple;
-
-static ID ID_uncompressed;
-static ID ID_compressed;
-static ID ID_hybrid;
-
-static VALUE ec_instance(VALUE klass, EC_KEY *ec)
-{
- EVP_PKEY *pkey;
- VALUE obj;
-
- if (!ec) {
- return Qfalse;
- }
- if (!(pkey = EVP_PKEY_new())) {
- return Qfalse;
- }
- if (!EVP_PKEY_assign_EC_KEY(pkey, ec)) {
- EVP_PKEY_free(pkey);
- return Qfalse;
- }
- WrapPKey(klass, obj, pkey);
-
- return obj;
-}
-
-VALUE ossl_ec_new(EVP_PKEY *pkey)
-{
- VALUE obj;
-
- if (!pkey) {
- obj = ec_instance(cEC, EC_KEY_new());
- } else {
- if (EVP_PKEY_type(pkey->type) != EVP_PKEY_EC) {
- ossl_raise(rb_eTypeError, "Not a EC key!");
- }
- WrapPKey(cEC, obj, pkey);
- }
- if (obj == Qfalse) {
- ossl_raise(eECError, NULL);
- }
-
- return obj;
-}
-
-
-/* call-seq:
- * OpenSSL::PKey::EC.new()
- * OpenSSL::PKey::EC.new(ec_key)
- * OpenSSL::PKey::EC.new(ec_group)
- * OpenSSL::PKey::EC.new("secp112r1")
- * OpenSSL::PKey::EC.new(pem_string)
- * OpenSSL::PKey::EC.new(der_string)
- *
- * See the OpenSSL documentation for:
- * EC_KEY_*
- */
-static VALUE ossl_ec_key_initialize(int argc, VALUE *argv, VALUE self)
-{
- EVP_PKEY *pkey;
- EC_KEY *ec = NULL;
- VALUE arg, pass;
- VALUE group = Qnil;
-
- GetPKey(self, pkey);
- if (pkey->pkey.ec)
- rb_raise(eECError, "EC_KEY already initialized");
-
- rb_scan_args(argc, argv, "02", &arg, &pass);
-
- if (NIL_P(arg)) {
- ec = EC_KEY_new();
- } else {
- if (rb_obj_is_kind_of(arg, cEC)) {
- EC_KEY *other_ec = NULL;
-
- SafeRequire_EC_KEY(arg, other_ec);
- ec = EC_KEY_dup(other_ec);
- } else if (rb_obj_is_kind_of(arg, cEC_GROUP)) {
- ec = EC_KEY_new();
- group = arg;
- } else {
- BIO *in = ossl_obj2bio(arg);
-
- ec = PEM_read_bio_ECPrivateKey(in, NULL, NULL, NULL);
- if (!ec) {
- BIO_reset(in);
- ec = PEM_read_bio_EC_PUBKEY(in, NULL, NULL, NULL);
- }
- if (!ec) {
- BIO_reset(in);
- ec = d2i_ECPrivateKey_bio(in, NULL);
- }
- if (!ec) {
- BIO_reset(in);
- ec = d2i_EC_PUBKEY_bio(in, NULL);
- }
-
- BIO_free(in);
-
- if (ec == NULL) {
- const char *name = STR2CSTR(arg);
- int nid = OBJ_sn2nid(name);
-
- if (nid == NID_undef)
- ossl_raise(eECError, "unknown curve name (%s)\n", name);
-
- if ((ec = EC_KEY_new_by_curve_name(nid)) == NULL)
- ossl_raise(eECError, "unable to create curve (%s)\n", name);
-
- EC_KEY_set_asn1_flag(ec, OPENSSL_EC_NAMED_CURVE);
- EC_KEY_set_conv_form(ec, POINT_CONVERSION_UNCOMPRESSED);
- }
- }
- }
-
- if (ec == NULL)
- ossl_raise(eECError, NULL);
-
- if (!EVP_PKEY_assign_EC_KEY(pkey, ec)) {
- EC_KEY_free(ec);
- ossl_raise(eECError, "EVP_PKEY_assign_EC_KEY");
- }
-
- rb_iv_set(self, "@group", Qnil);
-
- if (!NIL_P(group))
- rb_funcall(self, rb_intern("group="), 1, arg);
-
- return self;
-}
-
-/*
- * call-seq:
- * key.group => group
- *
- * Returns a constant <code>OpenSSL::EC::Group</code> that is tied to the key.
- * Modifying the returned group can make the key invalid.
- */
-static VALUE ossl_ec_key_get_group(VALUE self)
-{
- VALUE group_v;
- EC_KEY *ec;
- ossl_ec_group *ec_group;
- EC_GROUP *group;
-
- Require_EC_KEY(self, ec);
-
- group_v = rb_iv_get(self, "@group");
- if (!NIL_P(group_v))
- return group_v;
-
- if ((group = (EC_GROUP *)EC_KEY_get0_group(ec)) != NULL) {
- group_v = rb_obj_alloc(cEC_GROUP);
- SafeGet_ec_group(group_v, ec_group);
- ec_group->group = group;
- ec_group->dont_free = 1;
- rb_iv_set(group_v, "@key", self);
- rb_iv_set(self, "@group", group_v);
- return group_v;
- }
-
- return Qnil;
-}
-
-/*
- * call-seq:
- * key.group = group => group
- *
- * Returns the same object passed, not the group object associated with the key.
- * If you wish to access the group object tied to the key call key.group after setting
- * the group.
- *
- * Setting the group will immediately destroy any previously assigned group object.
- * The group is internally copied by OpenSSL. Modifying the original group after
- * assignment will not effect the internal key structure.
- * (your changes may be lost). BE CAREFUL.
- *
- * EC_KEY_set_group calls EC_GROUP_free(key->group) then EC_GROUP_dup(), not EC_GROUP_copy.
- * This documentation is accurate for OpenSSL 0.9.8b.
- */
-static VALUE ossl_ec_key_set_group(VALUE self, VALUE group_v)
-{
- VALUE old_group_v;
- EC_KEY *ec;
- EC_GROUP *group;
-
- Require_EC_KEY(self, ec);
- SafeRequire_EC_GROUP(group_v, group);
-
- old_group_v = rb_iv_get(self, "@group");
- if (!NIL_P(old_group_v)) {
- ossl_ec_group *old_ec_group;
- SafeGet_ec_group(old_group_v, old_ec_group);
-
- old_ec_group->group = NULL;
- old_ec_group->dont_free = 0;
- rb_iv_set(old_group_v, "@key", Qnil);
- }
-
- rb_iv_set(self, "@group", Qnil);
-
- if (EC_KEY_set_group(ec, group) != 1)
- ossl_raise(eECError, "EC_KEY_set_group");
-
- return group_v;
-}
-
-/*
- * call-seq:
- * key.private_key => OpenSSL::BN
- *
- * See the OpenSSL documentation for EC_KEY_get0_private_key()
- */
-static VALUE ossl_ec_key_get_private_key(VALUE self)
-{
- EC_KEY *ec;
- const BIGNUM *bn;
-
- Require_EC_KEY(self, ec);
-
- if ((bn = EC_KEY_get0_private_key(ec)) == NULL)
- return Qnil;
-
- return ossl_bn_new(bn);
-}
-
-/*
- * call-seq:
- * key.private_key = openssl_bn
- *
- * See the OpenSSL documentation for EC_KEY_set_private_key()
- */
-static VALUE ossl_ec_key_set_private_key(VALUE self, VALUE private_key)
-{
- EC_KEY *ec;
- BIGNUM *bn = NULL;
-
- Require_EC_KEY(self, ec);
- if (!NIL_P(private_key))
- bn = GetBNPtr(private_key);
-
- switch (EC_KEY_set_private_key(ec, bn)) {
- case 1:
- break;
- case 0:
- if (bn == NULL)
- break;
- default:
- ossl_raise(eECError, "EC_KEY_set_private_key");
- }
-
- return private_key;
-}
-
-
-static VALUE ossl_ec_point_dup(const EC_POINT *point, VALUE group_v)
-{
- VALUE obj;
- const EC_GROUP *group;
- ossl_ec_point *new_point;
-
- obj = rb_obj_alloc(cEC_POINT);
- Data_Get_Struct(obj, ossl_ec_point, new_point);
-
- SafeRequire_EC_GROUP(group_v, group);
-
- new_point->point = EC_POINT_dup(point, group);
- if (new_point->point == NULL)
- ossl_raise(eEC_POINT, "EC_POINT_dup");
- rb_iv_set(obj, "@group", group_v);
-
- return obj;
-}
-
-/*
- * call-seq:
- * key.public_key => OpenSSL::PKey::EC::Point
- *
- * See the OpenSSL documentation for EC_KEY_get0_public_key()
- */
-static VALUE ossl_ec_key_get_public_key(VALUE self)
-{
- EC_KEY *ec;
- const EC_POINT *point;
- VALUE group;
-
- Require_EC_KEY(self, ec);
-
- if ((point = EC_KEY_get0_public_key(ec)) == NULL)
- return Qnil;
-
- group = rb_funcall(self, rb_intern("group"), 0);
- if (NIL_P(group))
- ossl_raise(eECError, "EC_KEY_get0_get0_group (has public_key but no group???");
-
- return ossl_ec_point_dup(point, group);
-}
-
-/*
- * call-seq:
- * key.public_key = ec_point
- *
- * See the OpenSSL documentation for EC_KEY_set_public_key()
- */
-static VALUE ossl_ec_key_set_public_key(VALUE self, VALUE public_key)
-{
- EC_KEY *ec;
- EC_POINT *point = NULL;
-
- Require_EC_KEY(self, ec);
- if (!NIL_P(public_key))
- SafeRequire_EC_POINT(public_key, point);
-
- switch (EC_KEY_set_public_key(ec, point)) {
- case 1:
- break;
- case 0:
- if (point == NULL)
- break;
- default:
- ossl_raise(eECError, "EC_KEY_set_public_key");
- }
-
- return public_key;
-}
-
-/*
- * call-seq:
- * key.public_key? => true or false
- *
- * Both public_key? and private_key? may return false at the same time unlike other PKey classes.
- */
-static VALUE ossl_ec_key_is_public_key(VALUE self)
-{
- EC_KEY *ec;
-
- Require_EC_KEY(self, ec);
-
- return (EC_KEY_get0_public_key(ec) ? Qtrue : Qfalse);
-}
-
-/*
- * call-seq:
- * key.private_key? => true or false
- *
- * Both public_key? and private_key? may return false at the same time unlike other PKey classes.
- */
-static VALUE ossl_ec_key_is_private_key(VALUE self)
-{
- EC_KEY *ec;
-
- Require_EC_KEY(self, ec);
-
- return (EC_KEY_get0_private_key(ec) ? Qtrue : Qfalse);
-}
-
-static VALUE ossl_ec_key_to_string(VALUE self, int format)
-{
- EC_KEY *ec;
- BIO *out;
- int i = -1;
- int private = 0;
- EVP_CIPHER *cipher = NULL;
- char *password = NULL;
- VALUE str;
-
- Require_EC_KEY(self, ec);
-
- if (EC_KEY_get0_public_key(ec) == NULL)
- rb_raise(eECError, "can't export - no public key set");
-
- if (EC_KEY_check_key(ec) != 1)
- ossl_raise(eECError, "can't export - EC_KEY_check_key failed");
-
- if (EC_KEY_get0_private_key(ec))
- private = 1;
-
- if (!(out = BIO_new(BIO_s_mem())))
- ossl_raise(eECError, "BIO_new(BIO_s_mem())");
-
- switch(format) {
- case EXPORT_PEM:
- if (private) {
- if (cipher || password)
-/* BUG: finish cipher/password key export */
- rb_notimplement();
- i = PEM_write_bio_ECPrivateKey(out, ec, cipher, NULL, 0, NULL, password);
- } else {
- if (cipher || password)
- rb_raise(rb_eArgError, "encryption is not supported when exporting this key type");
-
- i = PEM_write_bio_EC_PUBKEY(out, ec);
- }
-
- break;
- case EXPORT_DER:
- if (private) {
- if (cipher || password)
- rb_raise(rb_eArgError, "encryption is not supported when exporting this key type");
-
- i = i2d_ECPrivateKey_bio(out, ec);
- } else {
- if (cipher || password)
- rb_raise(rb_eArgError, "encryption is not supported when exporting this key type");
-
- i = i2d_EC_PUBKEY_bio(out, ec);
- }
-
- break;
- default:
- BIO_free(out);
- rb_raise(rb_eRuntimeError, "unknown format (internal error)");
- }
-
- if (i != 1) {
- BIO_free(out);
- ossl_raise(eECError, "outlen=%d", i);
- }
-
- str = ossl_membio2str(out);
-
- return str;
-}
-
-/*
- * call-seq:
- * key.to_pem => String
- *
- * See the OpenSSL documentation for PEM_write_bio_ECPrivateKey()
- */
-static VALUE ossl_ec_key_to_pem(VALUE self)
-{
- return ossl_ec_key_to_string(self, EXPORT_PEM);
-}
-
-/*
- * call-seq:
- * key.to_der => String
- *
- * See the OpenSSL documentation for i2d_ECPrivateKey_bio()
- */
-static VALUE ossl_ec_key_to_der(VALUE self)
-{
- return ossl_ec_key_to_string(self, EXPORT_DER);
-}
-
-/*
- * call-seq:
- * key.to_text => String
- *
- * See the OpenSSL documentation for EC_KEY_print()
- */
-static VALUE ossl_ec_key_to_text(VALUE self)
-{
- EC_KEY *ec;
- BIO *out;
- VALUE str;
-
- Require_EC_KEY(self, ec);
- if (!(out = BIO_new(BIO_s_mem()))) {
- ossl_raise(eECError, "BIO_new(BIO_s_mem())");
- }
- if (!EC_KEY_print(out, ec, 0)) {
- BIO_free(out);
- ossl_raise(eECError, "EC_KEY_print");
- }
- str = ossl_membio2str(out);
-
- return str;
-}
-
-/*
- * call-seq:
- * key.generate_key => self
- *
- * See the OpenSSL documentation for EC_KEY_generate_key()
- */
-static VALUE ossl_ec_key_generate_key(VALUE self)
-{
- EC_KEY *ec;
-
- Require_EC_KEY(self, ec);
-
- if (EC_KEY_generate_key(ec) != 1)
- ossl_raise(eECError, "EC_KEY_generate_key");
-
- return self;
-}
-
-/*
- * call-seq:
- * key.check_key => true
- *
- * Raises an exception if the key is invalid.
- *
- * See the OpenSSL documentation for EC_KEY_check_key()
- */
-static VALUE ossl_ec_key_check_key(VALUE self)
-{
- EC_KEY *ec;
-
- Require_EC_KEY(self, ec);
-
- if (EC_KEY_check_key(ec) != 1)
- ossl_raise(eECError, "EC_KEY_check_key");
-
- return Qtrue;
-}
-
-/*
- * call-seq:
- * key.dh_compute_key(pubkey) => String
- *
- * See the OpenSSL documentation for ECDH_compute_key()
- */
-static VALUE ossl_ec_key_dh_compute_key(VALUE self, VALUE pubkey)
-{
- EC_KEY *ec;
- EC_POINT *point;
- int buf_len;
- VALUE str;
-
- Require_EC_KEY(self, ec);
- SafeRequire_EC_POINT(pubkey, point);
-
-/* BUG: need a way to figure out the maximum string size */
- buf_len = 1024;
- str = rb_str_new(0, buf_len);
-/* BUG: take KDF as a block */
- buf_len = ECDH_compute_key(RSTRING_PTR(str), buf_len, point, ec, NULL);
- if (buf_len < 0)
- ossl_raise(eECError, "ECDH_compute_key");
-
- rb_str_resize(str, buf_len);
-
- return str;
-}
-
-/* sign_setup */
-
-/*
- * call-seq:
- * key.dsa_sign_asn1(data) => String
- *
- * See the OpenSSL documentation for ECDSA_sign()
- */
-static VALUE ossl_ec_key_dsa_sign_asn1(VALUE self, VALUE data)
-{
- EC_KEY *ec;
- unsigned int buf_len;
- VALUE str;
-
- Require_EC_KEY(self, ec);
- StringValue(data);
-
- if (EC_KEY_get0_private_key(ec) == NULL)
- ossl_raise(eECError, "Private EC key needed!");
-
- str = rb_str_new(0, ECDSA_size(ec) + 16);
- if (ECDSA_sign(0, (unsigned char *) RSTRING_PTR(data), RSTRING_LEN(data), (unsigned char *) RSTRING_PTR(str), &buf_len, ec) != 1)
- ossl_raise(eECError, "ECDSA_sign");
-
- rb_str_resize(str, buf_len);
-
- return str;
-}
-
-/*
- * call-seq:
- * key.dsa_verify(data, sig) => true or false
- *
- * See the OpenSSL documentation for ECDSA_verify()
- */
-static VALUE ossl_ec_key_dsa_verify_asn1(VALUE self, VALUE data, VALUE sig)
-{
- EC_KEY *ec;
-
- Require_EC_KEY(self, ec);
- StringValue(data);
- StringValue(sig);
-
- switch (ECDSA_verify(0, (unsigned char *) RSTRING_PTR(data), RSTRING_LEN(data), (unsigned char *) RSTRING_PTR(sig), RSTRING_LEN(sig), ec)) {
- case 1: return Qtrue;
- case 0: return Qfalse;
- default: break;
- }
-
- ossl_raise(eECError, "ECDSA_verify");
-}
-
-static void ossl_ec_group_free(ossl_ec_group *ec_group)
-{
- if (!ec_group->dont_free && ec_group->group)
- EC_GROUP_clear_free(ec_group->group);
- free(ec_group);
-}
-
-static VALUE ossl_ec_group_alloc(VALUE klass)
-{
- ossl_ec_group *ec_group;
- VALUE obj;
-
- obj = Data_Make_Struct(klass, ossl_ec_group, 0, ossl_ec_group_free, ec_group);
-
- return obj;
-}
-
-/* call-seq:
- * OpenSSL::PKey::EC::Group.new("secp112r1")
- * OpenSSL::PKey::EC::Group.new(ec_group)
- * OpenSSL::PKey::EC::Group.new(pem_string)
- * OpenSSL::PKey::EC::Group.new(der_string)
- * OpenSSL::PKey::EC::Group.new(pem_file)
- * OpenSSL::PKey::EC::Group.new(der_file)
- * OpenSSL::PKey::EC::Group.new(:GFp_simple)
- * OpenSSL::PKey::EC::Group.new(:GFp_mult)
- * OpenSSL::PKey::EC::Group.new(:GFp_nist)
- * OpenSSL::PKey::EC::Group.new(:GF2m_simple)
- * OpenSSL::PKey::EC::Group.new(:GFp, bignum_p, bignum_a, bignum_b)
- * OpenSSL::PKey::EC::Group.new(:GF2m, bignum_p, bignum_a, bignum_b)
- *
- * See the OpenSSL documentation for EC_GROUP_*
- */
-static VALUE ossl_ec_group_initialize(int argc, VALUE *argv, VALUE self)
-{
- VALUE arg1, arg2, arg3, arg4;
- ossl_ec_group *ec_group;
- EC_GROUP *group = NULL;
-
- Data_Get_Struct(self, ossl_ec_group, ec_group);
- if (ec_group->group != NULL)
- rb_raise(rb_eRuntimeError, "EC_GROUP is already initialized");
-
- switch (rb_scan_args(argc, argv, "13", &arg1, &arg2, &arg3, &arg4)) {
- case 1:
- if (SYMBOL_P(arg1)) {
- const EC_METHOD *method = NULL;
- ID id = SYM2ID(arg1);
-
- if (id == s_GFp_simple) {
- method = EC_GFp_simple_method();
- } else if (id == s_GFp_mont) {
- method = EC_GFp_mont_method();
- } else if (id == s_GFp_nist) {
- method = EC_GFp_nist_method();
- } else if (id == s_GF2m_simple) {
- method = EC_GF2m_simple_method();
- }
-
- if (method) {
- if ((group = EC_GROUP_new(method)) == NULL)
- ossl_raise(eEC_GROUP, "EC_GROUP_new");
- } else {
- rb_raise(rb_eArgError, "unknown symbol, must be :GFp_simple, :GFp_mont, :GFp_nist or :GF2m_simple");
- }
- } else if (rb_obj_is_kind_of(arg1, cEC_GROUP)) {
- const EC_GROUP *arg1_group;
-
- SafeRequire_EC_GROUP(arg1, arg1_group);
- if ((group = EC_GROUP_dup(arg1_group)) == NULL)
- ossl_raise(eEC_GROUP, "EC_GROUP_dup");
- } else {
- BIO *in = ossl_obj2bio(arg1);
-
- group = PEM_read_bio_ECPKParameters(in, NULL, NULL, NULL);
- if (!group) {
- BIO_reset(in);
- group = d2i_ECPKParameters_bio(in, NULL);
- }
-
- BIO_free(in);
-
- if (!group) {
- const char *name = STR2CSTR(arg1);
- int nid = OBJ_sn2nid(name);
-
- if (nid == NID_undef)
- ossl_raise(eEC_GROUP, "unknown curve name (%s)", name);
-
- group = EC_GROUP_new_by_curve_name(nid);
- if (group == NULL)
- ossl_raise(eEC_GROUP, "unable to create curve (%s)", name);
-
- EC_GROUP_set_asn1_flag(group, OPENSSL_EC_NAMED_CURVE);
- EC_GROUP_set_point_conversion_form(group, POINT_CONVERSION_UNCOMPRESSED);
- }
- }
-
- break;
- case 4:
- if (SYMBOL_P(arg1)) {
- ID id = SYM2ID(arg1);
- EC_GROUP *(*new_curve)(const BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *) = NULL;
- const BIGNUM *p = GetBNPtr(arg2);
- const BIGNUM *a = GetBNPtr(arg3);
- const BIGNUM *b = GetBNPtr(arg4);
-
- if (id == s_GFp) {
- new_curve = EC_GROUP_new_curve_GFp;
- } else if (id == s_GF2m) {
- new_curve = EC_GROUP_new_curve_GF2m;
- } else {
- rb_raise(rb_eArgError, "unknown symbol, must be :GFp or :GF2m");
- }
-
- if ((group = new_curve(p, a, b, ossl_bn_ctx)) == NULL)
- ossl_raise(eEC_GROUP, "EC_GROUP_new_by_GF*");
- } else {
- rb_raise(rb_eArgError, "unknown argument, must be :GFp or :GF2m");
- }
-
- break;
- default:
- rb_raise(rb_eArgError, "wrong number of arguments");
- }
-
- if (group == NULL)
- ossl_raise(eEC_GROUP, "");
-
- ec_group->group = group;
-
- return self;
-}
-
-/* call-seq:
- * group1 == group2 => true | false
- *
- */
-static VALUE ossl_ec_group_eql(VALUE a, VALUE b)
-{
- EC_GROUP *group1 = NULL, *group2 = NULL;
-
- Require_EC_GROUP(a, group1);
- SafeRequire_EC_GROUP(b, group2);
-
- if (EC_GROUP_cmp(group1, group2, ossl_bn_ctx) == 1)
- return Qfalse;
-
- return Qtrue;
-}
-
-/* call-seq:
- * group.generator => ec_point
- *
- * See the OpenSSL documentation for EC_GROUP_get0_generator()
- */
-static VALUE ossl_ec_group_get_generator(VALUE self)
-{
- VALUE point_obj;
- EC_GROUP *group = NULL;
-
- Require_EC_GROUP(self, group);
-
- point_obj = ossl_ec_point_dup(EC_GROUP_get0_generator(group), self);
-
- return point_obj;
-}
-
-/* call-seq:
- * group.set_generator(generator, order, cofactor) => self
- *
- * See the OpenSSL documentation for EC_GROUP_set_generator()
- */
-static VALUE ossl_ec_group_set_generator(VALUE self, VALUE generator, VALUE order, VALUE cofactor)
-{
- EC_GROUP *group = NULL;
- const EC_POINT *point;
- const BIGNUM *o, *co;
-
- Require_EC_GROUP(self, group);
- SafeRequire_EC_POINT(generator, point);
- o = GetBNPtr(order);
- co = GetBNPtr(cofactor);
-
- if (EC_GROUP_set_generator(group, point, o, co) != 1)
- ossl_raise(eEC_GROUP, "EC_GROUP_set_generator");
-
- return self;
-}
-
-/* call-seq:
- * group.get_order => order_bn
- *
- * See the OpenSSL documentation for EC_GROUP_get_order()
- */
-static VALUE ossl_ec_group_get_order(VALUE self)
-{
- VALUE bn_obj;
- BIGNUM *bn;
- EC_GROUP *group = NULL;
-
- Require_EC_GROUP(self, group);
-
- bn_obj = ossl_bn_new(NULL);
- bn = GetBNPtr(bn_obj);
-
- if (EC_GROUP_get_order(group, bn, ossl_bn_ctx) != 1)
- ossl_raise(eEC_GROUP, "EC_GROUP_get_order");
-
- return bn_obj;
-}
-
-/* call-seq:
- * group.get_cofactor => cofactor_bn
- *
- * See the OpenSSL documentation for EC_GROUP_get_cofactor()
- */
-static VALUE ossl_ec_group_get_cofactor(VALUE self)
-{
- VALUE bn_obj;
- BIGNUM *bn;
- EC_GROUP *group = NULL;
-
- Require_EC_GROUP(self, group);
-
- bn_obj = ossl_bn_new(NULL);
- bn = GetBNPtr(bn_obj);
-
- if (EC_GROUP_get_cofactor(group, bn, ossl_bn_ctx) != 1)
- ossl_raise(eEC_GROUP, "EC_GROUP_get_cofactor");
-
- return bn_obj;
-}
-
-/* call-seq:
- * group.curve_name => String
- *
- * See the OpenSSL documentation for EC_GROUP_get_curve_name()
- */
-static VALUE ossl_ec_group_get_curve_name(VALUE self)
-{
- EC_GROUP *group = NULL;
- int nid;
-
- Get_EC_GROUP(self, group);
- if (group == NULL)
- return Qnil;
-
- nid = EC_GROUP_get_curve_name(group);
-
-/* BUG: an nid or asn1 object should be returned, maybe. */
- return rb_str_new2(OBJ_nid2sn(nid));
-}
-
-/* call-seq:
- * EC.builtin_curves => [[name, comment], ...]
- *
- * See the OpenSSL documentation for EC_builtin_curves()
- */
-static VALUE ossl_s_builtin_curves(VALUE self)
-{
- EC_builtin_curve *curves = NULL;
- int n;
- int crv_len = EC_get_builtin_curves(NULL, 0);
- VALUE ary, ret;
-
- curves = ALLOCA_N(EC_builtin_curve, crv_len);
- if (curves == NULL)
- return Qnil;
- if (!EC_get_builtin_curves(curves, crv_len))
- ossl_raise(rb_eRuntimeError, "EC_get_builtin_curves");
-
- ret = rb_ary_new2(crv_len);
-
- for (n = 0; n < crv_len; n++) {
- const char *sname = OBJ_nid2sn(curves[n].nid);
- const char *comment = curves[n].comment;
-
- ary = rb_ary_new2(2);
- rb_ary_push(ary, rb_str_new2(sname));
- rb_ary_push(ary, comment ? rb_str_new2(comment) : Qnil);
- rb_ary_push(ret, ary);
- }
-
- return ret;
-}
-
-/* call-seq:
- * group.asn1_flag => Fixnum
- *
- * See the OpenSSL documentation for EC_GROUP_get_asn1_flag()
- */
-static VALUE ossl_ec_group_get_asn1_flag(VALUE self)
-{
- EC_GROUP *group = NULL;
- int flag;
-
- Require_EC_GROUP(self, group);
-
- flag = EC_GROUP_get_asn1_flag(group);
-
- return INT2FIX(flag);
-}
-
-/* call-seq:
- * group.asn1_flag = Fixnum => Fixnum
- *
- * See the OpenSSL documentation for EC_GROUP_set_asn1_flag()
- */
-static VALUE ossl_ec_group_set_asn1_flag(VALUE self, VALUE flag_v)
-{
- EC_GROUP *group = NULL;
-
- Require_EC_GROUP(self, group);
-
- EC_GROUP_set_asn1_flag(group, NUM2INT(flag_v));
-
- return flag_v;
-}
-
-/* call-seq:
- * group.point_conversion_form => :uncompressed | :compressed | :hybrid
- *
- * See the OpenSSL documentation for EC_GROUP_get_point_conversion_form()
- */
-static VALUE ossl_ec_group_get_point_conversion_form(VALUE self)
-{
- EC_GROUP *group = NULL;
- point_conversion_form_t form;
- VALUE ret;
-
- Require_EC_GROUP(self, group);
-
- form = EC_GROUP_get_point_conversion_form(group);
-
- switch (form) {
- case POINT_CONVERSION_UNCOMPRESSED: ret = ID_uncompressed; break;
- case POINT_CONVERSION_COMPRESSED: ret = ID_compressed; break;
- case POINT_CONVERSION_HYBRID: ret = ID_hybrid; break;
- default: rb_raise(eEC_GROUP, "unsupported point conversion form: %d, this module should be updated", form);
- }
-
- return ID2SYM(ret);
-}
-
-/* call-seq:
- * group.point_conversion_form = form => form
- *
- * See the OpenSSL documentation for EC_GROUP_set_point_conversion_form()
- */
-static VALUE ossl_ec_group_set_point_conversion_form(VALUE self, VALUE form_v)
-{
- EC_GROUP *group = NULL;
- point_conversion_form_t form;
- ID form_id = SYM2ID(form_v);
-
- Require_EC_GROUP(self, group);
-
- if (form_id == ID_uncompressed) {
- form = POINT_CONVERSION_UNCOMPRESSED;
- } else if (form_id == ID_compressed) {
- form = POINT_CONVERSION_COMPRESSED;
- } else if (form_id == ID_hybrid) {
- form = POINT_CONVERSION_HYBRID;
- } else {
- rb_raise(rb_eArgError, "form must be :compressed, :uncompressed, or :hybrid");
- }
-
- EC_GROUP_set_point_conversion_form(group, form);
-
- return form_v;
-}
-
-/* call-seq:
- * group.seed => String or nil
- *
- * See the OpenSSL documentation for EC_GROUP_get0_seed()
- */
-static VALUE ossl_ec_group_get_seed(VALUE self)
-{
- EC_GROUP *group = NULL;
- size_t seed_len;
-
- Require_EC_GROUP(self, group);
-
- seed_len = EC_GROUP_get_seed_len(group);
-
- if (seed_len == 0)
- return Qnil;
-
- return rb_str_new(EC_GROUP_get0_seed(group), seed_len);
-}
-
-/* call-seq:
- * group.seed = seed => seed
- *
- * See the OpenSSL documentation for EC_GROUP_set_seed()
- */
-static VALUE ossl_ec_group_set_seed(VALUE self, VALUE seed)
-{
- EC_GROUP *group = NULL;
-
- Require_EC_GROUP(self, group);
- StringValue(seed);
-
- if (EC_GROUP_set_seed(group, RSTRING_PTR(seed), RSTRING_LEN(seed)) != RSTRING_LEN(seed))
- ossl_raise(eEC_GROUP, "EC_GROUP_set_seed");
-
- return seed;
-}
-
-/* get/set curve GFp, GF2m */
-
-/* call-seq:
- * group.degree => Fixnum
- *
- * See the OpenSSL documentation for EC_GROUP_get_degree()
- */
-static VALUE ossl_ec_group_get_degree(VALUE self)
-{
- EC_GROUP *group = NULL;
-
- Require_EC_GROUP(self, group);
-
- return INT2NUM(EC_GROUP_get_degree(group));
-}
-
-static VALUE ossl_ec_group_to_string(VALUE self, int format)
-{
- EC_GROUP *group;
- BIO *out;
- int i = -1;
- VALUE str;
-
- Get_EC_GROUP(self, group);
-
- if (!(out = BIO_new(BIO_s_mem())))
- ossl_raise(eEC_GROUP, "BIO_new(BIO_s_mem())");
-
- switch(format) {
- case EXPORT_PEM:
- i = PEM_write_bio_ECPKParameters(out, group);
- break;
- case EXPORT_DER:
- i = i2d_ECPKParameters_bio(out, group);
- break;
- default:
- BIO_free(out);
- rb_raise(rb_eRuntimeError, "unknown format (internal error)");
- }
-
- if (i != 1) {
- BIO_free(out);
- ossl_raise(eECError, NULL);
- }
-
- str = ossl_membio2str(out);
-
- return str;
-}
-
-/* call-seq:
- * group.to_pem => String
- *
- * See the OpenSSL documentation for PEM_write_bio_ECPKParameters()
- */
-static VALUE ossl_ec_group_to_pem(VALUE self)
-{
- return ossl_ec_group_to_string(self, EXPORT_PEM);
-}
-
-/* call-seq:
- * group.to_der => String
- *
- * See the OpenSSL documentation for i2d_ECPKParameters_bio()
- */
-static VALUE ossl_ec_group_to_der(VALUE self)
-{
- return ossl_ec_group_to_string(self, EXPORT_DER);
-}
-
-/* call-seq:
- * group.to_text => String
- *
- * See the OpenSSL documentation for ECPKParameters_print()
- */
-static VALUE ossl_ec_group_to_text(VALUE self)
-{
- EC_GROUP *group;
- BIO *out;
- VALUE str;
-
- Require_EC_GROUP(self, group);
- if (!(out = BIO_new(BIO_s_mem()))) {
- ossl_raise(eEC_GROUP, "BIO_new(BIO_s_mem())");
- }
- if (!ECPKParameters_print(out, group, 0)) {
- BIO_free(out);
- ossl_raise(eEC_GROUP, NULL);
- }
- str = ossl_membio2str(out);
-
- return str;
-}
-
-
-static void ossl_ec_point_free(ossl_ec_point *ec_point)
-{
- if (!ec_point->dont_free && ec_point->point)
- EC_POINT_clear_free(ec_point->point);
- free(ec_point);
-}
-
-static VALUE ossl_ec_point_alloc(VALUE klass)
-{
- ossl_ec_point *ec_point;
- VALUE obj;
-
- obj = Data_Make_Struct(klass, ossl_ec_point, 0, ossl_ec_point_free, ec_point);
-
- return obj;
-}
-
-/*
- * call-seq:
- * OpenSSL::PKey::EC::Point.new(point)
- * OpenSSL::PKey::EC::Point.new(group)
- * OpenSSL::PKey::EC::Point.new(group, bn)
- *
- * See the OpenSSL documentation for EC_POINT_*
- */
-static VALUE ossl_ec_point_initialize(int argc, VALUE *argv, VALUE self)
-{
- ossl_ec_point *ec_point;
- EC_POINT *point = NULL;
- VALUE arg1, arg2;
- VALUE group_v = Qnil;
- const EC_GROUP *group = NULL;
-
- Data_Get_Struct(self, ossl_ec_point, ec_point);
- if (ec_point->point)
- rb_raise(eEC_POINT, "EC_POINT already initialized");
-
- switch (rb_scan_args(argc, argv, "11", &arg1, &arg2)) {
- case 1:
- if (rb_obj_is_kind_of(arg1, cEC_POINT)) {
- const EC_POINT *arg_point;
-
- group_v = rb_iv_get(arg1, "@group");
- SafeRequire_EC_GROUP(group_v, group);
- SafeRequire_EC_POINT(arg1, arg_point);
-
- point = EC_POINT_dup(arg_point, group);
- } else if (rb_obj_is_kind_of(arg1, cEC_GROUP)) {
- group_v = arg1;
- SafeRequire_EC_GROUP(group_v, group);
-
- point = EC_POINT_new(group);
- } else {
- rb_raise(eEC_POINT, "wrong argument type: must be OpenSSL::PKey::EC::Point or OpenSSL::Pkey::EC::Group");
- }
-
- break;
- case 2:
- if (!rb_obj_is_kind_of(arg1, cEC_GROUP))
- rb_raise(rb_eArgError, "1st argument must be OpenSSL::PKey::EC::Group");
- group_v = arg1;
- SafeRequire_EC_GROUP(group_v, group);
-
- if (rb_obj_is_kind_of(arg2, cBN)) {
- const BIGNUM *bn = GetBNPtr(arg2);
-
- point = EC_POINT_bn2point(group, bn, NULL, ossl_bn_ctx);
- } else {
- BIO *in = ossl_obj2bio(arg1);
-
-/* BUG: finish me */
-
- BIO_free(in);
-
- if (point == NULL) {
- ossl_raise(eEC_POINT, "unknown type for 2nd arg");
- }
- }
- break;
- default:
- rb_raise(rb_eArgError, "wrong number of arguments");
- }
-
- if (point == NULL)
- ossl_raise(eEC_POINT, NULL);
-
- if (NIL_P(group_v))
- rb_raise(rb_eRuntimeError, "missing group (internal error)");
-
- ec_point->point = point;
-
- rb_iv_set(self, "@group", group_v);
-
- return self;
-}
-
-/*
- * call-seq:
- * point1 == point2 => true | false
- *
- */
-static VALUE ossl_ec_point_eql(VALUE a, VALUE b)
-{
- EC_POINT *point1, *point2;
- VALUE group_v1 = rb_iv_get(a, "@group");
- VALUE group_v2 = rb_iv_get(b, "@group");
- const EC_GROUP *group;
-
- if (ossl_ec_group_eql(group_v1, group_v2) == Qfalse)
- return Qfalse;
-
- Require_EC_POINT(a, point1);
- SafeRequire_EC_POINT(b, point2);
- SafeRequire_EC_GROUP(group_v1, group);
-
- if (EC_POINT_cmp(group, point1, point2, ossl_bn_ctx) == 1)
- return Qfalse;
-
- return Qtrue;
-}
-
-/*
- * call-seq:
- * point.infinity? => true | false
- *
- */
-static VALUE ossl_ec_point_is_at_infinity(VALUE self)
-{
- EC_POINT *point;
- VALUE group_v = rb_iv_get(self, "@group");
- const EC_GROUP *group;
-
- Require_EC_POINT(self, point);
- SafeRequire_EC_GROUP(group_v, group);
-
- switch (EC_POINT_is_at_infinity(group, point)) {
- case 1: return Qtrue;
- case 0: return Qfalse;
- default: ossl_raise(cEC_POINT, "EC_POINT_is_at_infinity");
- }
-}
-
-/*
- * call-seq:
- * point.on_curve? => true | false
- *
- */
-static VALUE ossl_ec_point_is_on_curve(VALUE self)
-{
- EC_POINT *point;
- VALUE group_v = rb_iv_get(self, "@group");
- const EC_GROUP *group;
-
- Require_EC_POINT(self, point);
- SafeRequire_EC_GROUP(group_v, group);
-
- switch (EC_POINT_is_on_curve(group, point, ossl_bn_ctx)) {
- case 1: return Qtrue;
- case 0: return Qfalse;
- default: ossl_raise(cEC_POINT, "EC_POINT_is_on_curve");
- }
-}
-
-/*
- * call-seq:
- * point.make_affine! => self
- *
- */
-static VALUE ossl_ec_point_make_affine(VALUE self)
-{
- EC_POINT *point;
- VALUE group_v = rb_iv_get(self, "@group");
- const EC_GROUP *group;
-
- Require_EC_POINT(self, point);
- SafeRequire_EC_GROUP(group_v, group);
-
- if (EC_POINT_make_affine(group, point, ossl_bn_ctx) != 1)
- ossl_raise(cEC_POINT, "EC_POINT_make_affine");
-
- return self;
-}
-
-/*
- * call-seq:
- * point.invert! => self
- *
- */
-static VALUE ossl_ec_point_invert(VALUE self)
-{
- EC_POINT *point;
- VALUE group_v = rb_iv_get(self, "@group");
- const EC_GROUP *group;
-
- Require_EC_POINT(self, point);
- SafeRequire_EC_GROUP(group_v, group);
-
- if (EC_POINT_invert(group, point, ossl_bn_ctx) != 1)
- ossl_raise(cEC_POINT, "EC_POINT_invert");
-
- return self;
-}
-
-/*
- * call-seq:
- * point.set_to_infinity! => self
- *
- */
-static VALUE ossl_ec_point_set_to_infinity(VALUE self)
-{
- EC_POINT *point;
- VALUE group_v = rb_iv_get(self, "@group");
- const EC_GROUP *group;
-
- Require_EC_POINT(self, point);
- SafeRequire_EC_GROUP(group_v, group);
-
- if (EC_POINT_set_to_infinity(group, point) != 1)
- ossl_raise(cEC_POINT, "EC_POINT_set_to_infinity");
-
- return self;
-}
-
-/*
- * call-seq:
- * point.to_bn => OpenSSL::BN
- *
- * See the OpenSSL documentation for EC_POINT_point2bn()
- */
-static VALUE ossl_ec_point_to_bn(VALUE self)
-{
- EC_POINT *point;
- VALUE bn_obj;
- VALUE group_v = rb_iv_get(self, "@group");
- const EC_GROUP *group;
- point_conversion_form_t form;
- BIGNUM *bn;
-
- Require_EC_POINT(self, point);
- SafeRequire_EC_GROUP(group_v, group);
-
- form = EC_GROUP_get_point_conversion_form(group);
-
- bn_obj = rb_obj_alloc(cBN);
- bn = GetBNPtr(bn_obj);
-
- if (EC_POINT_point2bn(group, point, form, bn, ossl_bn_ctx) == NULL)
- ossl_raise(eEC_POINT, "EC_POINT_point2bn");
-
- return bn_obj;
-}
-
-static void no_copy(VALUE klass)
-{
- rb_undef_method(klass, "copy");
- rb_undef_method(klass, "clone");
- rb_undef_method(klass, "dup");
- rb_undef_method(klass, "initialize_copy");
-}
-
-void Init_ossl_ec()
-{
-#ifdef DONT_NEED_RDOC_WORKAROUND
- mOSSL = rb_define_module("OpenSSL");
- mPKey = rb_define_module_under(mOSSL, "PKey");
-#endif
-
- eECError = rb_define_class_under(mPKey, "ECError", ePKeyError);
-
- cEC = rb_define_class_under(mPKey, "EC", cPKey);
- cEC_GROUP = rb_define_class_under(cEC, "Group", rb_cObject);
- cEC_POINT = rb_define_class_under(cEC, "Point", rb_cObject);
- eEC_GROUP = rb_define_class_under(cEC_GROUP, "Error", eOSSLError);
- eEC_POINT = rb_define_class_under(cEC_POINT, "Error", eOSSLError);
-
- s_GFp = rb_intern("GFp");
- s_GF2m = rb_intern("GF2m");
- s_GFp_simple = rb_intern("GFp_simple");
- s_GFp_mont = rb_intern("GFp_mont");
- s_GFp_nist = rb_intern("GFp_nist");
- s_GF2m_simple = rb_intern("GF2m_simple");
-
- ID_uncompressed = rb_intern("uncompressed");
- ID_compressed = rb_intern("compressed");
- ID_hybrid = rb_intern("hybrid");
-
-#ifdef OPENSSL_EC_NAMED_CURVE
- rb_define_const(cEC, "NAMED_CURVE", ULONG2NUM(OPENSSL_EC_NAMED_CURVE));
-#endif
-
- rb_define_singleton_method(cEC, "builtin_curves", ossl_s_builtin_curves, 0);
-
- rb_define_method(cEC, "initialize", ossl_ec_key_initialize, -1);
-/* copy/dup/cmp */
-
- rb_define_method(cEC, "group", ossl_ec_key_get_group, 0);
- rb_define_method(cEC, "group=", ossl_ec_key_set_group, 1);
- rb_define_method(cEC, "private_key", ossl_ec_key_get_private_key, 0);
- rb_define_method(cEC, "private_key=", ossl_ec_key_set_private_key, 1);
- rb_define_method(cEC, "public_key", ossl_ec_key_get_public_key, 0);
- rb_define_method(cEC, "public_key=", ossl_ec_key_set_public_key, 1);
- rb_define_method(cEC, "private_key?", ossl_ec_key_is_private_key, 0);
- rb_define_method(cEC, "public_key?", ossl_ec_key_is_public_key, 0);
-/* rb_define_method(cEC, "", ossl_ec_key_get_, 0);
- rb_define_method(cEC, "=", ossl_ec_key_set_ 1);
- set/get enc_flags
- set/get _conv_from
- set/get asn1_flag (can use ruby to call self.group.asn1_flag)
- set/get precompute_mult
-*/
- rb_define_method(cEC, "generate_key", ossl_ec_key_generate_key, 0);
- rb_define_method(cEC, "check_key", ossl_ec_key_check_key, 0);
-
- rb_define_method(cEC, "dh_compute_key", ossl_ec_key_dh_compute_key, 1);
- rb_define_method(cEC, "dsa_sign_asn1", ossl_ec_key_dsa_sign_asn1, 1);
- rb_define_method(cEC, "dsa_verify_asn1", ossl_ec_key_dsa_verify_asn1, 2);
-/* do_sign/do_verify */
-
- rb_define_method(cEC, "to_pem", ossl_ec_key_to_pem, 0);
- rb_define_method(cEC, "to_der", ossl_ec_key_to_der, 0);
- rb_define_method(cEC, "to_text", ossl_ec_key_to_text, 0);
-
-
- rb_define_alloc_func(cEC_GROUP, ossl_ec_group_alloc);
- rb_define_method(cEC_GROUP, "initialize", ossl_ec_group_initialize, -1);
- rb_define_method(cEC_GROUP, "eql?", ossl_ec_group_eql, 1);
- rb_define_alias(cEC_GROUP, "==", "eql?");
-/* copy/dup/cmp */
-
- rb_define_method(cEC_GROUP, "generator", ossl_ec_group_get_generator, 0);
- rb_define_method(cEC_GROUP, "set_generator", ossl_ec_group_set_generator, 3);
- rb_define_method(cEC_GROUP, "order", ossl_ec_group_get_order, 0);
- rb_define_method(cEC_GROUP, "cofactor", ossl_ec_group_get_cofactor, 0);
-
- rb_define_method(cEC_GROUP, "curve_name", ossl_ec_group_get_curve_name, 0);
-/* rb_define_method(cEC_GROUP, "curve_name=", ossl_ec_group_set_curve_name, 1); */
-
- rb_define_method(cEC_GROUP, "asn1_flag", ossl_ec_group_get_asn1_flag, 0);
- rb_define_method(cEC_GROUP, "asn1_flag=", ossl_ec_group_set_asn1_flag, 1);
-
- rb_define_method(cEC_GROUP, "point_conversion_form", ossl_ec_group_get_point_conversion_form, 0);
- rb_define_method(cEC_GROUP, "point_conversion_form=", ossl_ec_group_set_point_conversion_form, 1);
-
- rb_define_method(cEC_GROUP, "seed", ossl_ec_group_get_seed, 0);
- rb_define_method(cEC_GROUP, "seed=", ossl_ec_group_set_seed, 1);
-
-/* get/set GFp, GF2m */
-
- rb_define_method(cEC_GROUP, "degree", ossl_ec_group_get_degree, 0);
-
-/* check* */
-
-
- rb_define_method(cEC_GROUP, "to_pem", ossl_ec_group_to_pem, 0);
- rb_define_method(cEC_GROUP, "to_der", ossl_ec_group_to_der, 0);
- rb_define_method(cEC_GROUP, "to_text", ossl_ec_group_to_text, 0);
-
-
- rb_define_alloc_func(cEC_POINT, ossl_ec_point_alloc);
- rb_define_method(cEC_POINT, "initialize", ossl_ec_point_initialize, -1);
- rb_attr(cEC_POINT, rb_intern("group"), 1, 0, 0);
- rb_define_method(cEC_POINT, "eql?", ossl_ec_point_eql, 1);
- rb_define_alias(cEC_POINT, "==", "eql?");
-
- rb_define_method(cEC_POINT, "infinity?", ossl_ec_point_is_at_infinity, 0);
- rb_define_method(cEC_POINT, "on_curve?", ossl_ec_point_is_on_curve, 0);
- rb_define_method(cEC_POINT, "make_affine!", ossl_ec_point_make_affine, 0);
- rb_define_method(cEC_POINT, "invert!", ossl_ec_point_invert, 0);
- rb_define_method(cEC_POINT, "set_to_infinity!", ossl_ec_point_set_to_infinity, 0);
-/* all the other methods */
-
- rb_define_method(cEC_POINT, "to_bn", ossl_ec_point_to_bn, 0);
-
- no_copy(cEC);
- no_copy(cEC_GROUP);
- no_copy(cEC_POINT);
-}
-
-#else /* defined NO_EC */
-void Init_ossl_ec()
-{
-}
-#endif /* NO_EC */
diff --git a/ext/openssl/ossl_pkey_rsa.c b/ext/openssl/ossl_pkey_rsa.c
index 9ac69e7ded..69d69c76f4 100644
--- a/ext/openssl/ossl_pkey_rsa.c
+++ b/ext/openssl/ossl_pkey_rsa.c
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_pkey_rsa.c,v 1.5.2.4 2005/09/18 22:56:11 gotoyuzo Exp $
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -84,19 +84,9 @@ rsa_generate(int size, int exp)
NULL);
}
-/*
- * call-seq:
- * RSA.generate(size [, exponent]) -> rsa
- *
- * === Parameters
- * * +size+ is an integer representing the desired key size. Keys smaller than 1024 should be considered insecure.
- * * +exponent+ is an odd number normally 3, 17, or 65537.
- *
- */
static VALUE
ossl_rsa_s_generate(int argc, VALUE *argv, VALUE klass)
{
-/* why does this method exist? why can't initialize take an optional exponent? */
RSA *rsa;
VALUE size, exp;
VALUE obj;
@@ -114,20 +104,6 @@ ossl_rsa_s_generate(int argc, VALUE *argv, VALUE klass)
return obj;
}
-/*
- * call-seq:
- * RSA.new([size | encoded_key] [, pass]) -> rsa
- *
- * === Parameters
- * * +size+ is an integer representing the desired key size.
- * * +encoded_key+ is a string containing PEM or DER encoded key.
- * * +pass+ is an optional string with the password to decrypt the encoded key.
- *
- * === Examples
- * * RSA.new(2048) -> rsa
- * * RSA.new(File.read("rsa.pem")) -> rsa
- * * RSA.new(File.read("rsa.pem"), "mypassword") -> rsa
- */
static VALUE
ossl_rsa_initialize(int argc, VALUE *argv, VALUE self)
{
@@ -181,13 +157,6 @@ ossl_rsa_initialize(int argc, VALUE *argv, VALUE self)
return self;
}
-/*
- * call-seq:
- * rsa.public? -> true
- *
- * The return value is always true since every private key is also a public key.
- *
- */
static VALUE
ossl_rsa_is_public(VALUE self)
{
@@ -195,16 +164,12 @@ ossl_rsa_is_public(VALUE self)
GetPKeyRSA(self, pkey);
/*
- * This method should check for n and e. BUG.
+ * SURPRISE! :-))
+ * Every key is public at the same time!
*/
return Qtrue;
}
-/*
- * call-seq:
- * rsa.private? -> true | false
- *
- */
static VALUE
ossl_rsa_is_private(VALUE self)
{
@@ -215,18 +180,6 @@ ossl_rsa_is_private(VALUE self)
return (RSA_PRIVATE(self, pkey->pkey.rsa)) ? Qtrue : Qfalse;
}
-/*
- * call-seq:
- * rsa.to_pem([cipher, pass]) -> aString
- *
- * === Parameters
- * * +cipher+ is a Cipher object.
- * * +pass+ is a string.
- *
- * === Examples
- * * rsa.to_pem -> aString
- * * rsa.to_pem(cipher, pass) -> aString
- */
static VALUE
ossl_rsa_export(int argc, VALUE *argv, VALUE self)
{
@@ -266,11 +219,6 @@ ossl_rsa_export(int argc, VALUE *argv, VALUE self)
return str;
}
-/*
- * call-seq:
- * rsa.to_der -> aString
- *
- */
static VALUE
ossl_rsa_to_der(VALUE self)
{
@@ -288,7 +236,7 @@ ossl_rsa_to_der(VALUE self)
if((len = i2d_func(pkey->pkey.rsa, NULL)) <= 0)
ossl_raise(eRSAError, NULL);
str = rb_str_new(0, len);
- p = RSTRING_PTR(str);
+ p = RSTRING(str)->ptr;
if(i2d_func(pkey->pkey.rsa, &p) < 0)
ossl_raise(eRSAError, NULL);
ossl_str_adjust(str, p);
@@ -298,11 +246,6 @@ ossl_rsa_to_der(VALUE self)
#define ossl_rsa_buf_size(pkey) (RSA_size((pkey)->pkey.rsa)+16)
-/*
- * call-seq:
- * rsa.public_encrypt(string [, padding]) -> aString
- *
- */
static VALUE
ossl_rsa_public_encrypt(int argc, VALUE *argv, VALUE self)
{
@@ -315,20 +258,16 @@ ossl_rsa_public_encrypt(int argc, VALUE *argv, VALUE self)
pad = (argc == 1) ? RSA_PKCS1_PADDING : NUM2INT(padding);
StringValue(buffer);
str = rb_str_new(0, ossl_rsa_buf_size(pkey));
- buf_len = RSA_public_encrypt(RSTRING_LEN(buffer), RSTRING_PTR(buffer),
- RSTRING_PTR(str), pkey->pkey.rsa,
+ buf_len = RSA_public_encrypt(RSTRING(buffer)->len, RSTRING(buffer)->ptr,
+ RSTRING(str)->ptr, pkey->pkey.rsa,
pad);
if (buf_len < 0) ossl_raise(eRSAError, NULL);
- rb_str_set_len(str, buf_len);
+ RSTRING(str)->len = buf_len;
+ RSTRING(str)->ptr[buf_len] = 0;
return str;
}
-/*
- * call-seq:
- * rsa.public_decrypt(string [, padding]) -> aString
- *
- */
static VALUE
ossl_rsa_public_decrypt(int argc, VALUE *argv, VALUE self)
{
@@ -341,20 +280,16 @@ ossl_rsa_public_decrypt(int argc, VALUE *argv, VALUE self)
pad = (argc == 1) ? RSA_PKCS1_PADDING : NUM2INT(padding);
StringValue(buffer);
str = rb_str_new(0, ossl_rsa_buf_size(pkey));
- buf_len = RSA_public_decrypt(RSTRING_LEN(buffer), RSTRING_PTR(buffer),
- RSTRING_PTR(str), pkey->pkey.rsa,
+ buf_len = RSA_public_decrypt(RSTRING(buffer)->len, RSTRING(buffer)->ptr,
+ RSTRING(str)->ptr, pkey->pkey.rsa,
pad);
if (buf_len < 0) ossl_raise(eRSAError, NULL);
- rb_str_set_len(str, buf_len);
+ RSTRING(str)->len = buf_len;
+ RSTRING(str)->ptr[buf_len] = 0;
return str;
}
-/*
- * call-seq:
- * rsa.private_encrypt(string [, padding]) -> aString
- *
- */
static VALUE
ossl_rsa_private_encrypt(int argc, VALUE *argv, VALUE self)
{
@@ -370,21 +305,16 @@ ossl_rsa_private_encrypt(int argc, VALUE *argv, VALUE self)
pad = (argc == 1) ? RSA_PKCS1_PADDING : NUM2INT(padding);
StringValue(buffer);
str = rb_str_new(0, ossl_rsa_buf_size(pkey));
- buf_len = RSA_private_encrypt(RSTRING_LEN(buffer), RSTRING_PTR(buffer),
- RSTRING_PTR(str), pkey->pkey.rsa,
+ buf_len = RSA_private_encrypt(RSTRING(buffer)->len, RSTRING(buffer)->ptr,
+ RSTRING(str)->ptr, pkey->pkey.rsa,
pad);
if (buf_len < 0) ossl_raise(eRSAError, NULL);
- rb_str_set_len(str, buf_len);
+ RSTRING(str)->len = buf_len;
+ RSTRING(str)->ptr[buf_len] = 0;
return str;
}
-
-/*
- * call-seq:
- * rsa.private_decrypt(string [, padding]) -> aString
- *
- */
static VALUE
ossl_rsa_private_decrypt(int argc, VALUE *argv, VALUE self)
{
@@ -400,19 +330,17 @@ ossl_rsa_private_decrypt(int argc, VALUE *argv, VALUE self)
pad = (argc == 1) ? RSA_PKCS1_PADDING : NUM2INT(padding);
StringValue(buffer);
str = rb_str_new(0, ossl_rsa_buf_size(pkey));
- buf_len = RSA_private_decrypt(RSTRING_LEN(buffer), RSTRING_PTR(buffer),
- RSTRING_PTR(str), pkey->pkey.rsa,
+ buf_len = RSA_private_decrypt(RSTRING(buffer)->len, RSTRING(buffer)->ptr,
+ RSTRING(str)->ptr, pkey->pkey.rsa,
pad);
if (buf_len < 0) ossl_raise(eRSAError, NULL);
- rb_str_set_len(str, buf_len);
+ RSTRING(str)->len = buf_len;
+ RSTRING(str)->ptr[buf_len] = 0;
return str;
}
/*
- * call-seq:
- * rsa.params -> hash
- *
* Stores all parameters of key to the hash
* INSECURE: PRIVATE INFORMATIONS CAN LEAK OUT!!!
* Don't use :-)) (I's up to you)
@@ -440,9 +368,6 @@ ossl_rsa_get_params(VALUE self)
}
/*
- * call-seq:
- * rsa.to_text -> aString
- *
* Prints all parameters of key to buffer
* INSECURE: PRIVATE INFORMATIONS CAN LEAK OUT!!!
* Don't use :-)) (It's up to you)
@@ -468,9 +393,6 @@ ossl_rsa_to_text(VALUE self)
}
/*
- * call-seq:
- * rsa.public_key -> aRSA
- *
* Makes new instance RSA PUBLIC_KEY from PRIVATE_KEY
*/
static VALUE
@@ -493,6 +415,7 @@ ossl_rsa_to_public_key(VALUE self)
/*
* TODO: Test me
+extern BN_CTX *ossl_bn_ctx;
static VALUE
ossl_rsa_blinding_on(VALUE self)
@@ -536,11 +459,6 @@ 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);
@@ -585,9 +503,11 @@ Init_ossl_rsa()
}
#else /* defined NO_RSA */
+# warning >>> OpenSSL is compiled without RSA support <<<
void
Init_ossl_rsa()
{
+ rb_warning("OpenSSL is compiled without RSA support");
}
#endif /* NO_RSA */
diff --git a/ext/openssl/ossl_rand.c b/ext/openssl/ossl_rand.c
index ad830fbc98..ffd68966ca 100644
--- a/ext/openssl/ossl_rand.c
+++ b/ext/openssl/ossl_rand.c
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_rand.c,v 1.2 2003/09/17 09:05:02 gotoyuzo Exp $
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -27,150 +27,84 @@ VALUE eRandomError;
/*
* Private
*/
-
-/*
- * call-seq:
- * seed(str) -> str
- *
- */
static VALUE
ossl_rand_seed(VALUE self, VALUE str)
{
StringValue(str);
- RAND_seed(RSTRING_PTR(str), RSTRING_LEN(str));
+ RAND_seed(RSTRING(str)->ptr, RSTRING(str)->len);
return str;
}
-/*
- * call-seq:
- * add(str, entropy) -> self
- *
- */
-static VALUE
-ossl_rand_add(VALUE self, VALUE str, VALUE entropy)
-{
- StringValue(str);
- RAND_add(RSTRING_PTR(str), RSTRING_LEN(str), NUM2DBL(entropy));
-
- return self;
-}
-
-/*
- * call-seq:
- * load_random_file(filename) -> true
- *
- */
static VALUE
ossl_rand_load_file(VALUE self, VALUE filename)
{
SafeStringValue(filename);
- if(!RAND_load_file(RSTRING_PTR(filename), -1)) {
+ if(!RAND_load_file(RSTRING(filename)->ptr, -1)) {
ossl_raise(eRandomError, NULL);
}
return Qtrue;
}
-/*
- * call-seq:
- * write_random_file(filename) -> true
- *
- */
static VALUE
ossl_rand_write_file(VALUE self, VALUE filename)
{
SafeStringValue(filename);
- if (RAND_write_file(RSTRING_PTR(filename)) == -1) {
+ if (RAND_write_file(RSTRING(filename)->ptr) == -1) {
ossl_raise(eRandomError, NULL);
}
return Qtrue;
}
-/*
- * call-seq:
- * random_bytes(length) -> aString
- *
- */
static VALUE
ossl_rand_bytes(VALUE self, VALUE len)
{
VALUE str;
- int n = NUM2INT(len);
-
- str = rb_str_new(0, n);
- if (!RAND_bytes(RSTRING_PTR(str), n)) {
+
+ str = rb_str_new(0, FIX2INT(len));
+ if (!RAND_bytes(RSTRING(str)->ptr, FIX2INT(len))) {
ossl_raise(eRandomError, NULL);
}
return str;
}
-/*
- * call-seq:
- * pseudo_bytes(length) -> aString
- *
- */
static VALUE
ossl_rand_pseudo_bytes(VALUE self, VALUE len)
{
VALUE str;
- int n = NUM2INT(len);
- str = rb_str_new(0, n);
- if (!RAND_pseudo_bytes(RSTRING_PTR(str), n)) {
+ str = rb_str_new(0, FIX2INT(len));
+ if (!RAND_pseudo_bytes(RSTRING(str)->ptr, FIX2INT(len))) {
ossl_raise(eRandomError, NULL);
}
return str;
}
-/*
- * call-seq:
- * egd(filename) -> true
- *
- */
static VALUE
ossl_rand_egd(VALUE self, VALUE filename)
{
SafeStringValue(filename);
- if(!RAND_egd(RSTRING_PTR(filename))) {
+ if(!RAND_egd(RSTRING(filename)->ptr)) {
ossl_raise(eRandomError, NULL);
}
return Qtrue;
}
-/*
- * call-seq:
- * egd_bytes(filename, length) -> true
- *
- */
static VALUE
ossl_rand_egd_bytes(VALUE self, VALUE filename, VALUE len)
{
- long n = NUM2INT(len);
-
SafeStringValue(filename);
- if (!RAND_egd_bytes(RSTRING_PTR(filename), n)) {
+ if (!RAND_egd_bytes(RSTRING(filename)->ptr, FIX2INT(len))) {
ossl_raise(eRandomError, NULL);
}
return Qtrue;
}
-/*
- * call-seq:
- * status? => true | false
- *
- * Return true if the PRNG has been seeded with enough data, false otherwise.
- */
-static VALUE
-ossl_rand_status(VALUE self)
-{
- return RAND_status() ? Qtrue : Qfalse;
-}
-
#define DEFMETH(class, name, func, argc) \
rb_define_method(class, name, func, argc); \
rb_define_singleton_method(class, name, func, argc);
@@ -181,22 +115,16 @@ ossl_rand_status(VALUE self)
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);
DEFMETH(mRandom, "seed", ossl_rand_seed, 1);
- DEFMETH(mRandom, "random_add", ossl_rand_add, 2);
DEFMETH(mRandom, "load_random_file", ossl_rand_load_file, 1);
DEFMETH(mRandom, "write_random_file", ossl_rand_write_file, 1);
DEFMETH(mRandom, "random_bytes", ossl_rand_bytes, 1);
DEFMETH(mRandom, "pseudo_bytes", ossl_rand_pseudo_bytes, 1);
DEFMETH(mRandom, "egd", ossl_rand_egd, 1);
DEFMETH(mRandom, "egd_bytes", ossl_rand_egd_bytes, 2);
- DEFMETH(mRandom, "status?", ossl_rand_status, 0)
}
diff --git a/ext/openssl/ossl_rand.h b/ext/openssl/ossl_rand.h
index ce2ae0d129..4895267fb6 100644
--- a/ext/openssl/ossl_rand.h
+++ b/ext/openssl/ossl_rand.h
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_rand.h,v 1.1 2003/07/23 16:11:29 gotoyuzo Exp $
* '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 01b86fec27..e4889d6d3f 100644
--- a/ext/openssl/ossl_ssl.c
+++ b/ext/openssl/ossl_ssl.c
@@ -1,9 +1,8 @@
/*
- * $Id$
+ * $Id: ossl_ssl.c,v 1.13.2.11 2006/03/17 10:10:53 gotoyuzo Exp $
* 'OpenSSL for Ruby' project
* Copyright (C) 2000-2002 GOTOU Yuuzou <gotoyuzo@notwork.org>
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
- * Copyright (C) 2001-2007 Technorama Ltd. <oss-ruby@technorama.net>
* All rights reserved.
*/
/*
@@ -31,6 +30,9 @@ VALUE eSSLError;
VALUE cSSLContext;
VALUE cSSLSocket;
+/*
+ * SSLContext class
+ */
#define ossl_sslctx_set_cert(o,v) rb_iv_set((o),"@cert",(v))
#define ossl_sslctx_set_key(o,v) rb_iv_set((o),"@key",(v))
#define ossl_sslctx_set_client_ca(o,v) rb_iv_set((o),"@client_ca",(v))
@@ -63,12 +65,11 @@ VALUE cSSLSocket;
#define ossl_sslctx_get_tmp_dh_cb(o) rb_iv_get((o),"@tmp_dh_callback")
#define ossl_sslctx_get_sess_id_ctx(o) rb_iv_get((o),"@session_id_context")
-static const char *ossl_sslctx_attrs[] = {
+static char *ossl_sslctx_attrs[] = {
"cert", "key", "client_ca", "ca_file", "ca_path",
"timeout", "verify_mode", "verify_depth",
"verify_callback", "options", "cert_store", "extra_chain_cert",
"client_cert_cb", "tmp_dh_callback", "session_id_context",
- "session_get_cb", "session_new_cb", "session_remove_cb",
};
#define ossl_ssl_get_io(o) rb_iv_get((o),"@io")
@@ -85,10 +86,8 @@ static const char *ossl_sslctx_attrs[] = {
#define ossl_ssl_set_key(o,v) rb_iv_set((o),"@key",(v))
#define ossl_ssl_set_tmp_dh(o,v) rb_iv_set((o),"@tmp_dh",(v))
-static const char *ossl_ssl_attr_readers[] = { "io", "context", };
-static const char *ossl_ssl_attrs[] = { "sync_close", };
-
-ID ID_callback_state;
+static char *ossl_ssl_attr_readers[] = { "io", "context", };
+static char *ossl_ssl_attrs[] = { "sync_close", };
/*
* SSLContext class
@@ -142,13 +141,22 @@ ossl_sslctx_s_alloc(VALUE klass)
}
static VALUE
-ossl_sslctx_set_ssl_version(VALUE self, VALUE ssl_method)
+ossl_sslctx_initialize(int argc, VALUE *argv, VALUE self)
{
+ VALUE ssl_method;
SSL_METHOD *method = NULL;
- const char *s;
+ SSL_CTX *ctx;
int i;
+ char *s;
- SSL_CTX *ctx;
+ for(i = 0; i < numberof(ossl_sslctx_attrs); i++){
+ char buf[32];
+ snprintf(buf, sizeof(buf), "@%s", ossl_sslctx_attrs[i]);
+ rb_iv_set(self, buf, Qnil);
+ }
+ if (rb_scan_args(argc, argv, "01", &ssl_method) == 0){
+ return self;
+ }
if(TYPE(ssl_method) == T_SYMBOL)
s = rb_id2name(SYM2ID(ssl_method));
else
@@ -167,33 +175,6 @@ ossl_sslctx_set_ssl_version(VALUE self, VALUE ssl_method)
ossl_raise(eSSLError, "SSL_CTX_set_ssl_version:");
}
- return ssl_method;
-}
-
-/*
- * call-seq:
- * SSLContext.new => ctx
- * SSLContext.new(:TLSv1) => ctx
- * SSLContext.new("SSLv23_client") => ctx
- *
- * You can get a list of valid methods with OpenSSL::SSL::SSLContext::METHODS
- */
-static VALUE
-ossl_sslctx_initialize(int argc, VALUE *argv, VALUE self)
-{
- VALUE ssl_method;
- int i;
-
- for(i = 0; i < numberof(ossl_sslctx_attrs); i++){
- char buf[32];
- snprintf(buf, sizeof(buf), "@%s", ossl_sslctx_attrs[i]);
- rb_iv_set(self, buf, Qnil);
- }
- if (rb_scan_args(argc, argv, "01", &ssl_method) == 0){
- return self;
- }
- ossl_sslctx_set_ssl_version(self, ssl_method);
-
return self;
}
@@ -270,8 +251,6 @@ ossl_tmp_dh_callback(SSL *ssl, int is_export, int keylength)
static DH*
ossl_default_tmp_dh_callback(SSL *ssl, int is_export, int keylength)
{
- rb_warning("using default DH parameters.");
-
switch(keylength){
case 512:
return OSSL_DEFAULT_DH_512;
@@ -295,143 +274,6 @@ ossl_ssl_verify_callback(int preverify_ok, X509_STORE_CTX *ctx)
}
static VALUE
-ossl_call_session_get_cb(VALUE ary)
-{
- VALUE ssl_obj, sslctx_obj, cb, ret;
-
- Check_Type(ary, T_ARRAY);
- ssl_obj = rb_ary_entry(ary, 0);
-
- sslctx_obj = rb_iv_get(ssl_obj, "@context");
- if (NIL_P(sslctx_obj)) return Qnil;
- cb = rb_iv_get(sslctx_obj, "@session_get_cb");
- if (NIL_P(cb)) return Qnil;
-
- return rb_funcall(cb, rb_intern("call"), 1, ary);
-}
-
-/* this method is currently only called for servers (in OpenSSL <= 0.9.8e) */
-static SSL_SESSION *
-ossl_sslctx_session_get_cb(SSL *ssl, unsigned char *buf, int len, int *copy)
-{
- VALUE ary, ssl_obj, ret_obj;
- SSL_SESSION *sess;
- void *ptr;
- int state = 0;
-
- OSSL_Debug("SSL SESSION get callback entered");
- if ((ptr = SSL_get_ex_data(ssl, ossl_ssl_ex_ptr_idx)) == NULL)
- return NULL;
- ssl_obj = (VALUE)ptr;
- ary = rb_ary_new2(2);
- rb_ary_push(ary, ssl_obj);
- rb_ary_push(ary, rb_str_new(buf, len));
-
- ret_obj = rb_protect((VALUE(*)_((VALUE)))ossl_call_session_get_cb, ary, &state);
- if (state) {
- rb_ivar_set(ssl_obj, ID_callback_state, INT2NUM(state));
- return NULL;
- }
- if (!rb_obj_is_instance_of(ret_obj, cSSLSession))
- return NULL;
-
- SafeGetSSLSession(ret_obj, sess);
- *copy = 1;
-
- return sess;
-}
-
-static VALUE
-ossl_call_session_new_cb(VALUE ary)
-{
- VALUE ssl_obj, sslctx_obj, cb, ret;
-
- Check_Type(ary, T_ARRAY);
- ssl_obj = rb_ary_entry(ary, 0);
-
- sslctx_obj = rb_iv_get(ssl_obj, "@context");
- if (NIL_P(sslctx_obj)) return Qnil;
- cb = rb_iv_get(sslctx_obj, "@session_new_cb");
- if (NIL_P(cb)) return Qnil;
-
- return rb_funcall(cb, rb_intern("call"), 1, ary);
-}
-
-/* return 1 normal. return 0 removes the session */
-static int
-ossl_sslctx_session_new_cb(SSL *ssl, SSL_SESSION *sess)
-{
- VALUE ary, ssl_obj, sess_obj, ret_obj;
- void *ptr;
- int state = 0;
-
- OSSL_Debug("SSL SESSION new callback entered");
-
- if ((ptr = SSL_get_ex_data(ssl, ossl_ssl_ex_ptr_idx)) == NULL)
- return 1;
- ssl_obj = (VALUE)ptr;
- sess_obj = rb_obj_alloc(cSSLSession);
- CRYPTO_add(&sess->references, 1, CRYPTO_LOCK_SSL_SESSION);
- DATA_PTR(sess_obj) = sess;
-
- ary = rb_ary_new2(2);
- rb_ary_push(ary, ssl_obj);
- rb_ary_push(ary, sess_obj);
-
- ret_obj = rb_protect((VALUE(*)_((VALUE)))ossl_call_session_new_cb, ary, &state);
- if (state) {
- rb_ivar_set(ssl_obj, ID_callback_state, INT2NUM(state));
- return 0; /* what should be returned here??? */
- }
-
- return RTEST(ret_obj) ? 1 : 0;
-}
-
-static VALUE
-ossl_call_session_remove_cb(VALUE ary)
-{
- VALUE sslctx_obj, cb, ret;
-
- Check_Type(ary, T_ARRAY);
- sslctx_obj = rb_ary_entry(ary, 0);
-
- cb = rb_iv_get(sslctx_obj, "@session_remove_cb");
- if (NIL_P(cb)) return Qnil;
-
- return rb_funcall(cb, rb_intern("call"), 1, ary);
-}
-
-static void
-ossl_sslctx_session_remove_cb(SSL_CTX *ctx, SSL_SESSION *sess)
-{
- VALUE ary, sslctx_obj, sess_obj, ret_obj;
- void *ptr;
- int state = 0;
-
- OSSL_Debug("SSL SESSION remove callback entered");
-
- if ((ptr = SSL_CTX_get_ex_data(ctx, ossl_ssl_ex_ptr_idx)) == NULL)
- return;
- sslctx_obj = (VALUE)ptr;
- sess_obj = rb_obj_alloc(cSSLSession);
- CRYPTO_add(&sess->references, 1, CRYPTO_LOCK_SSL_SESSION);
- DATA_PTR(sess_obj) = sess;
-
- ary = rb_ary_new2(2);
- rb_ary_push(ary, sslctx_obj);
- rb_ary_push(ary, sess_obj);
-
- ret_obj = rb_protect((VALUE(*)_((VALUE)))ossl_call_session_new_cb, ary, &state);
- if (state) {
-/*
- the SSL_CTX is frozen, nowhere to save state.
- there is no common accessor method to check it either.
- rb_ivar_set(sslctx_obj, ID_callback_state, INT2NUM(state));
-*/
- }
-}
-
-static VALUE
ossl_sslctx_add_extra_chain_cert_i(VALUE i, VALUE arg)
{
X509 *x509;
@@ -446,14 +288,6 @@ ossl_sslctx_add_extra_chain_cert_i(VALUE i, VALUE arg)
return i;
}
-/*
- * call-seq:
- * ctx.setup => Qtrue # first time
- * ctx.setup => nil # thereafter
- *
- * This method is called automatically when a new SSLSocket is created.
- * Normally you do not need to call this method (unless you are writing an extension in C).
- */
static VALUE
ossl_sslctx_setup(VALUE self)
{
@@ -473,10 +307,10 @@ ossl_sslctx_setup(VALUE self)
SSL_CTX_set_tmp_dh_callback(ctx, ossl_tmp_dh_callback);
}
else{
+ rb_warning("using default DH parameters.");
SSL_CTX_set_tmp_dh_callback(ctx, ossl_default_tmp_dh_callback);
}
#endif
- SSL_CTX_set_ex_data(ctx, ossl_ssl_ex_ptr_idx, (void*)self);
val = ossl_sslctx_get_cert_store(self);
if(!NIL_P(val)){
@@ -493,7 +327,7 @@ ossl_sslctx_setup(VALUE self)
val = ossl_sslctx_get_extra_cert(self);
if(!NIL_P(val)){
- rb_block_call(val, rb_intern("each"), 0, 0, ossl_sslctx_add_extra_chain_cert_i, self);
+ rb_iterate(rb_each, val, ossl_sslctx_add_extra_chain_cert_i, self);
}
/* private key may be bundled in certificate file. */
@@ -518,8 +352,8 @@ ossl_sslctx_setup(VALUE self)
val = ossl_sslctx_get_client_ca(self);
if(!NIL_P(val)){
if(TYPE(val) == T_ARRAY){
- for(i = 0; i < RARRAY_LEN(val); i++){
- client_ca = GetX509CertPtr(RARRAY_PTR(val)[i]);
+ for(i = 0; i < RARRAY(val)->len; i++){
+ client_ca = GetX509CertPtr(RARRAY(val)->ptr[i]);
if (!SSL_CTX_add_client_CA(ctx, client_ca)){
/* Copies X509_NAME => FREE it. */
ossl_raise(eSSLError, "SSL_CTX_add_client_CA");
@@ -563,24 +397,12 @@ ossl_sslctx_setup(VALUE self)
val = ossl_sslctx_get_sess_id_ctx(self);
if (!NIL_P(val)){
StringValue(val);
- if (!SSL_CTX_set_session_id_context(ctx, RSTRING_PTR(val),
- RSTRING_LEN(val))){
- ossl_raise(eSSLError, "SSL_CTX_set_session_id_context:");
+ if (!SSL_CTX_set_session_id_context(ctx, RSTRING(val)->ptr,
+ RSTRING(val)->len)){
+ ossl_raise(eSSLError, "SSL_CTX_set_session_id_context:");
}
}
- if (RTEST(rb_iv_get(self, "@session_get_cb"))) {
- SSL_CTX_sess_set_get_cb(ctx, ossl_sslctx_session_get_cb);
- OSSL_Debug("SSL SESSION get callback added");
- }
- if (RTEST(rb_iv_get(self, "@session_new_cb"))) {
- SSL_CTX_sess_set_new_cb(ctx, ossl_sslctx_session_new_cb);
- OSSL_Debug("SSL SESSION new callback added");
- }
- if (RTEST(rb_iv_get(self, "@session_remove_cb"))) {
- SSL_CTX_sess_set_remove_cb(ctx, ossl_sslctx_session_remove_cb);
- OSSL_Debug("SSL SESSION remove callback added");
- }
return Qtrue;
}
@@ -600,10 +422,6 @@ ossl_ssl_cipher_to_ary(SSL_CIPHER *cipher)
return ary;
}
-/*
- * call-seq:
- * ctx.ciphers => [[name, version, bits, alg_bits], ...]
- */
static VALUE
ossl_sslctx_get_ciphers(VALUE self)
{
@@ -632,12 +450,6 @@ ossl_sslctx_get_ciphers(VALUE self)
return ary;
}
-/*
- * call-seq:
- * ctx.ciphers = "cipher1:cipher2:..."
- * ctx.ciphers = [name, ...]
- * ctx.ciphers = [[name, version, bits, alg_bits], ...]
- */
static VALUE
ossl_sslctx_set_ciphers(VALUE self, VALUE v)
{
@@ -650,12 +462,12 @@ ossl_sslctx_set_ciphers(VALUE self, VALUE v)
return v;
else if (TYPE(v) == T_ARRAY) {
str = rb_str_new(0, 0);
- for (i = 0; i < RARRAY_LEN(v); i++) {
+ for (i = 0; i < RARRAY(v)->len; i++) {
elem = rb_ary_entry(v, i);
if (TYPE(elem) == T_ARRAY) elem = rb_ary_entry(elem, 0);
elem = rb_String(elem);
rb_str_append(str, elem);
- if (i < RARRAY_LEN(v)-1) rb_str_cat2(str, ":");
+ if (i < RARRAY(v)->len-1) rb_str_cat2(str, ":");
}
} else {
str = v;
@@ -667,173 +479,13 @@ ossl_sslctx_set_ciphers(VALUE self, VALUE v)
ossl_raise(eSSLError, "SSL_CTX is not initialized.");
return Qnil;
}
- if (!SSL_CTX_set_cipher_list(ctx, RSTRING_PTR(str))) {
+ if (!SSL_CTX_set_cipher_list(ctx, RSTRING(str)->ptr)) {
ossl_raise(eSSLError, "SSL_CTX_set_cipher_list:");
}
return v;
}
-
-/*
- * call-seq:
- * ctx.session_add(session) -> true | false
- *
- */
-static VALUE
-ossl_sslctx_session_add(VALUE self, VALUE arg)
-{
- SSL_CTX *ctx;
- SSL_SESSION *sess;
-
- Data_Get_Struct(self, SSL_CTX, ctx);
- SafeGetSSLSession(arg, sess);
-
- return SSL_CTX_add_session(ctx, sess) == 1 ? Qtrue : Qfalse;
-}
-
-/*
- * call-seq:
- * ctx.session_remove(session) -> true | false
- *
- */
-static VALUE
-ossl_sslctx_session_remove(VALUE self, VALUE arg)
-{
- SSL_CTX *ctx;
- SSL_SESSION *sess;
-
- Data_Get_Struct(self, SSL_CTX, ctx);
- SafeGetSSLSession(arg, sess);
-
- return SSL_CTX_remove_session(ctx, sess) == 1 ? Qtrue : Qfalse;
-}
-
-/*
- * call-seq:
- * ctx.session_cache_mode -> integer
- *
- */
-static VALUE
-ossl_sslctx_get_session_cache_mode(VALUE self)
-{
- SSL_CTX *ctx;
-
- Data_Get_Struct(self, SSL_CTX, ctx);
-
- return LONG2NUM(SSL_CTX_get_session_cache_mode(ctx));
-}
-
-/*
- * call-seq:
- * ctx.session_cache_mode=(integer) -> integer
- *
- */
-static VALUE
-ossl_sslctx_set_session_cache_mode(VALUE self, VALUE arg)
-{
- SSL_CTX *ctx;
-
- Data_Get_Struct(self, SSL_CTX, ctx);
-
- SSL_CTX_set_session_cache_mode(ctx, NUM2LONG(arg));
-
- return arg;
-}
-
-/*
- * call-seq:
- * ctx.session_cache_size -> integer
- *
- */
-static VALUE
-ossl_sslctx_get_session_cache_size(VALUE self)
-{
- SSL_CTX *ctx;
-
- Data_Get_Struct(self, SSL_CTX, ctx);
-
- return LONG2NUM(SSL_CTX_sess_get_cache_size(ctx));
-}
-
-/*
- * call-seq:
- * ctx.session_cache_size=(integer) -> integer
- *
- */
-static VALUE
-ossl_sslctx_set_session_cache_size(VALUE self, VALUE arg)
-{
- SSL_CTX *ctx;
-
- Data_Get_Struct(self, SSL_CTX, ctx);
-
- SSL_CTX_sess_set_cache_size(ctx, NUM2LONG(arg));
-
- return arg;
-}
-
-/*
- * call-seq:
- * ctx.session_cache_stats -> Hash
- *
- */
-static VALUE
-ossl_sslctx_get_session_cache_stats(VALUE self)
-{
- SSL_CTX *ctx;
- VALUE hash;
-
- Data_Get_Struct(self, SSL_CTX, ctx);
-
- hash = rb_hash_new();
- rb_hash_aset(hash, ID2SYM(rb_intern("cache_num")), LONG2NUM(SSL_CTX_sess_number(ctx)));
- rb_hash_aset(hash, ID2SYM(rb_intern("connect")), LONG2NUM(SSL_CTX_sess_connect(ctx)));
- rb_hash_aset(hash, ID2SYM(rb_intern("connect_good")), LONG2NUM(SSL_CTX_sess_connect_good(ctx)));
- rb_hash_aset(hash, ID2SYM(rb_intern("connect_renegotiate")), LONG2NUM(SSL_CTX_sess_connect_renegotiate(ctx)));
- rb_hash_aset(hash, ID2SYM(rb_intern("accept")), LONG2NUM(SSL_CTX_sess_accept(ctx)));
- rb_hash_aset(hash, ID2SYM(rb_intern("accept_good")), LONG2NUM(SSL_CTX_sess_accept_good(ctx)));
- rb_hash_aset(hash, ID2SYM(rb_intern("accept_renegotiate")), LONG2NUM(SSL_CTX_sess_accept_renegotiate(ctx)));
- rb_hash_aset(hash, ID2SYM(rb_intern("cache_hits")), LONG2NUM(SSL_CTX_sess_hits(ctx)));
- rb_hash_aset(hash, ID2SYM(rb_intern("cb_hits")), LONG2NUM(SSL_CTX_sess_cb_hits(ctx)));
- rb_hash_aset(hash, ID2SYM(rb_intern("cache_misses")), LONG2NUM(SSL_CTX_sess_misses(ctx)));
- rb_hash_aset(hash, ID2SYM(rb_intern("cache_full")), LONG2NUM(SSL_CTX_sess_cache_full(ctx)));
- rb_hash_aset(hash, ID2SYM(rb_intern("timeouts")), LONG2NUM(SSL_CTX_sess_timeouts(ctx)));
-
- return hash;
-}
-
-
-/*
- * call-seq:
- * ctx.flush_sessions(time | nil) -> self
- *
- */
-static VALUE
-ossl_sslctx_flush_sessions(int argc, VALUE *argv, VALUE self)
-{
- VALUE arg1;
- SSL_CTX *ctx;
- time_t tm = 0;
- int cb_state;
-
- rb_scan_args(argc, argv, "01", &arg1);
-
- Data_Get_Struct(self, SSL_CTX, ctx);
-
- if (NIL_P(arg1)) {
- tm = time(0);
- } else if (rb_obj_is_instance_of(arg1, rb_cTime)) {
- tm = NUM2LONG(rb_funcall(arg1, rb_intern("to_i"), 0));
- } else {
- rb_raise(rb_eArgError, "arg must be Time or nil");
- }
-
- SSL_CTX_flush_sessions(ctx, tm);
-
- return self;
-}
-
/*
* SSLSocket class
*/
@@ -859,20 +511,6 @@ ossl_ssl_s_alloc(VALUE klass)
return Data_Wrap_Struct(klass, 0, ossl_ssl_free, NULL);
}
-/*
- * call-seq:
- * SSLSocket.new(io) => aSSLSocket
- * SSLSocket.new(io, ctx) => aSSLSocket
- *
- * === Parameters
- * * +io+ is a real ruby IO object. Not an IO like object that responds to read/write.
- * * +ctx+ is an OpenSSLSSL::SSLContext.
- *
- * The OpenSSL::Buffering module provides additional IO methods.
- *
- * This method will freeze the SSLContext if one is provided;
- * however, session management is still allowed in the frozen SSLContext.
- */
static VALUE
ossl_ssl_initialize(int argc, VALUE *argv, VALUE self)
{
@@ -898,7 +536,7 @@ ossl_ssl_setup(VALUE self)
VALUE io, v_ctx, cb;
SSL_CTX *ctx;
SSL *ssl;
- rb_io_t *fptr;
+ OpenFile *fptr;
Data_Get_Struct(self, SSL, ssl);
if(!ssl){
@@ -915,7 +553,7 @@ ossl_ssl_setup(VALUE self)
GetOpenFile(io, fptr);
rb_io_check_readable(fptr);
rb_io_check_writable(fptr);
- SSL_set_fd(ssl, TO_SOCKET(FPTR_TO_FD(fptr)));
+ SSL_set_fd(ssl, TO_SOCKET(fileno(fptr->f)));
SSL_set_ex_data(ssl, ossl_ssl_ex_ptr_idx, (void*)self);
cb = ossl_sslctx_get_verify_cb(v_ctx);
SSL_set_ex_data(ssl, ossl_ssl_ex_vcb_idx, (void*)cb);
@@ -929,85 +567,61 @@ ossl_ssl_setup(VALUE self)
}
#ifdef _WIN32
-#define ssl_get_error(ssl, ret) (errno = WSAGetLastError(), SSL_get_error(ssl, ret))
+#define ssl_get_error(ssl, ret) \
+ (errno = WSAGetLastError(), SSL_get_error(ssl, ret))
#else
#define ssl_get_error(ssl, ret) SSL_get_error(ssl, ret)
#endif
static VALUE
-ossl_start_ssl(VALUE self, int (*func)(), const char *funcname)
+ossl_start_ssl(VALUE self, int (*func)())
{
SSL *ssl;
- rb_io_t *fptr;
- int ret, ret2;
- VALUE cb_state;
-
- rb_ivar_set(self, ID_callback_state, Qnil);
+ OpenFile *fptr;
+ int ret;
Data_Get_Struct(self, SSL, ssl);
GetOpenFile(ossl_ssl_get_io(self), fptr);
for(;;){
if((ret = func(ssl)) > 0) break;
- switch((ret2 = ssl_get_error(ssl, ret))){
+ switch(ssl_get_error(ssl, ret)){
case SSL_ERROR_WANT_WRITE:
- rb_io_wait_writable(FPTR_TO_FD(fptr));
+ rb_io_wait_writable(fileno(fptr->f));
continue;
case SSL_ERROR_WANT_READ:
- rb_io_wait_readable(FPTR_TO_FD(fptr));
+ rb_io_wait_readable(fileno(fptr->f));
continue;
case SSL_ERROR_SYSCALL:
- if (errno) rb_sys_fail(funcname);
- ossl_raise(eSSLError, "%s SYSCALL returned=%d errno=%d state=%s", funcname, ret2, errno, SSL_state_string_long(ssl));
+ if (errno) rb_sys_fail(0);
default:
- ossl_raise(eSSLError, "%s returned=%d errno=%d state=%s", funcname, ret2, errno, SSL_state_string_long(ssl));
+ ossl_raise(eSSLError, NULL);
}
}
- cb_state = rb_ivar_get(self, ID_callback_state);
- if (!NIL_P(cb_state))
- rb_jump_tag(NUM2INT(cb_state));
-
return self;
}
-/*
- * call-seq:
- * ssl.connect => self
- */
static VALUE
ossl_ssl_connect(VALUE self)
{
ossl_ssl_setup(self);
- return ossl_start_ssl(self, SSL_connect, "SSL_connect");
+ return ossl_start_ssl(self, SSL_connect);
}
-/*
- * call-seq:
- * ssl.accept => self
- */
static VALUE
ossl_ssl_accept(VALUE self)
{
ossl_ssl_setup(self);
- return ossl_start_ssl(self, SSL_accept, "SSL_accept");
+ return ossl_start_ssl(self, SSL_accept);
}
-/*
- * call-seq:
- * ssl.sysread(length) => string
- * ssl.sysread(length, buffer) => buffer
- *
- * === Parameters
- * * +length+ is a positive integer.
- * * +buffer+ is a string used to store the result.
- */
static VALUE
ossl_ssl_read(int argc, VALUE *argv, VALUE self)
{
SSL *ssl;
int ilen, nread = 0;
VALUE len, str;
- rb_io_t *fptr;
+ OpenFile *fptr;
rb_scan_args(argc, argv, "11", &len, &str);
ilen = NUM2INT(len);
@@ -1023,19 +637,19 @@ ossl_ssl_read(int argc, VALUE *argv, VALUE self)
GetOpenFile(ossl_ssl_get_io(self), fptr);
if (ssl) {
if(SSL_pending(ssl) <= 0)
- rb_thread_wait_fd(FPTR_TO_FD(fptr));
+ rb_thread_wait_fd(fileno(fptr->f));
for (;;){
- nread = SSL_read(ssl, RSTRING_PTR(str), RSTRING_LEN(str));
+ nread = SSL_read(ssl, RSTRING(str)->ptr, RSTRING(str)->len);
switch(ssl_get_error(ssl, nread)){
case SSL_ERROR_NONE:
goto end;
case SSL_ERROR_ZERO_RETURN:
rb_eof_error();
case SSL_ERROR_WANT_WRITE:
- rb_io_wait_writable(FPTR_TO_FD(fptr));
+ rb_io_wait_writable(fileno(fptr->f));
continue;
case SSL_ERROR_WANT_READ:
- rb_io_wait_readable(FPTR_TO_FD(fptr));
+ rb_io_wait_readable(fileno(fptr->f));
continue;
case SSL_ERROR_SYSCALL:
if(ERR_peek_error() == 0 && nread == 0) rb_eof_error();
@@ -1052,22 +666,19 @@ ossl_ssl_read(int argc, VALUE *argv, VALUE self)
}
end:
- rb_str_set_len(str, nread);
+ RSTRING(str)->len = nread;
+ RSTRING(str)->ptr[nread] = 0;
OBJ_TAINT(str);
return str;
}
-/*
- * call-seq:
- * ssl.syswrite(string) => integer
- */
static VALUE
ossl_ssl_write(VALUE self, VALUE str)
{
SSL *ssl;
int nwrite = 0;
- rb_io_t *fptr;
+ OpenFile *fptr;
StringValue(str);
Data_Get_Struct(self, SSL, ssl);
@@ -1075,15 +686,15 @@ ossl_ssl_write(VALUE self, VALUE str)
if (ssl) {
for (;;){
- nwrite = SSL_write(ssl, RSTRING_PTR(str), RSTRING_LEN(str));
+ nwrite = SSL_write(ssl, RSTRING(str)->ptr, RSTRING(str)->len);
switch(ssl_get_error(ssl, nwrite)){
case SSL_ERROR_NONE:
goto end;
case SSL_ERROR_WANT_WRITE:
- rb_io_wait_writable(FPTR_TO_FD(fptr));
+ rb_io_wait_writable(fileno(fptr->f));
continue;
case SSL_ERROR_WANT_READ:
- rb_io_wait_readable(FPTR_TO_FD(fptr));
+ rb_io_wait_readable(fileno(fptr->f));
continue;
case SSL_ERROR_SYSCALL:
if (errno) rb_sys_fail(0);
@@ -1102,10 +713,6 @@ ossl_ssl_write(VALUE self, VALUE str)
return INT2NUM(nwrite);
}
-/*
- * call-seq:
- * ssl.sysclose => nil
- */
static VALUE
ossl_ssl_close(VALUE self)
{
@@ -1119,10 +726,6 @@ ossl_ssl_close(VALUE self)
return Qnil;
}
-/*
- * call-seq:
- * ssl.cert => cert or nil
- */
static VALUE
ossl_ssl_get_cert(VALUE self)
{
@@ -1147,10 +750,6 @@ ossl_ssl_get_cert(VALUE self)
return ossl_x509_new(cert);
}
-/*
- * call-seq:
- * ssl.peer_cert => cert or nil
- */
static VALUE
ossl_ssl_get_peer_cert(VALUE self)
{
@@ -1176,10 +775,6 @@ ossl_ssl_get_peer_cert(VALUE self)
return obj;
}
-/*
- * call-seq:
- * ssl.peer_cert_chain => [cert, ...] or nil
- */
static VALUE
ossl_ssl_get_peer_cert_chain(VALUE self)
{
@@ -1206,10 +801,6 @@ ossl_ssl_get_peer_cert_chain(VALUE self)
return ary;
}
-/*
- * call-seq:
- * ssl.cipher => [name, version, bits, alg_bits]
- */
static VALUE
ossl_ssl_get_cipher(VALUE self)
{
@@ -1226,10 +817,6 @@ ossl_ssl_get_cipher(VALUE self)
return ossl_ssl_cipher_to_ary(cipher);
}
-/*
- * call-seq:
- * ssl.state => string
- */
static VALUE
ossl_ssl_get_state(VALUE self)
{
@@ -1249,10 +836,6 @@ ossl_ssl_get_state(VALUE self)
return ret;
}
-/*
- * call-seq:
- * ssl.pending => integer
- */
static VALUE
ossl_ssl_pending(VALUE self)
{
@@ -1267,82 +850,10 @@ ossl_ssl_pending(VALUE self)
return INT2NUM(SSL_pending(ssl));
}
-/*
- * call-seq:
- * ssl.session_reused? -> true | false
- *
- */
-static VALUE
-ossl_ssl_session_reused(VALUE self)
-{
- SSL *ssl;
-
- Data_Get_Struct(self, SSL, ssl);
- if (!ssl) {
- rb_warning("SSL session is not started yet.");
- return Qnil;
- }
-
- switch(SSL_session_reused(ssl)) {
- case 1: return Qtrue;
- case 0: return Qfalse;
- default: ossl_raise(eSSLError, "SSL_session_reused");
- }
-}
-
-/*
- * call-seq:
- * ssl.session = session -> session
- *
- */
-static VALUE
-ossl_ssl_set_session(VALUE self, VALUE arg1)
-{
- SSL *ssl;
- SSL_SESSION *sess;
-
-/* why is ossl_ssl_setup delayed? */
- ossl_ssl_setup(self);
-
- Data_Get_Struct(self, SSL, ssl);
- if (!ssl) {
- rb_warning("SSL session is not started yet.");
- return Qnil;
- }
-
- SafeGetSSLSession(arg1, sess);
-
- if (SSL_set_session(ssl, sess) != 1)
- ossl_raise(eSSLError, "SSL_set_session");
-
- return arg1;
-}
-
-static VALUE
-ossl_ssl_get_verify_result(VALUE self)
-{
- SSL *ssl;
-
- Data_Get_Struct(self, SSL, ssl);
- if (!ssl) {
- rb_warning("SSL session is not started yet.");
- return Qnil;
- }
-
- return INT2FIX(SSL_get_verify_result(ssl));
-}
-
void
Init_ossl_ssl()
{
int i;
- VALUE ary;
-
-#if 0 /* let rdoc know about mOSSL */
- mOSSL = rb_define_module("OpenSSL");
-#endif
-
- ID_callback_state = rb_intern("@callback_state");
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);
@@ -1355,60 +866,16 @@ Init_ossl_ssl()
mSSL = rb_define_module_under(mOSSL, "SSL");
eSSLError = rb_define_class_under(mSSL, "SSLError", eOSSLError);
- Init_ossl_ssl_session();
-
- /* class SSLContext
- *
- * The following attributes are available but don't show up in rdoc.
- * All attributes must be set before calling SSLSocket.new(io, ctx).
- * * ssl_version, cert, key, client_ca, ca_file, ca_path, timeout,
- * * verify_mode, verify_depth client_cert_cb, tmp_dh_callback,
- * * session_id_context, session_add_cb, session_new_cb, session_remove_cb
- */
+ /* class SSLContext */
cSSLContext = rb_define_class_under(mSSL, "SSLContext", rb_cObject);
rb_define_alloc_func(cSSLContext, ossl_sslctx_s_alloc);
for(i = 0; i < numberof(ossl_sslctx_attrs); i++)
rb_attr(cSSLContext, rb_intern(ossl_sslctx_attrs[i]), 1, 1, Qfalse);
- rb_define_alias(cSSLContext, "ssl_timeout", "timeout");
rb_define_method(cSSLContext, "initialize", ossl_sslctx_initialize, -1);
- rb_define_method(cSSLContext, "ssl_version=", ossl_sslctx_set_ssl_version, 1);
rb_define_method(cSSLContext, "ciphers", ossl_sslctx_get_ciphers, 0);
rb_define_method(cSSLContext, "ciphers=", ossl_sslctx_set_ciphers, 1);
- rb_define_method(cSSLContext, "setup", ossl_sslctx_setup, 0);
-
-
- rb_define_const(cSSLContext, "SESSION_CACHE_OFF", LONG2FIX(SSL_SESS_CACHE_OFF));
- rb_define_const(cSSLContext, "SESSION_CACHE_CLIENT", LONG2FIX(SSL_SESS_CACHE_CLIENT)); /* doesn't actually do anything in 0.9.8e */
- rb_define_const(cSSLContext, "SESSION_CACHE_SERVER", LONG2FIX(SSL_SESS_CACHE_SERVER));
- rb_define_const(cSSLContext, "SESSION_CACHE_BOTH", LONG2FIX(SSL_SESS_CACHE_BOTH)); /* no different than CACHE_SERVER in 0.9.8e */
- rb_define_const(cSSLContext, "SESSION_CACHE_NO_AUTO_CLEAR", LONG2FIX(SSL_SESS_CACHE_NO_AUTO_CLEAR));
- rb_define_const(cSSLContext, "SESSION_CACHE_NO_INTERNAL_LOOKUP", LONG2FIX(SSL_SESS_CACHE_NO_INTERNAL_LOOKUP));
- rb_define_const(cSSLContext, "SESSION_CACHE_NO_INTERNAL_STORE", LONG2FIX(SSL_SESS_CACHE_NO_INTERNAL_STORE));
- rb_define_const(cSSLContext, "SESSION_CACHE_NO_INTERNAL", LONG2FIX(SSL_SESS_CACHE_NO_INTERNAL));
- rb_define_method(cSSLContext, "session_add", ossl_sslctx_session_add, 1);
- rb_define_method(cSSLContext, "session_remove", ossl_sslctx_session_remove, 1);
- rb_define_method(cSSLContext, "session_cache_mode", ossl_sslctx_get_session_cache_mode, 0);
- rb_define_method(cSSLContext, "session_cache_mode=", ossl_sslctx_set_session_cache_mode, 1);
- rb_define_method(cSSLContext, "session_cache_size", ossl_sslctx_get_session_cache_size, 0);
- rb_define_method(cSSLContext, "session_cache_size=", ossl_sslctx_set_session_cache_size, 1);
- rb_define_method(cSSLContext, "session_cache_stats", ossl_sslctx_get_session_cache_stats, 0);
- rb_define_method(cSSLContext, "flush_sessions", ossl_sslctx_flush_sessions, -1);
-
- ary = rb_ary_new2(numberof(ossl_ssl_method_tab));
- for (i = 0; i < numberof(ossl_ssl_method_tab); i++) {
- rb_ary_push(ary, ID2SYM(rb_intern(ossl_ssl_method_tab[i].name)));
- }
- rb_obj_freeze(ary);
- /* holds a list of available SSL/TLS methods */
- rb_define_const(cSSLContext, "METHODS", ary);
-
- /* class SSLSocket
- *
- * The following attributes are available but don't show up in rdoc.
- * * io, context, sync_close
- *
- */
+ /* class SSLSocket */
cSSLSocket = rb_define_class_under(mSSL, "SSLSocket", rb_cObject);
rb_define_alloc_func(cSSLSocket, ossl_ssl_s_alloc);
for(i = 0; i < numberof(ossl_ssl_attr_readers); i++)
@@ -1428,9 +895,6 @@ Init_ossl_ssl()
rb_define_method(cSSLSocket, "cipher", ossl_ssl_get_cipher, 0);
rb_define_method(cSSLSocket, "state", ossl_ssl_get_state, 0);
rb_define_method(cSSLSocket, "pending", ossl_ssl_pending, 0);
- rb_define_method(cSSLSocket, "session_reused?", ossl_ssl_session_reused, 0);
- rb_define_method(cSSLSocket, "session=", ossl_ssl_set_session, 1);
- rb_define_method(cSSLSocket, "verify_result", ossl_ssl_get_verify_result, 0);
#define ossl_ssl_def_const(x) rb_define_const(mSSL, #x, INT2FIX(SSL_##x))
@@ -1466,9 +930,6 @@ Init_ossl_ssl()
ossl_ssl_def_const(OP_NO_SSLv2);
ossl_ssl_def_const(OP_NO_SSLv3);
ossl_ssl_def_const(OP_NO_TLSv1);
-#if defined(SSL_OP_NO_TICKET)
- ossl_ssl_def_const(OP_NO_TICKET);
-#endif
ossl_ssl_def_const(OP_PKCS1_CHECK_1);
ossl_ssl_def_const(OP_PKCS1_CHECK_2);
ossl_ssl_def_const(OP_NETSCAPE_CA_DN_BUG);
diff --git a/ext/openssl/ossl_ssl.h b/ext/openssl/ossl_ssl.h
index 487f41216c..ba9ddb1985 100644
--- a/ext/openssl/ossl_ssl.h
+++ b/ext/openssl/ossl_ssl.h
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_ssl.h,v 1.1 2003/07/23 16:11:29 gotoyuzo Exp $
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -11,26 +11,11 @@
#if !defined(_OSSL_SSL_H_)
#define _OSSL_SSL_H_
-#define GetSSLSession(obj, sess) do { \
- Data_Get_Struct(obj, SSL_SESSION, sess); \
- if (!sess) { \
- ossl_raise(rb_eRuntimeError, "SSL Session wasn't initialized."); \
- } \
-} while (0)
-
-#define SafeGetSSLSession(obj, sess) do { \
- OSSL_Check_Kind(obj, cSSLSession); \
- GetSSLSession(obj, sess); \
-} while (0)
-
extern VALUE mSSL;
extern VALUE eSSLError;
extern VALUE cSSLSocket;
extern VALUE cSSLContext;
-extern VALUE cSSLSession;
void Init_ossl_ssl(void);
-void Init_ossl_ssl_session(void);
#endif /* _OSSL_SSL_H_ */
-
diff --git a/ext/openssl/ossl_ssl_session.c b/ext/openssl/ossl_ssl_session.c
deleted file mode 100644
index 63c2bbb87a..0000000000
--- a/ext/openssl/ossl_ssl_session.c
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- * Copyright (C) 2004-2007 Technorama Ltd. <oss-ruby@technorama.net>
- */
-
-#include "ossl.h"
-
-#define GetSSLSession(obj, sess) do { \
- Data_Get_Struct(obj, SSL_SESSION, sess); \
- if (!sess) { \
- ossl_raise(rb_eRuntimeError, "SSL Session wasn't initialized."); \
- } \
-} while (0)
-
-#define SafeGetSSLSession(obj, sess) do { \
- OSSL_Check_Kind(obj, cSSLSession); \
- GetSSLSession(obj, sess); \
-} while (0)
-
-
-VALUE cSSLSession;
-static VALUE eSSLSession;
-
-static VALUE ossl_ssl_session_alloc(VALUE klass)
-{
- return Data_Wrap_Struct(klass, 0, SSL_SESSION_free, NULL);
-}
-
-/*
- * call-seq:
- * Session.new(SSLSocket | string) => session
- *
- * === Parameters
- * +SSLSocket+ is an OpenSSL::SSL::SSLSocket
- * +string+ must be a DER or PEM encoded Session.
-*/
-static VALUE ossl_ssl_session_initialize(VALUE self, VALUE arg1)
-{
- SSL_SESSION *ctx = NULL;
- VALUE obj;
- unsigned char *p;
-
- if (RDATA(self)->data)
- ossl_raise(eSSLSession, "SSL Session already initialized");
-
- if (rb_obj_is_instance_of(arg1, cSSLSocket)) {
- SSL *ssl;
-
- Data_Get_Struct(arg1, SSL, ssl);
-
- if (!ssl || (ctx = SSL_get1_session(ssl)) == NULL)
- ossl_raise(eSSLSession, "no session available");
- } else {
- BIO *in = ossl_obj2bio(arg1);
-
- ctx = PEM_read_bio_SSL_SESSION(in, NULL, NULL, NULL);
-
- if (!ctx) {
- BIO_reset(in);
- ctx = d2i_SSL_SESSION_bio(in, NULL);
- }
-
- BIO_free(in);
-
- if (!ctx)
- ossl_raise(rb_eArgError, "unknown type");
- }
-
- /* should not happen */
- if (ctx == NULL)
- ossl_raise(eSSLSession, "ctx not set - internal error");
-
- RDATA(self)->data = ctx;
-
- return self;
-}
-
-/*
- * call-seq:
- * session1 == session2 -> boolean
- *
-*/
-static VALUE ossl_ssl_session_eq(VALUE val1, VALUE val2)
-{
- SSL_SESSION *ctx1, *ctx2;
-
- GetSSLSession(val1, ctx1);
- SafeGetSSLSession(val2, ctx2);
-
- switch (SSL_SESSION_cmp(ctx1, ctx2)) {
- case 0: return Qtrue;
- default: return Qfalse;
- }
-}
-
-/*
- * call-seq:
- * session.time -> Time
- *
-*/
-static VALUE ossl_ssl_session_get_time(VALUE self)
-{
- SSL_SESSION *ctx;
- time_t t;
-
- GetSSLSession(self, ctx);
-
- t = SSL_SESSION_get_time(ctx);
-
- if (t == 0)
- return Qnil;
-
- return rb_funcall(rb_cTime, rb_intern("at"), 1, LONG2NUM(t));
-}
-
-/*
- * call-seq:
- * session.timeout -> integer
- *
- * How long until the session expires in seconds.
- *
-*/
-static VALUE ossl_ssl_session_get_timeout(VALUE self)
-{
- SSL_SESSION *ctx;
- time_t t;
-
- GetSSLSession(self, ctx);
-
- t = SSL_SESSION_get_timeout(ctx);
-
- return ULONG2NUM(t);
-}
-
-#define SSLSESSION_SET_TIME(func) \
- static VALUE ossl_ssl_session_set_##func(VALUE self, VALUE time_v) \
- { \
- SSL_SESSION *ctx; \
- time_t t; \
- \
- GetSSLSession(self, ctx); \
- \
- if (rb_obj_is_instance_of(time_v, rb_cTime)) { \
- time_v = rb_funcall(time_v, rb_intern("to_i"), 0); \
- } else if (FIXNUM_P(time_v)) { \
- ; \
- } else { \
- rb_raise(rb_eArgError, "unknown type"); \
- } \
- \
- t = NUM2ULONG(time_v); \
- \
- SSL_SESSION_set_##func(ctx, t); \
- \
- return ossl_ssl_session_get_##func(self); \
- }
-
-SSLSESSION_SET_TIME(time)
-SSLSESSION_SET_TIME(timeout)
-
-#ifdef HAVE_SSL_SESSION_GET_ID
-/*
- * call-seq:
- * session.id -> aString
- *
- * Returns the Session ID.
-*/
-static VALUE ossl_ssl_session_get_id(VALUE self)
-{
- SSL_SESSION *ctx;
- const unsigned char *p = NULL;
- unsigned int i = 0;
-
- GetSSLSession(self, ctx);
-
- p = SSL_SESSION_get_id(ctx, &i);
-
- return rb_str_new((const char *) p, i);
-}
-#endif
-
-/*
- * call-seq:
- * session.to_der -> aString
- *
- * Returns an ASN1 encoded String that contains the Session object.
-*/
-static VALUE ossl_ssl_session_to_der(VALUE self)
-{
- SSL_SESSION *ctx;
- unsigned char buf[1024*10], *p;
- int len;
-
- GetSSLSession(self, ctx);
-
- p = buf;
- len = i2d_SSL_SESSION(ctx, &p);
-
- if (len <= 0)
- ossl_raise(eSSLSession, "i2d_SSL_SESSION");
- else if (len >= sizeof(buf))
- ossl_raise(eSSLSession, "i2d_SSL_SESSION too large");
-
- return rb_str_new((const char *) p, len);
-}
-
-/*
- * call-seq:
- * session.to_pem -> String
- *
- * Returns a PEM encoded String that contains the Session object.
-*/
-static VALUE ossl_ssl_session_to_pem(VALUE self)
-{
- SSL_SESSION *ctx;
- BIO *out;
- BUF_MEM *buf;
- VALUE str;
- int i;
-
- GetSSLSession(self, ctx);
-
- if (!(out = BIO_new(BIO_s_mem()))) {
- ossl_raise(eSSLSession, "BIO_s_mem()");
- }
-
- if (!(i=PEM_write_bio_SSL_SESSION(out, ctx))) {
- BIO_free(out);
- ossl_raise(eSSLSession, "SSL_SESSION_print()");
- }
-
- BIO_get_mem_ptr(out, &buf);
- str = rb_str_new(buf->data, buf->length);
- BIO_free(out);
-
- return str;
-}
-
-
-/*
- * call-seq:
- * session.to_text -> String
- *
- * Shows everything in the Session object.
-*/
-static VALUE ossl_ssl_session_to_text(VALUE self)
-{
- SSL_SESSION *ctx;
- BIO *out;
- BUF_MEM *buf;
- VALUE str;
-
- GetSSLSession(self, ctx);
-
- if (!(out = BIO_new(BIO_s_mem()))) {
- ossl_raise(eSSLSession, "BIO_s_mem()");
- }
-
- if (!SSL_SESSION_print(out, ctx)) {
- BIO_free(out);
- ossl_raise(eSSLSession, "SSL_SESSION_print()");
- }
-
- BIO_get_mem_ptr(out, &buf);
- str = rb_str_new(buf->data, buf->length);
- BIO_free(out);
-
- return str;
-}
-
-
-void Init_ossl_ssl_session(void)
-{
-#if 0 /* let rdoc know about mOSSL */
- mOSSL = rb_define_module("OpenSSL");
- mSSL = rb_define_module_under(mOSSL, "SSL");
-#endif
- cSSLSession = rb_define_class_under(mSSL, "Session", rb_cObject);
- eSSLSession = rb_define_class_under(cSSLSession, "SessionError", eOSSLError);
-
- rb_define_alloc_func(cSSLSession, ossl_ssl_session_alloc);
- rb_define_method(cSSLSession, "initialize", ossl_ssl_session_initialize, 1);
-
- rb_define_method(cSSLSession, "==", ossl_ssl_session_eq, 1);
-
- rb_define_method(cSSLSession, "time", ossl_ssl_session_get_time, 0);
- rb_define_method(cSSLSession, "time=", ossl_ssl_session_set_time, 1);
- rb_define_method(cSSLSession, "timeout", ossl_ssl_session_get_timeout, 0);
- rb_define_method(cSSLSession, "timeout=", ossl_ssl_session_set_timeout, 1);
-
-#ifdef HAVE_SSL_SESSION_GET_ID
- rb_define_method(cSSLSession, "id", ossl_ssl_session_get_id, 0);
-#else
- rb_undef_method(cSSLSession, "id");
-#endif
- rb_define_method(cSSLSession, "to_der", ossl_ssl_session_to_der, 0);
- rb_define_method(cSSLSession, "to_pem", ossl_ssl_session_to_pem, 0);
- rb_define_method(cSSLSession, "to_text", ossl_ssl_session_to_text, 0);
-}
diff --git a/ext/openssl/ossl_version.h b/ext/openssl/ossl_version.h
index 63878e0d8e..6d43cdccbf 100644
--- a/ext/openssl/ossl_version.h
+++ b/ext/openssl/ossl_version.h
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_version.h,v 1.1 2003/07/23 16:11:29 gotoyuzo Exp $
* '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 fd1d9b6c7e..fa90e92d11 100644
--- a/ext/openssl/ossl_x509.c
+++ b/ext/openssl/ossl_x509.c
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_x509.c,v 1.2 2003/09/08 10:31:38 gotoyuzo Exp $
* '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 1a43569073..8d1f77b302 100644
--- a/ext/openssl/ossl_x509.h
+++ b/ext/openssl/ossl_x509.h
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_x509.h,v 1.2 2003/11/01 09:24:55 gotoyuzo Exp $
* '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 ca1c59aba9..91a0795209 100644
--- a/ext/openssl/ossl_x509attr.c
+++ b/ext/openssl/ossl_x509attr.c
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_x509attr.c,v 1.4.2.2 2004/12/15 01:54:38 matz Exp $
* 'OpenSSL for Ruby' project
* Copyright (C) 2001 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -84,10 +84,6 @@ ossl_x509attr_alloc(VALUE klass)
return obj;
}
-/*
- * call-seq:
- * Attribute.new(oid [, value]) => attr
- */
static VALUE
ossl_x509attr_initialize(int argc, VALUE *argv, VALUE self)
{
@@ -99,9 +95,9 @@ ossl_x509attr_initialize(int argc, VALUE *argv, VALUE self)
if(rb_scan_args(argc, argv, "11", &oid, &value) == 1){
oid = ossl_to_der_if_possible(oid);
StringValue(oid);
- p = RSTRING_PTR(oid);
+ p = RSTRING(oid)->ptr;
if(!d2i_X509_ATTRIBUTE((X509_ATTRIBUTE**)&DATA_PTR(self),
- &p, RSTRING_LEN(oid))){
+ &p, RSTRING(oid)->len)){
ossl_raise(eX509AttrError, NULL);
}
return self;
@@ -112,10 +108,6 @@ ossl_x509attr_initialize(int argc, VALUE *argv, VALUE self)
return self;
}
-/*
- * call-seq:
- * attr.oid = string => string
- */
static VALUE
ossl_x509attr_set_oid(VALUE self, VALUE oid)
{
@@ -133,10 +125,6 @@ ossl_x509attr_set_oid(VALUE self, VALUE oid)
return oid;
}
-/*
- * call-seq:
- * attr.oid => string
- */
static VALUE
ossl_x509attr_get_oid(VALUE self)
{
@@ -168,10 +156,6 @@ ossl_x509attr_get_oid(VALUE self)
# define OSSL_X509ATTR_SET_SINGLE(attr) ((attr)->set = 0)
#endif
-/*
- * call-seq:
- * attr.value = asn1 => asn1
- */
static VALUE
ossl_x509attr_set_value(VALUE self, VALUE value)
{
@@ -195,10 +179,6 @@ ossl_x509attr_set_value(VALUE self, VALUE value)
return value;
}
-/*
- * call-seq:
- * attr.value => asn1
- */
static VALUE
ossl_x509attr_get_value(VALUE self)
{
@@ -212,7 +192,7 @@ ossl_x509attr_get_value(VALUE self)
if(OSSL_X509ATTR_IS_SINGLE(attr)){
length = i2d_ASN1_TYPE(attr->value.single, NULL);
str = rb_str_new(0, length);
- p = RSTRING_PTR(str);
+ p = RSTRING(str)->ptr;
i2d_ASN1_TYPE(attr->value.single, &p);
ossl_str_adjust(str, p);
}
@@ -220,7 +200,7 @@ ossl_x509attr_get_value(VALUE self)
length = i2d_ASN1_SET_OF_ASN1_TYPE(attr->value.set, NULL,
i2d_ASN1_TYPE, V_ASN1_SET, V_ASN1_UNIVERSAL, 0);
str = rb_str_new(0, length);
- p = RSTRING_PTR(str);
+ p = RSTRING(str)->ptr;
i2d_ASN1_SET_OF_ASN1_TYPE(attr->value.set, &p,
i2d_ASN1_TYPE, V_ASN1_SET, V_ASN1_UNIVERSAL, 0);
ossl_str_adjust(str, p);
@@ -230,10 +210,6 @@ ossl_x509attr_get_value(VALUE self)
return asn1;
}
-/*
- * call-seq:
- * attr.to_der => string
- */
static VALUE
ossl_x509attr_to_der(VALUE self)
{
@@ -246,10 +222,10 @@ ossl_x509attr_to_der(VALUE self)
if((len = i2d_X509_ATTRIBUTE(attr, NULL)) <= 0)
ossl_raise(eX509AttrError, NULL);
str = rb_str_new(0, len);
- p = RSTRING_PTR(str);
+ p = RSTRING(str)->ptr;
if(i2d_X509_ATTRIBUTE(attr, &p) <= 0)
ossl_raise(eX509AttrError, NULL);
- rb_str_set_len(str, p - (unsigned char*)RSTRING_PTR(str));
+ RSTRING(str)->len = p - (unsigned char*)RSTRING(str)->ptr;
return str;
}
diff --git a/ext/openssl/ossl_x509cert.c b/ext/openssl/ossl_x509cert.c
index b97f27ffa9..3ac9c894da 100644
--- a/ext/openssl/ossl_x509cert.c
+++ b/ext/openssl/ossl_x509cert.c
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_x509cert.c,v 1.3.2.1 2004/12/15 01:54:38 matz Exp $
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -63,7 +63,7 @@ ossl_x509_new_from_file(VALUE filename)
VALUE obj;
SafeStringValue(filename);
- if (!(fp = fopen(RSTRING_PTR(filename), "r"))) {
+ if (!(fp = fopen(RSTRING(filename)->ptr, "r"))) {
ossl_raise(eX509CertError, "%s", strerror(errno));
}
x509 = PEM_read_X509(fp, NULL, NULL, NULL);
@@ -125,11 +125,6 @@ ossl_x509_alloc(VALUE klass)
return obj;
}
-/*
- * call-seq:
- * Certificate.new => cert
- * Certificate.new(string) => cert
- */
static VALUE
ossl_x509_initialize(int argc, VALUE *argv, VALUE self)
{
@@ -174,10 +169,6 @@ ossl_x509_copy(VALUE self, VALUE other)
return self;
}
-/*
- * call-seq:
- * cert.to_der => string
- */
static VALUE
ossl_x509_to_der(VALUE self)
{
@@ -190,7 +181,7 @@ ossl_x509_to_der(VALUE self)
if ((len = i2d_X509(x509, NULL)) <= 0)
ossl_raise(eX509CertError, NULL);
str = rb_str_new(0, len);
- p = RSTRING_PTR(str);
+ p = RSTRING(str)->ptr;
if (i2d_X509(x509, &p) <= 0)
ossl_raise(eX509CertError, NULL);
ossl_str_adjust(str, p);
@@ -198,10 +189,6 @@ ossl_x509_to_der(VALUE self)
return str;
}
-/*
- * call-seq:
- * cert.to_pem => string
- */
static VALUE
ossl_x509_to_pem(VALUE self)
{
@@ -222,10 +209,6 @@ ossl_x509_to_pem(VALUE self)
return str;
}
-/*
- * call-seq:
- * cert.to_text => string
- */
static VALUE
ossl_x509_to_text(VALUE self)
{
@@ -269,10 +252,6 @@ ossl_x509_to_req(VALUE self)
}
#endif
-/*
- * call-seq:
- * cert.version => integer
- */
static VALUE
ossl_x509_get_version(VALUE self)
{
@@ -283,10 +262,6 @@ ossl_x509_get_version(VALUE self)
return LONG2NUM(X509_get_version(x509));
}
-/*
- * call-seq:
- * cert.version = integer => integer
- */
static VALUE
ossl_x509_set_version(VALUE self, VALUE version)
{
@@ -304,10 +279,6 @@ ossl_x509_set_version(VALUE self, VALUE version)
return version;
}
-/*
- * call-seq:
- * cert.serial => integer
- */
static VALUE
ossl_x509_get_serial(VALUE self)
{
@@ -318,10 +289,6 @@ ossl_x509_get_serial(VALUE self)
return asn1integer_to_num(X509_get_serialNumber(x509));
}
-/*
- * call-seq:
- * cert.serial = integer => integer
- */
static VALUE
ossl_x509_set_serial(VALUE self, VALUE num)
{
@@ -335,10 +302,6 @@ ossl_x509_set_serial(VALUE self, VALUE num)
return num;
}
-/*
- * call-seq:
- * cert.signature_algorithm => string
- */
static VALUE
ossl_x509_get_signature_algorithm(VALUE self)
{
@@ -359,10 +322,6 @@ ossl_x509_get_signature_algorithm(VALUE self)
return str;
}
-/*
- * call-seq:
- * cert.subject => name
- */
static VALUE
ossl_x509_get_subject(VALUE self)
{
@@ -377,10 +336,6 @@ ossl_x509_get_subject(VALUE self)
return ossl_x509name_new(name);
}
-/*
- * call-seq:
- * cert.subject = name => name
- */
static VALUE
ossl_x509_set_subject(VALUE self, VALUE subject)
{
@@ -394,10 +349,6 @@ ossl_x509_set_subject(VALUE self, VALUE subject)
return subject;
}
-/*
- * call-seq:
- * cert.issuer => name
- */
static VALUE
ossl_x509_get_issuer(VALUE self)
{
@@ -412,10 +363,6 @@ ossl_x509_get_issuer(VALUE self)
return ossl_x509name_new(name);
}
-/*
- * call-seq:
- * cert.issuer = name => name
- */
static VALUE
ossl_x509_set_issuer(VALUE self, VALUE issuer)
{
@@ -429,10 +376,6 @@ ossl_x509_set_issuer(VALUE self, VALUE issuer)
return issuer;
}
-/*
- * call-seq:
- * cert.not_before => time
- */
static VALUE
ossl_x509_get_not_before(VALUE self)
{
@@ -447,10 +390,6 @@ ossl_x509_get_not_before(VALUE self)
return asn1time_to_time(asn1time);
}
-/*
- * call-seq:
- * cert.not_before = time => time
- */
static VALUE
ossl_x509_set_not_before(VALUE self, VALUE time)
{
@@ -466,10 +405,6 @@ ossl_x509_set_not_before(VALUE self, VALUE time)
return time;
}
-/*
- * call-seq:
- * cert.not_after => time
- */
static VALUE
ossl_x509_get_not_after(VALUE self)
{
@@ -484,10 +419,6 @@ ossl_x509_get_not_after(VALUE self)
return asn1time_to_time(asn1time);
}
-/*
- * call-seq:
- * cert.not_before = time => time
- */
static VALUE
ossl_x509_set_not_after(VALUE self, VALUE time)
{
@@ -503,10 +434,6 @@ ossl_x509_set_not_after(VALUE self, VALUE time)
return time;
}
-/*
- * call-seq:
- * cert.public_key => key
- */
static VALUE
ossl_x509_get_public_key(VALUE self)
{
@@ -521,10 +448,6 @@ ossl_x509_get_public_key(VALUE self)
return ossl_pkey_new(pkey); /* NO DUP - OK */
}
-/*
- * call-seq:
- * cert.public_key = key => key
- */
static VALUE
ossl_x509_set_public_key(VALUE self, VALUE key)
{
@@ -538,10 +461,6 @@ ossl_x509_set_public_key(VALUE self, VALUE key)
return key;
}
-/*
- * call-seq:
- * cert.sign(key, digest) => self
- */
static VALUE
ossl_x509_sign(VALUE self, VALUE key, VALUE digest)
{
@@ -560,9 +479,6 @@ ossl_x509_sign(VALUE self, VALUE key, VALUE digest)
}
/*
- * call-seq:
- * cert.verify(key) => true | false
- *
* Checks that cert signature is made with PRIVversion of this PUBLIC 'key'
*/
static VALUE
@@ -585,9 +501,6 @@ ossl_x509_verify(VALUE self, VALUE key)
}
/*
- * call-seq:
- * cert.check_private_key(key)
- *
* Checks if 'key' is PRIV key for this cert
*/
static VALUE
@@ -608,8 +521,7 @@ ossl_x509_check_private_key(VALUE self, VALUE key)
}
/*
- * call-seq:
- * cert.extensions => [extension...]
+ * Gets X509v3 extensions as array of X509Ext objects
*/
static VALUE
ossl_x509_get_extensions(VALUE self)
@@ -634,8 +546,7 @@ ossl_x509_get_extensions(VALUE self)
}
/*
- * call-seq:
- * cert.extensions = [ext...] => [ext...]
+ * Sets X509_EXTENSIONs
*/
static VALUE
ossl_x509_set_extensions(VALUE self, VALUE ary)
@@ -646,14 +557,14 @@ ossl_x509_set_extensions(VALUE self, VALUE ary)
Check_Type(ary, T_ARRAY);
/* All ary's members should be X509Extension */
- for (i=0; i<RARRAY_LEN(ary); i++) {
- OSSL_Check_Kind(RARRAY_PTR(ary)[i], cX509Ext);
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ OSSL_Check_Kind(RARRAY(ary)->ptr[i], cX509Ext);
}
GetX509(self, x509);
sk_X509_EXTENSION_pop_free(x509->cert_info->extensions, X509_EXTENSION_free);
x509->cert_info->extensions = NULL;
- for (i=0; i<RARRAY_LEN(ary); i++) {
- ext = DupX509ExtPtr(RARRAY_PTR(ary)[i]);
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ ext = DupX509ExtPtr(RARRAY(ary)->ptr[i]);
if (!X509_add_ext(x509, ext, -1)) { /* DUPs ext - FREE it */
X509_EXTENSION_free(ext);
@@ -665,10 +576,6 @@ ossl_x509_set_extensions(VALUE self, VALUE ary)
return ary;
}
-/*
- * call-seq:
- * cert.add_extension(extension) => extension
- */
static VALUE
ossl_x509_add_extension(VALUE self, VALUE extension)
{
diff --git a/ext/openssl/ossl_x509crl.c b/ext/openssl/ossl_x509crl.c
index be9ddacf48..62d27fe7a4 100644
--- a/ext/openssl/ossl_x509crl.c
+++ b/ext/openssl/ossl_x509crl.c
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_x509crl.c,v 1.3.2.1 2004/12/15 01:54:38 matz Exp $
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -287,14 +287,14 @@ ossl_x509crl_set_revoked(VALUE self, VALUE ary)
Check_Type(ary, T_ARRAY);
/* All ary members should be X509 Revoked */
- for (i=0; i<RARRAY_LEN(ary); i++) {
- OSSL_Check_Kind(RARRAY_PTR(ary)[i], cX509Rev);
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ OSSL_Check_Kind(RARRAY(ary)->ptr[i], cX509Rev);
}
GetX509CRL(self, crl);
sk_X509_REVOKED_pop_free(crl->crl->revoked, X509_REVOKED_free);
crl->crl->revoked = NULL;
- for (i=0; i<RARRAY_LEN(ary); i++) {
- rev = DupX509RevokedPtr(RARRAY_PTR(ary)[i]);
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ rev = DupX509RevokedPtr(RARRAY(ary)->ptr[i]);
if (!X509_CRL_add0_revoked(crl, rev)) { /* NO DUP - don't free! */
ossl_raise(eX509CRLError, NULL);
}
@@ -461,14 +461,14 @@ ossl_x509crl_set_extensions(VALUE self, VALUE ary)
Check_Type(ary, T_ARRAY);
/* All ary members should be X509 Extensions */
- for (i=0; i<RARRAY_LEN(ary); i++) {
- OSSL_Check_Kind(RARRAY_PTR(ary)[i], cX509Ext);
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ OSSL_Check_Kind(RARRAY(ary)->ptr[i], cX509Ext);
}
GetX509CRL(self, crl);
sk_X509_EXTENSION_pop_free(crl->crl->extensions, X509_EXTENSION_free);
crl->crl->extensions = NULL;
- for (i=0; i<RARRAY_LEN(ary); i++) {
- ext = DupX509ExtPtr(RARRAY_PTR(ary)[i]);
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ ext = DupX509ExtPtr(RARRAY(ary)->ptr[i]);
if(!X509_CRL_add_ext(crl, ext, -1)) { /* DUPs ext - FREE it */
X509_EXTENSION_free(ext);
ossl_raise(eX509CRLError, NULL);
diff --git a/ext/openssl/ossl_x509ext.c b/ext/openssl/ossl_x509ext.c
index aa9366f901..219f30d7e3 100644
--- a/ext/openssl/ossl_x509ext.c
+++ b/ext/openssl/ossl_x509ext.c
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_x509ext.c,v 1.8.2.3 2005/11/22 22:28:51 gotoyuzo Exp $
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -229,23 +229,23 @@ ossl_x509extfactory_create_ext(int argc, VALUE *argv, VALUE self)
StringValue(value);
if(NIL_P(critical)) critical = Qfalse;
- nid = OBJ_ln2nid(RSTRING_PTR(oid));
- if(!nid) nid = OBJ_sn2nid(RSTRING_PTR(oid));
- if(!nid) ossl_raise(eX509ExtError, "unknown OID `%s'", RSTRING_PTR(oid));
+ nid = OBJ_ln2nid(RSTRING(oid)->ptr);
+ if(!nid) nid = OBJ_sn2nid(RSTRING(oid)->ptr);
+ if(!nid) ossl_raise(eX509ExtError, "unknown OID `%s'", RSTRING(oid)->ptr);
valstr = rb_str_new2(RTEST(critical) ? "critical," : "");
rb_str_append(valstr, value);
GetX509ExtFactory(self, ctx);
#ifdef HAVE_X509V3_EXT_NCONF_NID
rconf = rb_iv_get(self, "@config");
conf = NIL_P(rconf) ? NULL : GetConfigPtr(rconf);
- ext = X509V3_EXT_nconf_nid(conf, ctx, nid, RSTRING_PTR(valstr));
+ ext = X509V3_EXT_nconf_nid(conf, ctx, nid, RSTRING(valstr)->ptr);
#else
if (!empty_lhash) empty_lhash = lh_new(NULL, NULL);
- ext = X509V3_EXT_conf_nid(empty_lhash, ctx, nid, RSTRING_PTR(valstr));
+ ext = X509V3_EXT_conf_nid(empty_lhash, ctx, nid, RSTRING(valstr)->ptr);
#endif
if (!ext){
ossl_raise(eX509ExtError, "%s = %s",
- RSTRING_PTR(oid), RSTRING_PTR(value));
+ RSTRING(oid)->ptr, RSTRING(value)->ptr);
}
WrapX509Ext(cX509Ext, obj, ext);
@@ -280,9 +280,9 @@ ossl_x509ext_initialize(int argc, VALUE *argv, VALUE self)
if(rb_scan_args(argc, argv, "12", &oid, &value, &critical) == 1){
oid = ossl_to_der_if_possible(oid);
StringValue(oid);
- p = RSTRING_PTR(oid);
+ p = RSTRING(oid)->ptr;
if(!d2i_X509_EXTENSION((X509_EXTENSION**)&DATA_PTR(self),
- &p, RSTRING_LEN(oid)))
+ &p, RSTRING(oid)->len))
ossl_raise(eX509ExtError, NULL);
return self;
}
@@ -319,14 +319,14 @@ ossl_x509ext_set_value(VALUE self, VALUE data)
data = ossl_to_der_if_possible(data);
StringValue(data);
- if(!(s = OPENSSL_malloc(RSTRING_LEN(data))))
+ if(!(s = OPENSSL_malloc(RSTRING(data)->len)))
ossl_raise(eX509ExtError, "malloc error");
- memcpy(s, RSTRING_PTR(data), RSTRING_LEN(data));
+ memcpy(s, RSTRING(data)->ptr, RSTRING(data)->len);
if(!(asn1s = ASN1_OCTET_STRING_new())){
free(s);
ossl_raise(eX509ExtError, NULL);
}
- if(!M_ASN1_OCTET_STRING_set(asn1s, s, RSTRING_LEN(data))){
+ if(!M_ASN1_OCTET_STRING_set(asn1s, s, RSTRING(data)->len)){
free(s);
ASN1_OCTET_STRING_free(asn1s);
ossl_raise(eX509ExtError, NULL);
@@ -409,7 +409,7 @@ ossl_x509ext_to_der(VALUE obj)
if((len = i2d_X509_EXTENSION(ext, NULL)) <= 0)
ossl_raise(eX509ExtError, NULL);
str = rb_str_new(0, len);
- p = RSTRING_PTR(str);
+ p = RSTRING(str)->ptr;
if(i2d_X509_EXTENSION(ext, &p) < 0)
ossl_raise(eX509ExtError, NULL);
ossl_str_adjust(str, p);
diff --git a/ext/openssl/ossl_x509name.c b/ext/openssl/ossl_x509name.c
index b4434d2a34..1a456f2c48 100644
--- a/ext/openssl/ossl_x509name.c
+++ b/ext/openssl/ossl_x509name.c
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_x509name.c,v 1.4.2.8 2004/12/27 07:55:56 gotoyuzo Exp $
* 'OpenSSL for Ruby' project
* Copyright (C) 2001 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -109,13 +109,6 @@ ossl_x509name_init_i(VALUE i, VALUE args)
return Qnil;
}
-/*
- * call-seq:
- * X509::Name.new => name
- * X509::Name.new(string) => name
- * X509::Name.new(dn) => name
- * X509::Name.new(dn, template) => name
- */
static VALUE
ossl_x509name_initialize(int argc, VALUE *argv, VALUE self)
{
@@ -132,14 +125,14 @@ ossl_x509name_initialize(int argc, VALUE *argv, VALUE self)
VALUE args;
if(NIL_P(template)) template = OBJECT_TYPE_TEMPLATE;
args = rb_ary_new3(2, self, template);
- rb_block_call(tmp, rb_intern("each"), 0, 0, ossl_x509name_init_i, args);
+ rb_iterate(rb_each, tmp, ossl_x509name_init_i, args);
}
else{
unsigned char *p;
VALUE str = ossl_to_der_if_possible(arg);
StringValue(str);
- p = RSTRING_PTR(str);
- if(!d2i_X509_NAME((X509_NAME**)&DATA_PTR(self), &p, RSTRING_LEN(str))){
+ p = RSTRING(str)->ptr;
+ if(!d2i_X509_NAME((X509_NAME**)&DATA_PTR(self), &p, RSTRING(str)->len)){
ossl_raise(eX509NameError, NULL);
}
}
@@ -148,10 +141,6 @@ ossl_x509name_initialize(int argc, VALUE *argv, VALUE self)
return self;
}
-/*
- * call-seq:
- * name.add_entry(oid, value [, type]) => self
- */
static
VALUE ossl_x509name_add_entry(int argc, VALUE *argv, VALUE self)
{
@@ -163,8 +152,8 @@ VALUE ossl_x509name_add_entry(int argc, VALUE *argv, VALUE self)
StringValue(value);
if(NIL_P(type)) type = rb_aref(OBJECT_TYPE_TEMPLATE, oid);
GetX509Name(self, name);
- if (!X509_NAME_add_entry_by_txt(name, RSTRING_PTR(oid), NUM2INT(type),
- RSTRING_PTR(value), RSTRING_LEN(value), -1, 0)) {
+ if (!X509_NAME_add_entry_by_txt(name, RSTRING(oid)->ptr, NUM2INT(type),
+ RSTRING(value)->ptr, RSTRING(value)->len, -1, 0)) {
ossl_raise(eX509NameError, NULL);
}
@@ -186,14 +175,9 @@ ossl_x509name_to_s_old(VALUE self)
return str;
}
-/*
- * call-seq:
- * name.to_s => string
- * name.to_s(integer) => string
- */
static VALUE
ossl_x509name_to_s(int argc, VALUE *argv, VALUE self)
-{
+{
X509_NAME *name;
VALUE flag, str;
BIO *out;
@@ -215,10 +199,6 @@ ossl_x509name_to_s(int argc, VALUE *argv, VALUE self)
return str;
}
-/*
- * call-seq:
- * name.to_a => [[name, data, type], ...]
- */
static VALUE
ossl_x509name_to_a(VALUE self)
{
@@ -286,10 +266,6 @@ ossl_x509name_eql(VALUE self, VALUE other)
return (result == 0) ? Qtrue : Qfalse;
}
-/*
- * call-seq:
- * name.hash => integer
- */
static VALUE
ossl_x509name_hash(VALUE self)
{
@@ -303,10 +279,6 @@ ossl_x509name_hash(VALUE self)
return ULONG2NUM(hash);
}
-/*
- * call-seq:
- * name.to_der => string
- */
static VALUE
ossl_x509name_to_der(VALUE self)
{
@@ -319,7 +291,7 @@ ossl_x509name_to_der(VALUE self)
if((len = i2d_X509_NAME(name, NULL)) <= 0)
ossl_raise(eX509NameError, NULL);
str = rb_str_new(0, len);
- p = RSTRING_PTR(str);
+ p = RSTRING(str)->ptr;
if(i2d_X509_NAME(name, &p) <= 0)
ossl_raise(eX509NameError, NULL);
ossl_str_adjust(str, p);
diff --git a/ext/openssl/ossl_x509req.c b/ext/openssl/ossl_x509req.c
index 13a42dddaf..c1b1a3e619 100644
--- a/ext/openssl/ossl_x509req.c
+++ b/ext/openssl/ossl_x509req.c
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_x509req.c,v 1.5.2.2 2005/09/10 00:54:29 gotoyuzo Exp $
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -171,7 +171,7 @@ ossl_x509req_to_der(VALUE self)
if ((len = i2d_X509_REQ(req, NULL)) <= 0)
ossl_raise(eX509CertError, NULL);
str = rb_str_new(0, len);
- p = RSTRING_PTR(str);
+ p = RSTRING(str)->ptr;
if (i2d_X509_REQ(req, &p) <= 0)
ossl_raise(eX509ReqError, NULL);
ossl_str_adjust(str, p);
@@ -403,14 +403,14 @@ ossl_x509req_set_attributes(VALUE self, VALUE ary)
VALUE item;
Check_Type(ary, T_ARRAY);
- for (i=0;i<RARRAY_LEN(ary); i++) {
- OSSL_Check_Kind(RARRAY_PTR(ary)[i], cX509Attr);
+ for (i=0;i<RARRAY(ary)->len; i++) {
+ OSSL_Check_Kind(RARRAY(ary)->ptr[i], cX509Attr);
}
GetX509Req(self, req);
sk_X509_ATTRIBUTE_pop_free(req->req_info->attributes, X509_ATTRIBUTE_free);
req->req_info->attributes = NULL;
- for (i=0;i<RARRAY_LEN(ary); i++) {
- item = RARRAY_PTR(ary)[i];
+ for (i=0;i<RARRAY(ary)->len; i++) {
+ item = RARRAY(ary)->ptr[i];
attr = DupX509AttrPtr(item);
if (!X509_REQ_add1_attr(req, attr)) {
ossl_raise(eX509ReqError, NULL);
diff --git a/ext/openssl/ossl_x509revoked.c b/ext/openssl/ossl_x509revoked.c
index d0f816bad4..a0f2f00aa5 100644
--- a/ext/openssl/ossl_x509revoked.c
+++ b/ext/openssl/ossl_x509revoked.c
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_x509revoked.c,v 1.2.2.1 2004/12/15 01:54:38 matz Exp $
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -175,14 +175,14 @@ ossl_x509revoked_set_extensions(VALUE self, VALUE ary)
VALUE item;
Check_Type(ary, T_ARRAY);
- for (i=0; i<RARRAY_LEN(ary); i++) {
- OSSL_Check_Kind(RARRAY_PTR(ary)[i], cX509Ext);
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ OSSL_Check_Kind(RARRAY(ary)->ptr[i], cX509Ext);
}
GetX509Rev(self, rev);
sk_X509_EXTENSION_pop_free(rev->extensions, X509_EXTENSION_free);
rev->extensions = NULL;
- for (i=0; i<RARRAY_LEN(ary); i++) {
- item = RARRAY_PTR(ary)[i];
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ item = RARRAY(ary)->ptr[i];
ext = DupX509ExtPtr(item);
if(!X509_REVOKED_add_ext(rev, ext, -1)) {
ossl_raise(eX509RevError, NULL);
diff --git a/ext/openssl/ossl_x509store.c b/ext/openssl/ossl_x509store.c
index 769ce8a91a..360769e612 100644
--- a/ext/openssl/ossl_x509store.c
+++ b/ext/openssl/ossl_x509store.c
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ossl_x509store.c,v 1.2.2.5 2005/09/10 00:54:29 gotoyuzo Exp $
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -118,18 +118,11 @@ ossl_x509store_set_vfy_cb(VALUE self, VALUE cb)
return cb;
}
-
-/*
- * call-seq:
- * X509::Store.new => store
- *
- */
static VALUE
ossl_x509store_initialize(int argc, VALUE *argv, VALUE self)
{
X509_STORE *store;
-/* BUG: This method takes any number of arguments but appears to ignore them. */
GetX509Store(self, store);
X509_STORE_set_verify_cb_func(store, ossl_verify_cb);
ossl_x509store_set_vfy_cb(self, Qnil);
@@ -213,7 +206,7 @@ ossl_x509store_add_file(VALUE self, VALUE file)
if(file != Qnil){
Check_SafeStr(file);
- path = RSTRING_PTR(file);
+ path = RSTRING(file)->ptr;
}
GetX509Store(self, store);
lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file());
@@ -234,7 +227,7 @@ ossl_x509store_add_path(VALUE self, VALUE dir)
if(dir != Qnil){
Check_SafeStr(dir);
- path = RSTRING_PTR(dir);
+ path = RSTRING(dir)->ptr;
}
GetX509Store(self, store);
lookup = X509_STORE_add_lookup(store, X509_LOOKUP_hash_dir());
@@ -458,7 +451,7 @@ ossl_x509stctx_set_error(VALUE self, VALUE err)
X509_STORE_CTX *ctx;
GetX509StCtx(self, ctx);
- X509_STORE_CTX_set_error(ctx, NUM2INT(err));
+ X509_STORE_CTX_set_error(ctx, FIX2INT(err));
return err;
}
@@ -557,10 +550,6 @@ ossl_x509stctx_set_trust(VALUE self, VALUE trust)
return trust;
}
-/*
- * call-seq:
- * storectx.time = time => time
- */
static VALUE
ossl_x509stctx_set_time(VALUE self, VALUE time)
{
diff --git a/ext/openssl/ruby_missing.h b/ext/openssl/ruby_missing.h
index 64b76f26b4..f673bb157a 100644
--- a/ext/openssl/ruby_missing.h
+++ b/ext/openssl/ruby_missing.h
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: ruby_missing.h,v 1.3 2003/09/06 08:56:57 gotoyuzo Exp $
* 'OpenSSL for Ruby' project
* Copyright (C) 2001-2003 Michal Rokos <m.rokos@sh.cvut.cz>
* All rights reserved.
@@ -9,33 +9,10 @@
* (See the file 'LICENCE'.)
*/
#if !defined(_OSSL_RUBY_MISSING_H_)
-#define _OSSL_RUBY_MISSING_H_
+#define _OSS_RUBY_MISSING_H_
#define rb_define_copy_func(klass, func) \
rb_define_method(klass, "initialize_copy", func, 1)
+#endif /* _OSS_RUBY_MISSING_H_ */
-#ifndef GetReadFile
-#define FPTR_TO_FD(fptr) (fptr->fd)
-#else
-#define FPTR_TO_FD(fptr) (fileno(GetReadFile(fptr)))
-#endif
-
-#ifndef HAVE_RB_IO_T
-#define rb_io_t OpenFile
-#endif
-
-#ifndef HAVE_RB_STR_SET_LEN
-/* these methods should probably be backported to 1.8 */
-#define rb_str_set_len(str, length) do { \
- RSTRING(str)->ptr[length] = 0; \
- RSTRING(str)->len = length; \
-} while(0)
-#endif /* ! HAVE_RB_STR_SET_LEN */
-
-#ifndef HAVE_RB_BLOCK_CALL
-/* the openssl module doesn't use arg[3-4] and arg2 is always rb_each */
-#define rb_block_call(arg1, arg2, arg3, arg4, arg5, arg6) rb_iterate(rb_each, arg1, arg5, arg6)
-#endif /* ! HAVE_RB_BLOCK_CALL */
-
-#endif /* _OSSL_RUBY_MISSING_H_ */
diff --git a/ext/pty/expect_sample.rb b/ext/pty/expect_sample.rb
index 2a2e29f866..bf8a2352fe 100644
--- a/ext/pty/expect_sample.rb
+++ b/ext/pty/expect_sample.rb
@@ -15,6 +15,10 @@ PTY.spawn("ftp ftp.ruby-lang.org") do |r_f,w_f,pid|
$expect_verbose = false
+ r_f.expect(/^Name.*: /) do
+ w_f.print "ftp\n"
+ end
+
if !ENV['USER'].nil?
username = ENV['USER']
elsif !ENV['LOGNAME'].nil?
@@ -23,16 +27,19 @@ PTY.spawn("ftp ftp.ruby-lang.org") do |r_f,w_f,pid|
username = 'guest'
end
- r_f.expect(/^(Name).*: |(word):|> /) do
- w_f.puts($1 ? "ftp" : $2 ? "#{username}@" : "cd pub/ruby")
+ r_f.expect('word:') do
+ w_f.print username+"@\n"
+ end
+ r_f.expect("> ") do
+ w_f.print "cd pub/ruby\n"
end
r_f.expect("> ") do
w_f.print "dir\n"
end
- r_f.expect(/[^\-]> /) do |output|
+ r_f.expect("> ") do |output|
for x in output[0].split("\n")
- if x =~ /(ruby.*?\.tar\.gz)/ then
+ if x =~ /(ruby.*\.tar\.gz)/ then
fnames.push $1
end
end
diff --git a/ext/pty/pty.c b/ext/pty/pty.c
index 939335242f..93fb5c0118 100644
--- a/ext/pty/pty.c
+++ b/ext/pty/pty.c
@@ -39,10 +39,10 @@
#if !defined(HAVE_OPENPTY)
#if defined(__hpux)
-static const
-char MasterDevice[] = "/dev/ptym/pty%s",
- SlaveDevice[] = "/dev/pty/tty%s",
- *const deviceNo[] = {
+static
+char *MasterDevice = "/dev/ptym/pty%s",
+ *SlaveDevice = "/dev/pty/tty%s",
+ *deviceNo[] = {
"p0","p1","p2","p3","p4","p5","p6","p7",
"p8","p9","pa","pb","pc","pd","pe","pf",
"q0","q1","q2","q3","q4","q5","q6","q7",
@@ -62,10 +62,10 @@ char MasterDevice[] = "/dev/ptym/pty%s",
0,
};
#elif defined(_IBMESA) /* AIX/ESA */
-static const
-char MasterDevice[] = "/dev/ptyp%s",
- SlaveDevice[] = "/dev/ttyp%s",
- *const deviceNo[] = {
+static
+char *MasterDevice = "/dev/ptyp%s",
+ *SlaveDevice = "/dev/ttyp%s",
+ *deviceNo[] = {
"00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f",
"10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f",
"20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f",
@@ -84,10 +84,10 @@ 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 const
-char MasterDevice[] = "/dev/pty%s",
- SlaveDevice[] = "/dev/tty%s",
- *const deviceNo[] = {
+static
+char *MasterDevice = "/dev/pty%s",
+ *SlaveDevice = "/dev/tty%s",
+ *deviceNo[] = {
"p0","p1","p2","p3","p4","p5","p6","p7",
"p8","p9","pa","pb","pc","pd","pe","pf",
"q0","q1","q2","q3","q4","q5","q6","q7",
@@ -101,6 +101,8 @@ char MasterDevice[] = "/dev/pty%s",
#endif
#endif /* !defined(HAVE_OPENPTY) */
+static char SlaveName[DEVICELEN];
+
#ifndef HAVE_SETEUID
# ifdef HAVE_SETREUID
# define seteuid(e) setreuid(-1, (e))
@@ -137,7 +139,7 @@ raise_from_wait(state, info)
char buf[1024];
VALUE exc;
- snprintf(buf, sizeof(buf), "pty - %s: %ld", state, (long)info->child_pid);
+ snprintf(buf, sizeof(buf), "pty - %s: %d", state, info->child_pid);
exc = rb_exc_new2(eChildExited, buf);
rb_iv_set(exc, "status", rb_last_status);
rb_funcall(info->thread, rb_intern("raise"), 1, exc);
@@ -153,15 +155,17 @@ pty_syswait(info)
cpid = rb_waitpid(info->child_pid, &status, WUNTRACED);
if (cpid == -1) return Qnil;
-#if defined(WIFSTOPPED)
-#elif defined(IF_STOPPED)
-#define WIFSTOPPED(status) IF_STOPPED(status)
-#else
----->> Either IF_STOPPED or WIFSTOPPED is needed <<----
-#endif /* WIFSTOPPED | IF_STOPPED */
+#if defined(IF_STOPPED)
+ if (IF_STOPPED(status)) { /* suspend */
+ raise_from_wait("stopped", info);
+ }
+#elif defined(WIFSTOPPED)
if (WIFSTOPPED(status)) { /* suspend */
raise_from_wait("stopped", info);
}
+#else
+---->> Either IF_STOPPED or WIFSTOPPED is needed <<----
+#endif /* WIFSTOPPED | IF_STOPPED */
else if (kill(info->child_pid, 0) == 0) {
raise_from_wait("changed", info);
}
@@ -172,31 +176,27 @@ pty_syswait(info)
}
}
-static void getDevice _((int*, int*, char [DEVICELEN]));
+static void getDevice _((int*, int*));
struct exec_info {
int argc;
VALUE *argv;
};
-static VALUE pty_exec _((VALUE v));
-
static VALUE
-pty_exec(v)
- VALUE v;
+pty_exec(arg)
+ struct exec_info *arg;
{
- struct exec_info *arg = (struct exec_info *)v;
return rb_f_exec(arg->argc, arg->argv);
}
static void
-establishShell(argc, argv, info, SlaveName)
+establishShell(argc, argv, info)
int argc;
VALUE *argv;
struct pty_info *info;
- char SlaveName[DEVICELEN];
-{
- int i,master,slave;
+{
+ static int i,master,slave,currentPid;
char *p, tmp, *getenv();
struct passwd *pwent;
VALUE v;
@@ -220,9 +220,10 @@ establishShell(argc, argv, info, SlaveName)
argc = 1;
argv = &v;
}
- getDevice(&master, &slave, SlaveName);
+ getDevice(&master,&slave);
info->thread = rb_thread_current();
+ currentPid = getpid();
if((i = fork()) < 0) {
close(master);
close(slave);
@@ -230,6 +231,8 @@ establishShell(argc, argv, info, SlaveName)
}
if(i == 0) { /* child */
+ currentPid = getpid();
+
/*
* Set free from process group and controlling terminal
*/
@@ -241,7 +244,7 @@ establishShell(argc, argv, info, SlaveName)
if (setpgrp() == -1)
perror("setpgrp()");
# else /* SETGRP_VOID */
- if (setpgrp(0, getpid()) == -1)
+ if (setpgrp(0, currentPid) == -1)
rb_sys_fail("setpgrp()");
if ((i = open("/dev/tty", O_RDONLY)) < 0)
rb_sys_fail("/dev/tty");
@@ -304,9 +307,8 @@ pty_finalize_syswait(info)
}
static int
-get_device_once(master, slave, SlaveName, fail)
+get_device_once(master, slave, fail)
int *master, *slave, fail;
- char SlaveName[DEVICELEN];
{
#if defined HAVE_OPENPTY
/*
@@ -329,9 +331,10 @@ get_device_once(master, slave, SlaveName, fail)
}
*slave = open(name, O_RDWR);
- strncpy(SlaveName, name, sizeof SlaveName);
+ strcpy(SlaveName, name);
return 0;
+}
#else /* HAVE__GETPTY */
int i,j;
@@ -357,7 +360,7 @@ get_device_once(master, slave, SlaveName, fail)
#endif
*master = i;
*slave = j;
- strncpy(SlaveName, pn, sizeof SlaveName);
+ strcpy(SlaveName, pn);
return 0;
#if defined I_PUSH && !defined linux
}
@@ -376,10 +379,10 @@ get_device_once(master, slave, SlaveName, fail)
char MasterName[DEVICELEN];
for (p = deviceNo; *p != NULL; p++) {
- snprintf(MasterName, sizeof MasterName, MasterDevice, *p);
+ sprintf(MasterName,MasterDevice,*p);
if ((i = open(MasterName,O_RDWR,0)) >= 0) {
*master = i;
- snprintf(SlaveName, sizeof SlaveName, SlaveDevice, *p);
+ sprintf(SlaveName,SlaveDevice,*p);
if ((j = open(SlaveName,O_RDWR,0)) >= 0) {
*slave = j;
chown(SlaveName, getuid(), getgid());
@@ -396,16 +399,22 @@ get_device_once(master, slave, SlaveName, fail)
}
static void
-getDevice(master, slave, slavename)
+getDevice(master, slave)
int *master, *slave;
- char slavename[DEVICELEN];
{
- if (get_device_once(master, slave, slavename, 0)) {
+ if (get_device_once(master, slave, 0)) {
rb_gc();
- get_device_once(master, slave, slavename, 1);
+ get_device_once(master, slave, 1);
}
}
+static void
+freeDevice()
+{
+ chmod(SlaveName, 0666);
+ chown(SlaveName, 0, 0);
+}
+
/* ruby function: getpty */
static VALUE
pty_getpty(argc, argv, self)
@@ -416,15 +425,14 @@ pty_getpty(argc, argv, self)
VALUE res;
struct pty_info info;
struct pty_info thinfo;
- rb_io_t *wfptr,*rfptr;
+ OpenFile *wfptr,*rfptr;
VALUE rport = rb_obj_alloc(rb_cFile);
VALUE wport = rb_obj_alloc(rb_cFile);
- char SlaveName[DEVICELEN];
-
+
MakeOpenFile(rport, rfptr);
MakeOpenFile(wport, wfptr);
- establishShell(argc, argv, &info, SlaveName);
+ establishShell(argc, argv, &info);
rfptr->mode = rb_io_mode_flags("r");
rfptr->f = fdopen(info.fd, "r");
diff --git a/ext/purelib.rb b/ext/purelib.rb
deleted file mode 100644
index dbe514c34a..0000000000
--- a/ext/purelib.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-nul = nil
-$:.each_with_index {|path, index|
- if /\A(?:\.\/)*-\z/ =~ path
- nul = index
- break
- end
-}
-if nul
- $:[nul..-1] = ["."]
-end
diff --git a/ext/racc/cparse/cparse.c b/ext/racc/cparse/cparse.c
index 18a26f670f..197a0eb40b 100644
--- a/ext/racc/cparse/cparse.c
+++ b/ext/racc/cparse/cparse.c
@@ -393,6 +393,10 @@ 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 dd953a7e15..8516c2998a 100644
--- a/ext/racc/cparse/extconf.rb
+++ b/ext/racc/cparse/extconf.rb
@@ -1,4 +1,4 @@
-# $Id$
+# $Id: extconf.rb,v 1.1 2002/03/22 07:20:31 aamine Exp $
require 'mkmf'
create_makefile 'racc/cparse'
diff --git a/ext/readline/readline.c b/ext/readline/readline.c
index c9acaadac9..3625fadef8 100644
--- a/ext/readline/readline.c
+++ b/ext/readline/readline.c
@@ -34,11 +34,7 @@ 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
@@ -79,7 +75,7 @@ readline_readline(argc, argv, self)
char *prompt = NULL;
char *buff;
int status;
- rb_io_t *ofp, *ifp;
+ OpenFile *ofp, *ifp;
rb_secure(4);
if (rb_scan_args(argc, argv, "02", &tmp, &add_hist) > 0) {
diff --git a/ext/sdbm/_sdbm.c b/ext/sdbm/_sdbm.c
index 5b34824afc..7ffcf8579c 100644
--- a/ext/sdbm/_sdbm.c
+++ b/ext/sdbm/_sdbm.c
@@ -8,7 +8,7 @@
*/
#ifndef lint
-/*char sdbm_rcsid[] = "$Id$";*/
+/*char sdbm_rcsid[] = "$Id: _sdbm.c,v 1.5.2.1 2005/09/08 05:59:41 matz Exp $";*/
#endif
#include "sdbm.h"
@@ -626,7 +626,7 @@ register DBM *db;
*/
#ifndef lint
-/*char pair_rcsid[] = "$Id$";*/
+/*char pair_rcsid[] = "$Id: _sdbm.c,v 1.5.2.1 2005/09/08 05:59:41 matz Exp $";*/
#endif
#ifndef BSD42
diff --git a/ext/sdbm/init.c b/ext/sdbm/init.c
index acadc9b26a..ef4fb8ffbf 100644
--- a/ext/sdbm/init.c
+++ b/ext/sdbm/init.c
@@ -2,8 +2,8 @@
sdbminit.c -
- $Author$
- $Date$
+ $Author: ocean $
+ $Date: 2005/06/25 05:42:41 $
created at: Fri May 7 08:34:24 JST 1999
Copyright (C) 1995-2001 Yukihiro Matsumoto
diff --git a/ext/socket/addrinfo.h b/ext/socket/addrinfo.h
index e93adafba6..a22615ee00 100644
--- a/ext/socket/addrinfo.h
+++ b/ext/socket/addrinfo.h
@@ -61,15 +61,10 @@
#undef NI_NUMERICSERV
#undef NI_DGRAM
-#undef addrinfo
#define addrinfo addrinfo__compat
-#undef getaddrinfo
#define getaddrinfo getaddrinfo__compat
-#undef getnameinfo
#define getnameinfo getnameinfo__compat
-#undef freehostent
#define freehostent freehostent__compat
-#undef freeaddrinfo
#define freeaddrinfo freeaddrinfo__compat
#ifndef __P
diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb
index 8a13ddba73..41b715e0af 100644
--- a/ext/socket/extconf.rb
+++ b/ext/socket/extconf.rb
@@ -33,9 +33,6 @@ 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
@@ -156,10 +153,6 @@ 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
@@ -259,6 +252,7 @@ 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/socket.c b/ext/socket/socket.c
index 491823ad44..8558e99ee5 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -2,8 +2,8 @@
socket.c -
- $Author$
- $Date$
+ $Author: matz $
+ $Date: 2006/08/07 07:50:28 $
created at: Thu Mar 31 12:21:29 JST 1994
Copyright (C) 1993-2001 Yukihiro Matsumoto
@@ -42,9 +42,6 @@
#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>
@@ -198,34 +195,6 @@ 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
@@ -244,7 +213,7 @@ init_sock(sock, fd)
VALUE sock;
int fd;
{
- rb_io_t *fp;
+ OpenFile *fp;
MakeOpenFile(sock, fp);
fp->f = rb_fdopen(fd, "r");
@@ -259,7 +228,7 @@ static VALUE
bsock_s_for_fd(klass, fd)
VALUE klass, fd;
{
- rb_io_t *fptr;
+ OpenFile *fptr;
VALUE sock = init_sock(rb_obj_alloc(klass), NUM2INT(fd));
GetOpenFile(sock, fptr);
@@ -275,7 +244,7 @@ bsock_shutdown(argc, argv, sock)
{
VALUE howto;
int how;
- rb_io_t *fptr;
+ OpenFile *fptr;
if (rb_safe_level() >= 4 && !OBJ_TAINTED(sock)) {
rb_raise(rb_eSecurityError, "Insecure: can't shutdown socket");
@@ -300,7 +269,7 @@ static VALUE
bsock_close_read(sock)
VALUE sock;
{
- rb_io_t *fptr;
+ OpenFile *fptr;
if (rb_safe_level() >= 4 && !OBJ_TAINTED(sock)) {
rb_raise(rb_eSecurityError, "Insecure: can't close socket");
@@ -319,7 +288,7 @@ static VALUE
bsock_close_write(sock)
VALUE sock;
{
- rb_io_t *fptr;
+ OpenFile *fptr;
if (rb_safe_level() >= 4 && !OBJ_TAINTED(sock)) {
rb_raise(rb_eSecurityError, "Insecure: can't close socket");
@@ -384,7 +353,7 @@ bsock_setsockopt(sock, lev, optname, val)
VALUE sock, lev, optname, val;
{
int level, option;
- rb_io_t *fptr;
+ OpenFile *fptr;
int i;
char *v;
int vlen;
@@ -467,7 +436,7 @@ bsock_getsockopt(sock, lev, optname)
int level, option;
socklen_t len;
char *buf;
- rb_io_t *fptr;
+ OpenFile *fptr;
level = NUM2INT(lev);
option = NUM2INT(optname);
@@ -491,7 +460,7 @@ bsock_getsockname(sock)
{
char buf[1024];
socklen_t len = sizeof buf;
- rb_io_t *fptr;
+ OpenFile *fptr;
GetOpenFile(sock, fptr);
if (getsockname(fileno(fptr->f), (struct sockaddr*)buf, &len) < 0)
@@ -505,7 +474,7 @@ bsock_getpeername(sock)
{
char buf[1024];
socklen_t len = sizeof buf;
- rb_io_t *fptr;
+ OpenFile *fptr;
GetOpenFile(sock, fptr);
if (getpeername(fileno(fptr->f), (struct sockaddr*)buf, &len) < 0)
@@ -521,7 +490,7 @@ bsock_send(argc, argv, sock)
{
VALUE mesg, to;
VALUE flags;
- rb_io_t *fptr;
+ OpenFile *fptr;
FILE *f;
int fd, n;
@@ -574,7 +543,7 @@ s_recvfrom(sock, argc, argv, from)
VALUE *argv;
enum sock_recv_type from;
{
- rb_io_t *fptr;
+ OpenFile *fptr;
VALUE str;
char buf[1024];
socklen_t alen = sizeof buf;
@@ -644,7 +613,7 @@ s_recvfrom(sock, argc, argv, from)
static VALUE
s_recvfrom_nonblock(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from)
{
- rb_io_t *fptr;
+ OpenFile *fptr;
VALUE str;
char buf[1024];
socklen_t alen = sizeof buf;
@@ -840,7 +809,7 @@ host_str(host, hbuf, len)
return NULL;
}
else if (rb_obj_is_kind_of(host, rb_cInteger)) {
- unsigned long i = NUM2ULONG(host);
+ long i = NUM2LONG(host);
make_inetaddr(htonl(i), hbuf, len);
return hbuf;
@@ -893,10 +862,10 @@ port_str(port, pbuf, len)
}
#ifndef NI_MAXHOST
-# define NI_MAXHOST 1025
+# define 1025
#endif
#ifndef NI_MAXSERV
-# define NI_MAXSERV 32
+# define 32
#endif
static struct addrinfo*
@@ -1085,8 +1054,7 @@ ruby_connect(fd, sockaddr, len, socks)
int mode;
#if WAIT_IN_PROGRESS > 0
int wait_in_progress = -1;
- int sockerr;
- socklen_t sockerrlen;
+ int sockerr, sockerrlen;
#endif
#if defined(HAVE_FCNTL)
@@ -1306,14 +1274,6 @@ 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;
@@ -1350,7 +1310,7 @@ static VALUE
socks_s_close(sock)
VALUE sock;
{
- rb_io_t *fptr;
+ OpenFile *fptr;
if (rb_safe_level() >= 4 && !OBJ_TAINTED(sock)) {
rb_raise(rb_eSecurityError, "Insecure: can't close socket");
@@ -1483,7 +1443,7 @@ make_fd_nonblock(int fd)
}
static VALUE
-s_accept_nonblock(VALUE klass, rb_io_t *fptr, struct sockaddr *sockaddr, socklen_t *len)
+s_accept_nonblock(VALUE klass, OpenFile *fptr, struct sockaddr *sockaddr, socklen_t *len)
{
int fd2;
@@ -1542,7 +1502,7 @@ static VALUE
tcp_accept(sock)
VALUE sock;
{
- rb_io_t *fptr;
+ OpenFile *fptr;
struct sockaddr_storage from;
socklen_t fromlen;
@@ -1565,7 +1525,7 @@ tcp_accept(sock)
* serv = TCPServer.new(2202)
* begin
* sock = serv.accept_nonblock
- * rescue Errno::EAGAIN, Errno::EWOULDBLOCK, Errno::ECONNABORTED, Errno::EPROTO, Errno::EINTR
+ * rescue Errno::EAGAIN, Errno::ECONNABORTED, Errno::EPROTO, Errno::EINTR
* IO.select([serv])
* retry
* end
@@ -1585,7 +1545,7 @@ static VALUE
tcp_accept_nonblock(sock)
VALUE sock;
{
- rb_io_t *fptr;
+ OpenFile *fptr;
struct sockaddr_storage from;
socklen_t fromlen;
@@ -1599,7 +1559,7 @@ static VALUE
tcp_sysaccept(sock)
VALUE sock;
{
- rb_io_t *fptr;
+ OpenFile *fptr;
struct sockaddr_storage from;
socklen_t fromlen;
@@ -1630,7 +1590,7 @@ init_unixsock(sock, path, server)
{
struct sockaddr_un sockaddr;
int fd, status;
- rb_io_t *fptr;
+ OpenFile *fptr;
SafeStringValue(path);
fd = ruby_socket(AF_UNIX, SOCK_STREAM, 0);
@@ -1682,7 +1642,7 @@ static VALUE
ip_addr(sock)
VALUE sock;
{
- rb_io_t *fptr;
+ OpenFile *fptr;
struct sockaddr_storage addr;
socklen_t len = sizeof addr;
@@ -1697,7 +1657,7 @@ static VALUE
ip_peeraddr(sock)
VALUE sock;
{
- rb_io_t *fptr;
+ OpenFile *fptr;
struct sockaddr_storage addr;
socklen_t len = sizeof addr;
@@ -1778,7 +1738,7 @@ static VALUE
udp_connect(sock, host, port)
VALUE sock, host, port;
{
- rb_io_t *fptr;
+ OpenFile *fptr;
struct udp_arg arg;
VALUE ret;
@@ -1796,7 +1756,7 @@ static VALUE
udp_bind(sock, host, port)
VALUE sock, host, port;
{
- rb_io_t *fptr;
+ OpenFile *fptr;
struct addrinfo *res0, *res;
rb_secure(3);
@@ -1821,7 +1781,7 @@ udp_send(argc, argv, sock)
VALUE sock;
{
VALUE mesg, flags, host, port;
- rb_io_t *fptr;
+ OpenFile *fptr;
FILE *f;
int n;
struct addrinfo *res0, *res;
@@ -1920,7 +1880,7 @@ static VALUE
unix_path(sock)
VALUE sock;
{
- rb_io_t *fptr;
+ OpenFile *fptr;
GetOpenFile(sock, fptr);
if (fptr->path == 0) {
@@ -1967,7 +1927,7 @@ unix_send_io(sock, val)
{
#if defined(HAVE_SENDMSG) && (FD_PASSING_BY_MSG_CONTROL || FD_PASSING_BY_MSG_ACCRIGHTS)
int fd;
- rb_io_t *fptr;
+ OpenFile *fptr;
struct msghdr msg;
struct iovec vec[1];
char buf[1];
@@ -1975,12 +1935,12 @@ unix_send_io(sock, val)
#if FD_PASSING_BY_MSG_CONTROL
struct {
struct cmsghdr hdr;
- char pad[8+sizeof(int)+8];
+ int fd;
} cmsg;
#endif
if (rb_obj_is_kind_of(val, rb_cIO)) {
- rb_io_t *valfptr;
+ OpenFile *valfptr;
GetOpenFile(val, valfptr);
fd = fileno(valfptr->f);
}
@@ -2005,13 +1965,12 @@ unix_send_io(sock, val)
#if FD_PASSING_BY_MSG_CONTROL
msg.msg_control = (caddr_t)&cmsg;
- msg.msg_controllen = CMSG_LEN(sizeof(int));
+ msg.msg_controllen = CMSG_SPACE(sizeof(int));
msg.msg_flags = 0;
- MEMZERO((char*)&cmsg, char, sizeof(cmsg));
cmsg.hdr.cmsg_len = CMSG_LEN(sizeof(int));
cmsg.hdr.cmsg_level = SOL_SOCKET;
cmsg.hdr.cmsg_type = SCM_RIGHTS;
- *(int *)CMSG_DATA(&cmsg.hdr) = fd;
+ cmsg.fd = fd;
#else
msg.msg_accrights = (caddr_t)&fd;
msg.msg_accrightslen = sizeof(fd);
@@ -2048,7 +2007,7 @@ unix_recv_io(argc, argv, sock)
{
#if defined(HAVE_RECVMSG) && (FD_PASSING_BY_MSG_CONTROL || FD_PASSING_BY_MSG_ACCRIGHTS)
VALUE klass, mode;
- rb_io_t *fptr;
+ OpenFile *fptr;
struct msghdr msg;
struct iovec vec[2];
char buf[1];
@@ -2057,7 +2016,7 @@ unix_recv_io(argc, argv, sock)
#if FD_PASSING_BY_MSG_CONTROL
struct {
struct cmsghdr hdr;
- char pad[8+sizeof(int)+8];
+ int fd;
} cmsg;
#endif
@@ -2086,7 +2045,7 @@ unix_recv_io(argc, argv, sock)
cmsg.hdr.cmsg_len = CMSG_LEN(sizeof(int));
cmsg.hdr.cmsg_level = SOL_SOCKET;
cmsg.hdr.cmsg_type = SCM_RIGHTS;
- *(int *)CMSG_DATA(&cmsg.hdr) = -1;
+ cmsg.fd = -1;
#else
msg.msg_accrights = (caddr_t)&fd;
msg.msg_accrightslen = sizeof(fd);
@@ -2099,22 +2058,22 @@ unix_recv_io(argc, argv, sock)
#if FD_PASSING_BY_MSG_CONTROL
if (msg.msg_controllen != CMSG_SPACE(sizeof(int))) {
rb_raise(rb_eSocket,
- "file descriptor was not passed (msg_controllen=%d, %d expected)",
+ "file descriptor was not passed (msg_controllen : %d != %d)",
msg.msg_controllen, CMSG_SPACE(sizeof(int)));
}
- if (cmsg.hdr.cmsg_len != CMSG_LEN(sizeof(int))) {
+ if (cmsg.hdr.cmsg_len != CMSG_SPACE(0) + sizeof(int)) {
rb_raise(rb_eSocket,
- "file descriptor was not passed (cmsg_len=%d, %d expected)",
- cmsg.hdr.cmsg_len, CMSG_LEN(sizeof(int)));
+ "file descriptor was not passed (cmsg_len : %d != %d)",
+ cmsg.hdr.cmsg_len, CMSG_SPACE(0) + sizeof(int));
}
if (cmsg.hdr.cmsg_level != SOL_SOCKET) {
rb_raise(rb_eSocket,
- "file descriptor was not passed (cmsg_level=%d, %d expected)",
+ "file descriptor was not passed (cmsg_level : %d != %d)",
cmsg.hdr.cmsg_level, SOL_SOCKET);
}
if (cmsg.hdr.cmsg_type != SCM_RIGHTS) {
rb_raise(rb_eSocket,
- "file descriptor was not passed (cmsg_type=%d, %d expected)",
+ "file descriptor was not passed (cmsg_type : %d != %d)",
cmsg.hdr.cmsg_type, SCM_RIGHTS);
}
#else
@@ -2126,7 +2085,7 @@ unix_recv_io(argc, argv, sock)
#endif
#if FD_PASSING_BY_MSG_CONTROL
- fd = *(int *)CMSG_DATA(&cmsg.hdr);
+ fd = cmsg.fd;
#endif
if (klass == Qnil)
@@ -2152,7 +2111,7 @@ static VALUE
unix_accept(sock)
VALUE sock;
{
- rb_io_t *fptr;
+ OpenFile *fptr;
struct sockaddr_un from;
socklen_t fromlen;
@@ -2175,7 +2134,7 @@ unix_accept(sock)
* serv = UNIXServer.new("/tmp/sock")
* begin
* sock = serv.accept_nonblock
- * rescue Errno::EAGAIN, Errno::EWOULDBLOCK, Errno::ECONNABORTED, Errno::EPROTO, Errno::EINTR
+ * rescue Errno::EAGAIN, Errno::ECONNABORTED, Errno::EPROTO, Errno::EINTR
* IO.select([serv])
* retry
* end
@@ -2195,7 +2154,7 @@ static VALUE
unix_accept_nonblock(sock)
VALUE sock;
{
- rb_io_t *fptr;
+ OpenFile *fptr;
struct sockaddr_un from;
socklen_t fromlen;
@@ -2209,7 +2168,7 @@ static VALUE
unix_sysaccept(sock)
VALUE sock;
{
- rb_io_t *fptr;
+ OpenFile *fptr;
struct sockaddr_un from;
socklen_t fromlen;
@@ -2231,7 +2190,7 @@ static VALUE
unix_addr(sock)
VALUE sock;
{
- rb_io_t *fptr;
+ OpenFile *fptr;
struct sockaddr_un addr;
socklen_t len = sizeof addr;
@@ -2246,14 +2205,14 @@ static VALUE
unix_peeraddr(sock)
VALUE sock;
{
- rb_io_t *fptr;
+ OpenFile *fptr;
struct sockaddr_un addr;
socklen_t len = sizeof addr;
GetOpenFile(sock, fptr);
if (getpeername(fileno(fptr->f), (struct sockaddr*)&addr, &len) < 0)
- rb_sys_fail("getpeername(2)");
+ rb_sys_fail("getsockname(2)");
return unixaddr(&addr, len);
}
#endif
@@ -2526,7 +2485,7 @@ static VALUE
sock_connect(sock, addr)
VALUE sock, addr;
{
- rb_io_t *fptr;
+ OpenFile *fptr;
int fd;
StringValue(addr);
@@ -2582,7 +2541,7 @@ static VALUE
sock_connect_nonblock(sock, addr)
VALUE sock, addr;
{
- rb_io_t *fptr;
+ OpenFile *fptr;
int n;
StringValue(addr);
@@ -2680,7 +2639,7 @@ static VALUE
sock_bind(sock, addr)
VALUE sock, addr;
{
- rb_io_t *fptr;
+ OpenFile *fptr;
StringValue(addr);
GetOpenFile(sock, fptr);
@@ -2764,7 +2723,7 @@ static VALUE
sock_listen(sock, log)
VALUE sock, log;
{
- rb_io_t *fptr;
+ OpenFile *fptr;
int backlog;
rb_secure(4);
@@ -2921,7 +2880,7 @@ sock_recvfrom(argc, argv, sock)
* client, client_sockaddr = socket.accept
* begin
* pair = client.recvfrom_nonblock(20)
- * rescue Errno::EAGAIN, Errno::EWOULDBLOCK
+ * rescue Errno::EAGAIN
* IO.select([client])
* retry
* end
@@ -2971,7 +2930,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, '#{client.readline.chomp}'"
+ * puts "The client said, '#{socket.readline.chomp}'"
* client.puts "Hello from script one!"
* socket.close
*
@@ -3040,7 +2999,7 @@ static VALUE
sock_accept(sock)
VALUE sock;
{
- rb_io_t *fptr;
+ OpenFile *fptr;
VALUE sock2;
char buf[1024];
socklen_t len = sizeof buf;
@@ -3072,11 +3031,11 @@ sock_accept(sock)
* socket.listen(5)
* begin
* client_socket, client_sockaddr = socket.accept_nonblock
- * rescue Errno::EAGAIN, Errno::EWOULDBLOCK, Errno::ECONNABORTED, Errno::EPROTO, Errno::EINTR
+ * rescue Errno::EAGAIN, Errno::ECONNABORTED, Errno::EPROTO, Errno::EINTR
* IO.select([socket])
* retry
* end
- * puts "The client said, '#{client_socket.readline.chomp}'"
+ * puts "The client said, '#{socket.readline.chomp}'"
* client_socket.puts "Hello from script one!"
* socket.close
*
@@ -3103,7 +3062,7 @@ static VALUE
sock_accept_nonblock(sock)
VALUE sock;
{
- rb_io_t *fptr;
+ OpenFile *fptr;
VALUE sock2;
char buf[1024];
socklen_t len = sizeof buf;
@@ -3131,8 +3090,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
*
@@ -3156,7 +3115,7 @@ static VALUE
sock_sysaccept(sock)
VALUE sock;
{
- rb_io_t *fptr;
+ OpenFile *fptr;
VALUE sock2;
char buf[1024];
socklen_t len = sizeof buf;
diff --git a/ext/socket/sockport.h b/ext/socket/sockport.h
index e1cddf53f4..8c7bebf558 100644
--- a/ext/socket/sockport.h
+++ b/ext/socket/sockport.h
@@ -2,8 +2,8 @@
sockport.h -
- $Author$
- $Date$
+ $Author: eban $
+ $Date: 2000/08/24 06:29:30 $
created at: Fri Apr 30 23:19:34 JST 1999
************************************************/
diff --git a/ext/stringio/README b/ext/stringio/README
index c4031f7e97..190052309c 100644
--- a/ext/stringio/README
+++ b/ext/stringio/README
@@ -1,6 +1,6 @@
-*- rd -*-
-$Author$
-$Date$
+$Author: nobu $
+$Date: 2002/02/19 13:16:24 $
=begin
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c
index 71b7b69f71..fcc596d5f0 100644
--- a/ext/stringio/stringio.c
+++ b/ext/stringio/stringio.c
@@ -2,8 +2,8 @@
stringio.c -
- $Author$
- $Date$
+ $Author: nobu $
+ $Date: 2005/08/13 09:36:12 $
$RoughId: stringio.c,v 1.13 2002/03/14 03:24:18 nobu Exp $
created at: Tue Feb 19 04:10:38 JST 2002
@@ -14,7 +14,6 @@
#include "ruby.h"
#include "rubyio.h"
-#include "re.h"
#if defined(HAVE_FCNTL_H) || defined(_WIN32)
#include <fcntl.h>
#elif defined(HAVE_SYS_FCNTL_H)
@@ -163,7 +162,6 @@ static VALUE strio_rewind _((VALUE));
static VALUE strio_seek _((int, VALUE *, VALUE));
static VALUE strio_get_sync _((VALUE));
static VALUE strio_each_byte _((VALUE));
-static VALUE strio_each_char _((VALUE));
static VALUE strio_getc _((VALUE));
static VALUE strio_ungetc _((VALUE, VALUE));
static VALUE strio_readchar _((VALUE));
@@ -659,9 +657,6 @@ strio_seek(argc, argv, self)
rb_scan_args(argc, argv, "11", NULL, &whence);
offset = NUM2LONG(argv[0]);
- if (CLOSED(ptr)) {
- rb_raise(rb_eIOError, "closed stream");
- }
switch (NIL_P(whence) ? 0 : NUM2LONG(whence)) {
case 0:
break;
@@ -672,7 +667,7 @@ strio_seek(argc, argv, self)
offset += RSTRING(ptr->string)->len;
break;
default:
- error_inval("invalid whence");
+ rb_raise(rb_eArgError, "invalid whence %ld", NUM2LONG(whence));
}
if (offset < 0) {
error_inval(0);
@@ -712,14 +707,11 @@ strio_each_byte(self)
VALUE self;
{
struct StringIO *ptr = readable(StringIO(self));
-
- RETURN_ENUMERATOR(self, 0, 0);
-
- while (ptr->pos < RSTRING_LEN(ptr->string)) {
- char c = RSTRING_PTR(ptr->string)[ptr->pos++];
+ while (ptr->pos < RSTRING(ptr->string)->len) {
+ char c = RSTRING(ptr->string)->ptr[ptr->pos++];
rb_yield(CHR2FIX(c));
}
- return self;
+ return Qnil;
}
/*
@@ -779,24 +771,15 @@ strio_ungetc(self, ch)
int cc = NUM2INT(ch);
long len, pos = ptr->pos;
- if (cc != EOF) {
- len = RSTRING(ptr->string)->len;
- if (pos == 0) {
- char *p;
- rb_str_resize(ptr->string, len + 1);
- p = RSTRING(ptr->string)->ptr;
- memmove(p + 1, p, len);
+ if (cc != EOF && pos > 0) {
+ if ((len = RSTRING(ptr->string)->len) < pos-- ||
+ (unsigned char)RSTRING(ptr->string)->ptr[pos] !=
+ (unsigned char)cc) {
+ strio_extend(ptr, pos, 1);
+ RSTRING(ptr->string)->ptr[pos] = cc;
+ OBJ_INFECT(ptr->string, self);
}
- else {
- if (len < pos-- ||
- (unsigned char)RSTRING(ptr->string)->ptr[pos] !=
- (unsigned char)cc) {
- strio_extend(ptr, pos, 1);
- }
- --ptr->pos;
- }
- RSTRING(ptr->string)->ptr[pos] = cc;
- OBJ_INFECT(ptr->string, self);
+ --ptr->pos;
ptr->flags &= ~STRIO_EOF;
}
return Qnil;
@@ -817,41 +800,6 @@ strio_readchar(self)
return c;
}
-/*
- * call-seq:
- * strio.each_char {|char| block } -> strio
- *
- * See IO#each_char.
- */
-static VALUE
-strio_each_char(self)
- VALUE self;
-{
- struct StringIO *sio;
- VALUE str;
- const char *ptr;
- size_t len;
-
- RETURN_ENUMERATOR(self, 0, 0);
-
- sio = readable(StringIO(self));
- str = sio->string;
- ptr = RSTRING_PTR(str);
- len = RSTRING_LEN(str);
-
- while (sio->pos < len) {
- int pos = sio->pos;
- char c = ptr[pos];
- int n = mbclen(c);
-
- if (len < pos + n) n = len - pos;
-
- sio->pos += n;
- rb_yield(rb_str_substr(str, pos, n));
- }
- return self;
-}
-
static void
bm_init_skip(skip, pat, m)
long *skip;
@@ -999,7 +947,7 @@ strio_readline(argc, argv, self)
VALUE *argv;
VALUE self;
{
- VALUE line = strio_gets(argc, argv, self);
+ VALUE line = strio_getline(argc, argv, readable(StringIO(self)));
if (NIL_P(line)) rb_eof_error();
return line;
}
@@ -1020,8 +968,6 @@ strio_each(argc, argv, self)
struct StringIO *ptr = StringIO(self);
VALUE line;
- RETURN_ENUMERATOR(self, argc, argv);
-
while (!NIL_P(line = strio_getline(argc, argv, readable(ptr)))) {
rb_yield(line);
}
@@ -1345,17 +1291,11 @@ Init_stringio()
rb_define_method(StringIO, "path", strio_path, 0);
rb_define_method(StringIO, "each", strio_each, -1);
- rb_define_method(StringIO, "each_line", strio_each, -1);
- rb_define_method(StringIO, "lines", strio_each, -1);
rb_define_method(StringIO, "each_byte", strio_each_byte, 0);
- rb_define_method(StringIO, "bytes", strio_each_byte, 0);
- rb_define_method(StringIO, "each_char", strio_each_char, 0);
- rb_define_method(StringIO, "chars", strio_each_char, 0);
+ rb_define_method(StringIO, "each_line", strio_each, -1);
rb_define_method(StringIO, "getc", strio_getc, 0);
- rb_define_method(StringIO, "getbyte", strio_getc, 0);
rb_define_method(StringIO, "ungetc", strio_ungetc, 1);
rb_define_method(StringIO, "readchar", strio_readchar, 0);
- rb_define_method(StringIO, "readbyte", strio_readchar, 0);
rb_define_method(StringIO, "gets", strio_gets, -1);
rb_define_method(StringIO, "readline", strio_readline, -1);
rb_define_method(StringIO, "readlines", strio_readlines, -1);
diff --git a/ext/strscan/strscan.c b/ext/strscan/strscan.c
index b5ee20282c..5e5ab5db1f 100644
--- a/ext/strscan/strscan.c
+++ b/ext/strscan/strscan.c
@@ -1,5 +1,5 @@
/*
- $Id$
+ $Id: strscan.c,v 1.7.2.8 2006/07/26 09:37:00 aamine Exp $
Copyright (c) 1999-2006 Minero Aoki
@@ -403,7 +403,6 @@ 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),
@@ -417,7 +416,6 @@ 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) {
@@ -1258,7 +1256,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$");
+ tmp = rb_str_new2("$Id: strscan.c,v 1.7.2.8 2006/07/26 09:37:00 aamine Exp $");
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 567aaf52a8..acda3b15a4 100644
--- a/ext/syck/bytecode.c
+++ b/ext/syck/bytecode.c
@@ -3,8 +3,8 @@
/*
* bytecode.re
*
- * $Author$
- * $Date$
+ * $Author: why $
+ * $Date: 2005/09/20 06:46:43 $
*
* Copyright (C) 2003 why the lucky stiff
*/
diff --git a/ext/syck/emitter.c b/ext/syck/emitter.c
index 9c8ab8d49b..8d32784cd5 100644
--- a/ext/syck/emitter.c
+++ b/ext/syck/emitter.c
@@ -1,8 +1,8 @@
/*
* emitter.c
*
- * $Author$
- * $Date$
+ * $Author: matz $
+ * $Date: 2006/05/03 17:29:34 $
*
* Copyright (C) 2003 why the lucky stiff
*
diff --git a/ext/syck/handler.c b/ext/syck/handler.c
index 56fe838fbd..26fb258318 100644
--- a/ext/syck/handler.c
+++ b/ext/syck/handler.c
@@ -1,8 +1,8 @@
/*
* handler.c
*
- * $Author$
- * $Date$
+ * $Author: why $
+ * $Date: 2005/09/20 06:46:43 $
*
* Copyright (C) 2003 why the lucky stiff
*/
diff --git a/ext/syck/implicit.c b/ext/syck/implicit.c
index d356faf7d9..0f922f4d1b 100644
--- a/ext/syck/implicit.c
+++ b/ext/syck/implicit.c
@@ -3,8 +3,8 @@
/*
* implicit.re
*
- * $Author$
- * $Date$
+ * $Author: ocean $
+ * $Date: 2005/10/26 00:28:39 $
*
* Copyright (C) 2003 why the lucky stiff
*/
diff --git a/ext/syck/node.c b/ext/syck/node.c
index 28fc78c077..724f747e99 100644
--- a/ext/syck/node.c
+++ b/ext/syck/node.c
@@ -1,8 +1,8 @@
/*
* node.c
*
- * $Author$
- * $Date$
+ * $Author: matz $
+ * $Date: 2005/09/16 09:35:23 $
*
* Copyright (C) 2003 why the lucky stiff
*/
diff --git a/ext/syck/rubyext.c b/ext/syck/rubyext.c
index 76e8279601..8cd2da7c4e 100644
--- a/ext/syck/rubyext.c
+++ b/ext/syck/rubyext.c
@@ -2,8 +2,8 @@
/*
* rubyext.c
*
- * $Author$
- * $Date$
+ * $Author: ocean $
+ * $Date: 2006/01/30 15:11:57 $
*
* Copyright (C) 2003-2005 why the lucky stiff
*/
@@ -268,13 +268,9 @@ rb_syck_mktime(str, len)
{
char padded[] = "000000";
char *end = ptr + 1;
- char *p = end;
while ( isdigit( *end ) ) end++;
- if (end - p < sizeof(padded)) {
- MEMCPY(padded, ptr + 1, char, end - (ptr + 1));
- p = padded;
- }
- usec = strtol(p, NULL, 10);
+ MEMCPY(padded, ptr + 1, char, end - (ptr + 1));
+ usec = strtol(padded, NULL, 10);
}
else
{
@@ -917,6 +913,7 @@ static VALUE
syck_resolver_initialize( self )
VALUE self;
{
+ VALUE tags = rb_hash_new();
rb_ivar_set(self, s_tags, rb_hash_new());
return self;
}
@@ -951,6 +948,7 @@ VALUE
syck_resolver_detect_implicit( self, val )
VALUE self, val;
{
+ char *type_id;
return rb_str_new2( "" );
}
@@ -1306,6 +1304,7 @@ syck_genericresolver_node_import( self, node )
break;
case syck_seq_kind:
+ rb_iv_set(obj, "@kind", sym_seq);
v = rb_ary_new2( syck_seq_count( n ) );
for ( i = 0; i < syck_seq_count( n ); i++ )
{
@@ -1316,10 +1315,10 @@ syck_genericresolver_node_import( self, node )
style = sym_inline;
}
obj = rb_funcall( cSeq, s_new, 3, t, v, style );
- rb_iv_set(obj, "@kind", sym_seq);
break;
case syck_map_kind:
+ rb_iv_set(obj, "@kind", sym_map);
v = rb_hash_new();
for ( i = 0; i < syck_map_count( n ); i++ )
{
@@ -1330,7 +1329,6 @@ syck_genericresolver_node_import( self, node )
style = sym_inline;
}
obj = rb_funcall( cMap, s_new, 3, t, v, style );
- rb_iv_set(obj, "@kind", sym_map);
break;
}
@@ -2026,6 +2024,7 @@ syck_emitter_emit( argc, argv, self )
VALUE self;
{
VALUE oid, proc;
+ char *anchor_name;
SyckEmitter *emitter;
struct emitter_xtra *bonus;
SYMID symple;
diff --git a/ext/syck/syck.c b/ext/syck/syck.c
index a83c8813c1..ac5427bc1b 100644
--- a/ext/syck/syck.c
+++ b/ext/syck/syck.c
@@ -1,8 +1,8 @@
/*
* syck.c
*
- * $Author$
- * $Date$
+ * $Author: matz $
+ * $Date: 2006/08/07 08:09:34 $
*
* Copyright (C) 2003 why the lucky stiff
*/
diff --git a/ext/syck/syck.h b/ext/syck/syck.h
index e7d07e9c0d..bc383ff2de 100644
--- a/ext/syck/syck.h
+++ b/ext/syck/syck.h
@@ -1,8 +1,8 @@
/*
* syck.h
*
- * $Author$
- * $Date$
+ * $Author: ocean $
+ * $Date: 2005/12/20 04:13:26 $
*
* Copyright (C) 2003 why the lucky stiff
*/
diff --git a/ext/syck/token.c b/ext/syck/token.c
index 3c6cd1a9cf..e7b0414f74 100644
--- a/ext/syck/token.c
+++ b/ext/syck/token.c
@@ -3,8 +3,8 @@
/*
* token.re
*
- * $Author$
- * $Date$
+ * $Author: why $
+ * $Date: 2005/09/20 23:56:24 $
*
* Copyright (C) 2003 why the lucky stiff
*/
diff --git a/ext/syck/yaml2byte.c b/ext/syck/yaml2byte.c
index 821a3cd5b5..01a3aaf652 100644
--- a/ext/syck/yaml2byte.c
+++ b/ext/syck/yaml2byte.c
@@ -1,8 +1,8 @@
/*
* yaml2byte.c
*
- * $Author$
- * $Date$
+ * $Author: matz $
+ * $Date: 2006/05/03 17:41:10 $
*
* Copyright (C) 2003 why the lucky stiff, clark evans
*
diff --git a/ext/syslog/extconf.rb b/ext/syslog/extconf.rb
index 0fa0bc339b..d47ed8fd61 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$
+# $Id: extconf.rb,v 1.1 2001/11/26 12:00:40 knu Exp $
require 'mkmf'
diff --git a/ext/syslog/syslog.c b/ext/syslog/syslog.c
index ecc49318f7..99e4215a95 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$
+ * $Id: syslog.c,v 1.8.2.1 2004/04/05 07:45:24 matz Exp $
*/
#include "ruby.h"
@@ -22,7 +22,6 @@ static void syslog_write(int pri, int argc, VALUE *argv)
{
VALUE str;
- rb_secure(4);
if (argc < 1) {
rb_raise(rb_eArgError, "no log message supplied");
}
@@ -39,7 +38,6 @@ static void syslog_write(int pri, int argc, VALUE *argv)
/* Syslog module methods */
static VALUE mSyslog_close(VALUE self)
{
- rb_secure(4);
if (!syslog_opened) {
rb_raise(rb_eRuntimeError, "syslog not opened");
}
@@ -134,7 +132,6 @@ static VALUE mSyslog_get_mask(VALUE self)
static VALUE mSyslog_set_mask(VALUE self, VALUE mask)
{
- rb_secure(4);
if (!syslog_opened) {
rb_raise(rb_eRuntimeError, "must open syslog before setting log mask");
}
diff --git a/ext/syslog/syslog.txt b/ext/syslog/syslog.txt
index 35bd4cb057..b134ed2a40 100644
--- a/ext/syslog/syslog.txt
+++ b/ext/syslog/syslog.txt
@@ -1,16 +1,13 @@
.\" syslog.txt - -*- Indented-Text -*-
$RoughId: syslog.txt,v 1.18 2002/02/25 08:20:14 knu Exp $
-$Id$
+$Id: syslog.txt,v 1.2 2002/02/25 12:13:30 knu Exp $
UNIX Syslog extension for Ruby
Amos Gouaux, University of Texas at Dallas
<amos+ruby@utdallas.edu>
&
Akinori MUSHA
-<knu@iDaemons.org>
-
-Contact:
- - Akinori MUSHA <knu@iDaemons.org> (current maintainer)
+<knu@ruby-lang.org>
** Syslog(Module)
diff --git a/ext/syslog/test.rb b/ext/syslog/test.rb
index cfa33eff8f..907602c21d 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$
+# $Id: test.rb,v 1.4 2002/11/27 08:36:22 knu Exp $
# 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
deleted file mode 100644
index 2f984efc6d..0000000000
--- a/ext/thread/extconf.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-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
deleted file mode 100644
index 6c533aba39..0000000000
--- a/ext/thread/lib/thread.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-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
deleted file mode 100644
index 68f172220a..0000000000
--- a/ext/thread/thread.c
+++ /dev/null
@@ -1,1182 +0,0 @@
-/*
- * 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>
-
-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(VALUE (*func)(ANYARGS), VALUE arg)
-{
- VALUE critical = rb_thread_critical;
-
- rb_thread_critical = 1;
- return rb_ensure(func, arg, set_critical, (VALUE)critical);
-}
-
-/*
- * 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 thread_exclusive(rb_yield, Qundef);
-}
-
-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 Qnil;
-
- 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 = wake_thread(shift_list(list));
- }
-
- 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 VALUE
-wait_list(List *list)
-{
- return rb_ensure(wait_list_inner, (VALUE)list, wait_list_cleanup, (VALUE)list);
-}
-
-static void
-kill_waiting_threads(List *waiting)
-{
- Entry *entry;
-
- for (entry = waiting->entries; entry; entry = entry->next) {
- rb_thread_kill(entry->value);
- }
-}
-
-/*
- * 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)
-{
- kill_waiting_threads(&mutex->waiting);
- 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 {
- do {
- wait_list(&mutex->waiting);
- 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;
-}
-
-/*
- * 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 = thread_exclusive(unlock_mutex_inner, (VALUE)mutex);
-
- 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);
-
- waking = thread_exclusive(rb_mutex_exclusive_unlock_inner, (VALUE)mutex);
-
- if (!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)
-{
- kill_waiting_threads(&condvar->waiting);
- 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, lock_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);
-
- thread_exclusive(wake_all, (VALUE)&condvar->waiting);
- 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 = thread_exclusive(wake_one, (VALUE)&condvar->waiting);
-
- 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)
-{
- kill_waiting_threads(&queue->mutex.waiting);
- kill_waiting_threads(&queue->space_available.waiting);
- kill_waiting_threads(&queue->value_available.waiting);
- 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 8c5d01a954..fa5524da01 100644
--- a/ext/tk/ChangeLog.tkextlib
+++ b/ext/tk/ChangeLog.tkextlib
@@ -1,69 +1,3 @@
-2008-05-12 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/lib/tkextlib/tkDND/shape.rb: wrong package name.
-
---------------< ... some changes ... >------------------
-
-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/MANUAL_tcltklib.eng b/ext/tk/MANUAL_tcltklib.eng
index 6fa775b7de..1db61f228e 100644
--- a/ext/tk/MANUAL_tcltklib.eng
+++ b/ext/tk/MANUAL_tcltklib.eng
@@ -125,24 +125,7 @@ module TclTklib
: Tcl7.6 doesn't have this flag. So PARSE_VARNAME is
: defined as 0.
- module TclTkLib::RELEASE_TYPE
- : Defines release type number of Tcl/Tk
-
- ALPHA
- : ALPHA release
-
- BETA
- : BETA release
-
- FINAL
- : FINAL release
-
[module methods]
- get_version()
- : return an array of major, minor, release-type number,
- : number, release-type name, and patchlevel of current
- : Tcl/Tk library.
-
mainloop(check_root = true)
: Starts the eventloop. If 'check_root' is true, this method
: doesn't return when a root widget exists.
@@ -448,10 +431,6 @@ class TclTkIp
: slave interpreter, same to the TclTkLib module method with
: the same name.
- encoding_table
- : For Ruby m17n. Return encoding relation table between Ruby's
- : Encoding object and Tcl's encoding name.
-
class TkCallbackBreak < StandardError
class TkCallbackContinue < StandardError
: They are exception classes to break or continue the Tk callback
@@ -462,8 +441,5 @@ class TkCallbackContinue < StandardError
: If raise TkCallbackContinue, returns 'continue' code (Then the Tk
: interpreter will break the operateion for the current bindtag and
: starts the operation for the next buindtag for the current event).
- : However, current tcltklib supports Ruby's 'break' and 'next' to
- : get the same effect. That is, those classes are obsolete. Those
- : exist for backward compatibility.
(eof)
diff --git a/ext/tk/MANUAL_tcltklib.eucj b/ext/tk/MANUAL_tcltklib.eucj
index 7df42997b4..5dd36726ba 100644
--- a/ext/tk/MANUAL_tcltklib.eucj
+++ b/ext/tk/MANUAL_tcltklib.eucj
@@ -221,23 +221,7 @@ require "tcltklib" ¤¹¤ë¤È, °Ê²¼¤Î¥â¥¸¥å¡¼¥ë, ¥¯¥é¥¹¤¬ÍøÍѲÄǽ¤Ç¤¹.
: ¤«¤éÃê½Ð¤µ¤ì¤ë¤Ï¤º¤Ç¤¢¤ë¤«¤é¡¤index_name °ú¿ô¤Ï nil ¤È
: ¤»¤Í¤Ð¤Ê¤é¤Ê¤¤¡¥
- ¥â¥¸¥å¡¼¥ë TclTkLib::RELEASE_TYPE
- : Tcl/Tk ¤Î¥ê¥ê¡¼¥¹¥¿¥¤¥×ÈÖ¹æ¤ÎÄêµÁ
-
- Äê¿ô ALPHA
- : ALPHA ¥ê¥ê¡¼¥¹
-
- Äê¿ô BETA
- : BETA ¥ê¥ê¡¼¥¹
-
- Äê¿ô FINAL
- : FINAL ¥ê¥ê¡¼¥¹
-
¥â¥¸¥å¡¼¥ë¥á¥½¥Ã¥É
- get_version()
- : Tcl/Tk ¤Î major, minor, release-type ÈÖ¹æ, release-type ̾,
- : patchlevel ¤òÇÛÎó¤Ë¤·¤ÆÊÖ¤¹¡¥
-
mainloop(check_root = true)
: ¥¤¥Ù¥ó¥È¥ë¡¼¥×¤òµ¯Æ°¤¹¤ë¡¥check_root ¤¬ true ¤Ç¤¢¤ì¤Ð¡¤
: root widget ¤¬Â¸ºß¤¹¤ë¸Â¤ê¡¤¤³¤Î¥á¥½¥Ã¥É¤Ï½ªÎ»¤·¤Ê¤¤¡¥
@@ -559,9 +543,6 @@ require "tcltklib" ¤¹¤ë¤È, °Ê²¼¤Î¥â¥¸¥å¡¼¥ë, ¥¯¥é¥¹¤¬ÍøÍѲÄǽ¤Ç¤¹.
: ¥¹¥ì¡¼¥Ö IP ¤Î¾ì¹ç¤Ë¤ÏÃͤÎÀßÄ꤬µö¤µ¤ì¤Ê¤¤ (̵»ë¤µ¤ì¤ë)¡¥
: ¤½¤ì°Ê³°¤ÎÅÀ¤Ç¤Ï°ú¿ô¤ò´Þ¤á¤Æ TclTkLib ¤ÎƱ̾¥á¥½¥Ã¥É¤ËƱ¤¸¡¥
- encoding_table
- : Ruby m17n ÍÑ¤Ë Ruby ¤È Tk ¤È¤Î´Ö¤Î encoding Âбþɽ¤òÊÖ¤¹¡¥
-
¥¯¥é¥¹ TkCallbackBreak < StandardError
¥¯¥é¥¹ TkCallbackContinue < StandardError
: ¤³¤ì¤é¤Ï¥¤¥Ù¥ó¥È¥³¡¼¥ë¥Ð¥Ã¥¯¤Ë¤ª¤¤¤Æ¡¤¥³¡¼¥ë¥Ð¥Ã¥¯½èÍý¤òŬÀÚ¤ËÃæ
@@ -572,8 +553,5 @@ require "tcltklib" ¤¹¤ë¤È, °Ê²¼¤Î¥â¥¸¥å¡¼¥ë, ¥¯¥é¥¹¤¬ÍøÍѲÄǽ¤Ç¤¹.
: ¥É¤òÊÖ¤¹É¬Íפ¬¤¢¤ë¡¥Ruby ¤Î¼ê³¤­¤¬ÉáÄ̤ËÃͤòÊÖ¤¹¤Î¤Ç¤Ï¡¤¤½¤ì¤¬Éá
: Ä̤ÎÌá¤êÃͤǤ¢¤ë¤Î¤«Èݤ«¤ò¶èÊ̤¬¤Ç¤­¤Ê¤¤¤¿¤á¡¤Î㳰ȯÀ¸¤òÍøÍѤ·¤¿
: ¼ÂÁõ¤ò¹Ô¤Ã¤Æ¤¤¤ë¡¥
- : ¤¿¤À¤·¸½ºß¤Ç¤Ï¡¤¥³¡¼¥ë¥Ð¥Ã¥¯¼ê³¤­¤ò Ruby ¤Î break, next ¤Ç½ªÎ»¤¹
- : ¤ë¤³¤È¤ÇƱÅù¤Î·ë²Ì¤òÆÀ¤ë¤³¤È¤¬¤Ç¤­¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤ë¡¥¤½¤ì¤æ¤¨¡¤
- : ¤³¤ì¤é¤ÏɬÍפʤ¤¤â¤Î¤Ç¤Ï¤¢¤ë¤¬¡¤¸ß´¹À­¤Î¤¿¤á¤Ë»Ä¤·¤Æ¤¢¤ë¡¥
(eof)
diff --git a/ext/tk/README.1st b/ext/tk/README.1st
index fce5b0242b..df6c819d26 100644
--- a/ext/tk/README.1st
+++ b/ext/tk/README.1st
@@ -1,6 +1,7 @@
If you want to use Ruby/Tk (tk.rb and so on), you must have tcltklib.so
-which is working correctly. When you have some troubles on compiling,
-please read README.tcltklib and README.ActiveTcl.
+which is working correctly. If you fail to call 'require "tcltklib"',
+you may not have tcltklib.so. When you have some troubles on compiling
+tcltklib, please read README files on tcltklib.
Even if there is a tcltklib.so on your Ruby library directry, it will not
work without Tcl/Tk libraries (e.g. libtcl8.4.so) on your environment.
You must also check that your Tcl/Tk is installed properly.
@@ -8,9 +9,11 @@ You must also check that your Tcl/Tk is installed properly.
--------------------------------------------
( the following is written in EUC-JP )
-Ruby/Tk (tk.rb ¤Ê¤É) ¤ò»È¤¤¤¿¤¤¾ì¹ç¤Ë¤Ï¡¤tcltklib.so ¤¬Àµ¤·¤¯Æ°¤¤¤Æ¤¤¤Ê
-¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡¥¥³¥ó¥Ñ¥¤¥ë»þ¤Ë²¿¤«ÌäÂ꤬À¸¤¸¤¿¾ì¹ç¤Ï¡¤README.tcltklib
-¤ä README.ActiveTcl ¤ò¸«¤Æ¤¯¤À¤µ¤¤¡¥
+Ruby/Tk (tk.rb ¤Ê¤É) ¤ò»È¤¤¤¿¤¤¾ì¹ç¤Ë¤Ï¡¤tcltklib.so ¤¬Àµ¤·¤¯Æ°¤¤¤Æ
+¤¤¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡¥¤â¤· 'require "tcltklib"' ¤Ë¼ºÇÔ¤¹¤ë¤è¤¦¤Ê¤é¡¤
+tcltklib.so ¤¬¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¤Æ¤¤¤Ê¤¤¤Î¤«¤â¤·¤ì¤Þ¤»¤ó¡¥tcltklib ¤Î
+¥³¥ó¥Ñ¥¤¥ë»þ¤Ë²¿¤«ÌäÂ꤬À¸¤¸¤Æ¤¤¤ë¾ì¹ç¤Ï¡¤tcltklib ¤Î README ¥Õ¥¡¥¤¥ë
+¤ò¸«¤Æ¤¯¤À¤µ¤¤¡¥
¤¿¤È¤¨ Ruby ¤Î¥é¥¤¥Ö¥é¥ê¥Ç¥£¥ì¥¯¥È¥ê¤Ë tcltklib.so ¤¬Â¸ºß¤·¤Æ¤¤¤¿¤È¤·¤Æ
¤â¡¤¼Â¹Ô´Ä¶­¤Ë Tcl/Tk ¥é¥¤¥Ö¥é¥ê (libtcl8.4.so ¤Ê¤É) ¤¬¤Ê¤±¤ì¤Ðµ¡Ç½¤·¤Þ
¤»¤ó¡¥Tcl/Tk ¤¬Àµ¤·¤¯¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¤Æ¤¤¤ë¤«¤â¥Á¥§¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤¡¥
diff --git a/ext/tk/README.tcltklib b/ext/tk/README.tcltklib
index 8c6dd5178f..5d1da48a45 100644
--- a/ext/tk/README.tcltklib
+++ b/ext/tk/README.tcltklib
@@ -5,14 +5,10 @@ Tcl/Tk libraries or header files are installed but are not found, you can
give the information by arguments of the 'configure' script. Please give
some or all of the following options.
- --with-tcltkversion=<version>
- force version of Tcl/Tk libaray
- (e.g. libtcl8.4g.so ==> --with-tcltkversion=8.4g)
-
--with-tcllib=<libname> (e.g. libtcl8.4.so ==> --with-tcllib=tcl8.4)
--with-tklib=<libname> (e.g. libtk8.4.so ==> --with-tklib=tk8.4)
- --enable-tcltk-stubs (if you force to enable stubs)
+ --enable-tcltk_stubs (if you force to enable stubs)
--with-tcl-dir=<path>
equal to "--with-tcl-include=<path>/include --with-tcl-lib=<path>/lib"
@@ -20,18 +16,18 @@ some or all of the following options.
--with-tk-dir=<path>
equal to "--with-tk-include=<path>/include --with-tk-lib=<path>/lib"
- --with-tcl-include=<dir> the directry contains 'tcl.h'
- --with-tk-include=<dir> the directry contains 'tk.h'
+ --with-tcl-include=<dir> the directry containts 'tcl.h'
+ --with-tk-include=<dir> the directry containts 'tk.h'
- --with-tcl-lib=<dir> the directry contains 'libtcl<version>.so'
- --with-tk-lib=<dir> the directry contains 'libtk<version>.so'
+ --with-tcl-lib=<dir> the directry containts 'libtcl<version>.so'
+ --with-tk-lib=<dir> the directry containts 'libtk<version>.so'
--enable-mac-tcltk-framework (MacOS X) use Tcl/Tk framework
(Obsolete. Please use '--enable-tcltk-framework'.)
--enable-tcltk-framework use Tcl/Tk framework
- --with-tcltk-framework=<dir> the directory contains Tcl/Tk framework;
+ --with-tcltk-framework=<dir> the directory containts Tcl/Tk framework;
"<dir>/Tcl.framework" and "<dir>/Tk.framework".
When this option is given, it is assumed that
--enable-tcltk-framework option is given also.
@@ -45,15 +41,6 @@ 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 contais X11 header files
- --with-X11-lib=<dir> the directry contais 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 4807ea7b40..8c8d833481 100644
--- a/ext/tk/extconf.rb
+++ b/ext/tk/extconf.rb
@@ -2,8 +2,7 @@
require 'mkmf'
-#is_win32 = (/mswin32|mingw|cygwin|bccwin32/ =~ RUBY_PLATFORM)
-is_win32 = (/mswin|mingw|cygwin|bccwin|wince/ =~ RUBY_PLATFORM)
+is_win32 = (/mswin32|mingw|cygwin|bccwin32/ =~ RUBY_PLATFORM)
#is_macosx = (/darwin/ =~ RUBY_PLATFORM)
def find_framework(tcl_hdr, tk_hdr)
@@ -40,68 +39,16 @@ unless is_win32
have_library("m", "log")
end
-tk_idir, tk_ldir = dir_config("tk")
-tcl_idir, tcl_ldir = dir_config("tcl")
-x11_idir, x11_ldir = dir_config("X11")
-
-tk_ldir2 = with_config("tk-lib")
-tcl_ldir2 = with_config("tcl-lib")
-x11_ldir2 = with_config("X11-lib")
-
-tk_ldir_list = [tk_ldir2, tk_ldir]
-tcl_ldir_list = [tcl_ldir2, tcl_ldir]
+dir_config("tk")
+dir_config("tcl")
+dir_config("X11")
tklib = with_config("tklib")
tcllib = with_config("tcllib")
stubs = enable_config("tcltk_stubs") || with_config("tcltk_stubs")
-tcltk_version = with_config("tcltkversion")
-
-use_X = with_config("X11", (! is_win32))
-
-def check_tcltk_version(version)
- return [nil, nil] unless version
-
- version = version.strip
-
- tclver = version.dup
- tkver = version.dup
-
- major = dot = minor = dot = plvl = ext = nil
-
- if version =~ /^(\d)(\.?)(\d)(\.?)(\d*)(.*)$/
- major = $1; minor_dot = $2; minor = $3; plvl_dot = $4; plvl = $5; ext = $6
- dot = ! minor_dot.empty?
- if plvl_dot.empty? && ! plvl.empty?
- minor << plvl
- end
- elsif version =~ /^(\d)(\.?)(\d?)(.*)$/
- major = $1; minor_dot = $2; minor = $3; ext = $4
- dot = ! minor_dot.empty?
- else # unknown -> believe user
- return [tclver, tkver]
- end
-
- # check Tcl7.6 / Tk4.2 ?
- if major == "7" # Tcl7.6 ( not support Tclversion < 7.6 )
- # Tk4.2
- tkver = "4" + ((dot)? ".": "") + ((minor.empty)? "": "2") + ext
- elsif major == "4" # Tk4.2 ( not support Tkversion < 4.2 )
- # Tcl7.6
- tclver = "7" + ((dot)? ".": "") + ((minor.empty)? "": "6") + ext
- end
-
- [tclver, tkver]
-end
-
-def find_tcl(tcllib, stubs, version, *opt_paths)
- default_paths = ["/usr/local/lib", "/usr/pkg/lib", "/usr/lib"]
- default_paths << "/Tcl/lib" # default for ActiveTcl
-
- if (paths = opt_paths.compact).empty?
- paths = default_paths
- end
-
+def find_tcl(tcllib, stubs)
+ paths = ["/usr/local/lib", "/usr/pkg/lib", "/usr/lib"]
if stubs
func = "Tcl_InitStubs"
lib = "tclstub"
@@ -109,42 +56,22 @@ def find_tcl(tcllib, stubs, version, *opt_paths)
func = "Tcl_FindExecutable"
lib = "tcl"
end
-
- if version && ! version.empty?
- versions = [version]
- else
- versions = %w[8.6 8.5 8.4 8.3 8.2 8.1 8.0 7.6]
- end
-
if tcllib
- st = find_library(tcllib, func, *paths)
+ find_library(tcllib, func, *paths)
+ elsif find_library(lib, func, *paths)
+ true
else
- st = versions.find { |ver|
- find_library("#{lib}#{ver}", func, *paths) or
- find_library("#{lib}#{ver.delete('.')}", func, *paths) or
- find_library("#{lib}#{ver}g", func, *paths) or
- find_library("#{lib}#{ver.delete('.')}g", func, *paths) or
- find_library("tcl#{ver}", func, *paths) or
- find_library("tcl#{ver.delete('.')}", func, *paths) or
- find_library("tcl#{ver}g", func, *paths) or
- find_library("tcl#{ver.delete('.')}g", func, *paths)
- } || (!version && find_library(lib, func, *paths))
- end
-
- unless st
- puts("Warning:: cannot find Tcl library. tcltklib will not be compiled (tcltklib is disabled on your Ruby == Ruby/Tk will not work). Please check configure options.")
+ %w[8.5 8.4 8.3 8.2 8.1 8.0 7.6].find { |ver|
+ find_library("#{lib}#{ver}", func, *paths) or
+ find_library("#{lib}#{ver.delete('.')}", func, *paths) or
+ find_library("tcl#{ver}", func, *paths) or
+ find_library("tcl#{ver.delete('.')}", func, *paths)
+ }
end
- st
end
-def find_tk(tklib, stubs, version, *opt_paths)
- default_paths = ["/usr/local/lib", "/usr/pkg/lib", "/usr/lib"]
- default_paths << "/Tcl/lib" # default for ActiveTcl
-
- if (paths = opt_paths.compact).empty?
- paths = default_paths
- end
-
+def find_tk(tklib, stubs)
+ paths = ["/usr/local/lib", "/usr/pkg/lib", "/usr/lib"]
if stubs
func = "Tk_InitStubs"
lib = "tkstub"
@@ -152,45 +79,20 @@ def find_tk(tklib, stubs, version, *opt_paths)
func = "Tk_Init"
lib = "tk"
end
-
- if version && ! version.empty?
- versions = [version]
- else
- versions = %w[8.6 8.5 8.4 8.3 8.2 8.1 8.0 4.2]
- end
-
if tklib
- st = find_library(tklib, func, *paths)
+ find_library(tklib, func, *paths)
+ elsif find_library(lib, func, *paths)
+ true
else
- st = versions.find { |ver|
- find_library("#{lib}#{ver}", func, *paths) or
- find_library("#{lib}#{ver.delete('.')}", func, *paths) or
- find_library("#{lib}#{ver}g", func, *paths) or
- find_library("#{lib}#{ver.delete('.')}g", func, *paths) or
- find_library("tk#{ver}", func, *paths) or
- find_library("tk#{ver.delete('.')}", func, *paths) or
- find_library("tk#{ver}g", func, *paths) or
- find_library("tk#{ver.delete('.')}g", func, *paths)
- } || (!version && find_library(lib, func, *paths))
- end
-
- unless st
- puts("Warning:: cannot find Tk library. tcltklib will not be compiled (tcltklib is disabled on your Ruby == Ruby/Tk will not work). Please check configure options.")
+ %w[8.5 8.4 8.3 8.2 8.1 8.0 4.2].find { |ver|
+ find_library("#{lib}#{ver}", func, *paths) or
+ find_library("#{lib}#{ver.delete('.')}", func, *paths) or
+ find_library("tk#{ver}", func, *paths) or
+ find_library("tk#{ver.delete('.')}", func, *paths)
+ }
end
- st
end
-def find_X11(*opt_paths)
- default_paths =
- [ "/usr/X11/lib", "/usr/lib/X11", "/usr/X11R6/lib", "/usr/openwin/lib" ]
- paths = opt_paths.compact.concat(default_paths)
- st = find_library("X11", "XOpenDisplay", *paths)
- unless st
- puts("Warning:: cannot find X11 library. tcltklib will not be compiled (tcltklib is disabled on your Ruby == Ruby/Tk will not work). Please check configure options. If your Tcl/Tk don't require X11, please try --without-X11.")
- end
- st
-end
-
def pthread_check()
tcl_major_ver = nil
tcl_minor_ver = nil
@@ -369,13 +271,12 @@ EOF
end
end
-tclver, tkver = check_tcltk_version(tcltk_version)
-
-if have_header("tcl.h") && have_header("tk.h") &&
- ( tcltk_framework ||
- ( ( !use_X || find_X11(x11_ldir2, x11_ldir) ) &&
- find_tcl(tcllib, stubs, tclver, *tcl_ldir_list) &&
- find_tk(tklib, stubs, tkver, *tk_ldir_list) ) )
+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")) &&
+ find_tcl(tcllib, stubs) &&
+ find_tk(tklib, stubs))
$CPPFLAGS += ' -DUSE_TCL_STUBS -DUSE_TK_STUBS' if stubs
$CPPFLAGS += ' -D_WIN32' if /cygwin/ =~ RUBY_PLATFORM
@@ -402,11 +303,7 @@ if have_header("tcl.h") && have_header("tk.h") &&
$INSTALLFILES ||= []
$INSTALLFILES << ["lib/tkextlib/SUPPORT_STATUS", "$(RUBYLIBDIR)", "lib"]
- have_func("rb_hash_lookup", "ruby.h")
-
# create
- $defs << %[-DRUBY_VERSION=\\"#{RUBY_VERSION}\\"]
- $defs << %[-DRUBY_RELEASE_DATE=\\"#{RUBY_RELEASE_DATE}\\"]
create_makefile("tcltklib")
end
end
diff --git a/ext/tk/lib/multi-tk.rb b/ext/tk/lib/multi-tk.rb
index ec718678f0..78ed1aa6ee 100644
--- a/ext/tk/lib/multi-tk.rb
+++ b/ext/tk/lib/multi-tk.rb
@@ -114,14 +114,7 @@ MultiTkIp_OK.freeze
class MultiTkIp
BASE_DIR = File.dirname(__FILE__)
- WITH_RUBY_VM = Object.const_defined?(:VM) && ::VM.class == Class
- WITH_ENCODING = Object.const_defined?(:Encoding) && ::Encoding.class == Class
-
- (@@SLAVE_IP_ID = ['slave'.freeze, '0'.taint]).instance_eval{
- @mutex = Mutex.new
- def mutex; @mutex; end
- freeze
- }
+ @@SLAVE_IP_ID = ['slave'.freeze, '0'.taint].freeze
@@IP_TABLE = {}.taint unless defined?(@@IP_TABLE)
@@ -133,18 +126,14 @@ class MultiTkIp
unless defined?(@@TK_CMD_TBL)
@@TK_CMD_TBL = Object.new.taint
- # @@TK_CMD_TBL.instance_variable_set('@tbl', {}.taint)
- @@TK_CMD_TBL.instance_variable_set('@tbl', Hash.new{|hash,key|
- fail IndexError,
- "unknown command ID '#{key}'"
- }.taint)
+ @@TK_CMD_TBL.instance_variable_set('@tbl', {}.taint)
class << @@TK_CMD_TBL
allow = [
- '__send__', '__id__', 'freeze', 'inspect', 'kind_of?', 'object_id',
+ '__send__', '__id__', 'freeze', 'inspect', 'kind_of?',
'[]', '[]=', 'delete', 'each', 'has_key?'
]
- instance_methods.each{|m| undef_method(m) unless allow.index(m.to_s)}
+ instance_methods.each{|m| undef_method(m) unless allow.index(m)}
def kind_of?(klass)
@tbl.kind_of?(klass)
@@ -217,7 +206,7 @@ class MultiTkIp
def initialize(ip, cmd)
@ip = ip
@cmd = cmd
- self.freeze
+ freeze
end
attr_reader :ip, :cmd
def inspect
@@ -584,11 +573,7 @@ class MultiTkIp
# raise exception
begin
bt = _toUTF8(e.backtrace.join("\n"))
- if MultiTkIp::WITH_ENCODING
- bt.force_encoding('utf-8')
- else
- bt.instance_variable_set(:@encoding, 'utf-8')
- end
+ bt.instance_variable_set(:@encoding, 'utf-8')
rescue Exception
bt = e.backtrace.join("\n")
end
@@ -710,11 +695,6 @@ class MultiTkIp
######################################
- unless self.const_defined? :RUN_EVENTLOOP_ON_MAIN_THREAD
- ### Ruby 1.9 !!!!!!!!!!!!!!!!!!!!!!!!!!
- RUN_EVENTLOOP_ON_MAIN_THREAD = false
- end
-
if self.const_defined? :DEFAULT_MASTER_NAME
name = DEFAULT_MASTER_NAME.to_s
else
@@ -743,41 +723,7 @@ class MultiTkIp
fail ArgumentError, "expecting a Hash object for the 2nd argument"
end
- if !WITH_RUBY_VM || RUN_EVENTLOOP_ON_MAIN_THREAD ### check Ruby 1.9 !!!!!!!
- @interp = TclTkIp.new(name, _keys2opts(keys))
- else ### Ruby 1.9 !!!!!!!!!!!
- @interp_thread = Thread.new{
- current = Thread.current
- current[:interp] = interp = TclTkIp.new(name, _keys2opts(keys))
- #sleep
- current[:mutex] = mutex = Mutex.new
- current[:root_check] = cond_var = ConditionVariable.new
-
- begin
- current[:status] = interp.mainloop(true)
- rescue Exception=>e
- current[:status] = e
- ensure
- mutex.synchronize{ cond_var.broadcast }
- end
- current[:status] = interp.mainloop(false)
- }
- until @interp_thread[:interp]
- Thread.pass
- end
- # INTERP_THREAD.run
- @interp = @interp_thread[:interp]
-
- def self.mainloop(check_root = true)
- begin
- TclTkLib.set_eventloop_window_mode(true)
- @interp_thread.value
- ensure
- TclTkLib.set_eventloop_window_mode(false)
- end
- end
- end
-
+ @interp = TclTkIp.new(name, _keys2opts(keys))
@ip_name = nil
@callback_status = [].taint
@@ -907,26 +853,22 @@ class MultiTkIp
Thread.new{
current = Thread.current
loop {
- mtx, cond, ret, table, script = @init_ip_env_queue.deq
- begin
+ mtx, ret, table, script = @init_ip_env_queue.deq
+ begin
ret[0] = table.each{|tg, ip| ip._init_ip_env(script) }
rescue Exception => e
ret[0] = e
ensure
- mtx.synchronize{ cond.signal }
+ mtx.unlock
end
- mtx = cond = ret = table = script = nil # clear variables for GC
}
}
def self.__init_ip_env__(table, script)
ret = []
- mtx = (Thread.current[:MultiTk_ip_Mutex] ||= Mutex.new)
- cond = (Thread.current[:MultiTk_ip_CondVar] ||= ConditionVariable.new)
- mtx.synchronize{
- @init_ip_env_queue.enq([mtx, cond, ret, table, script])
- cond.wait(mtx)
- }
+ mtx = Mutex.new.lock
+ @init_ip_env_queue.enq([mtx, ret, table, script])
+ mtx.lock
if ret[0].kind_of?(Exception)
raise ret[0]
else
@@ -1005,11 +947,9 @@ class MultiTkIp
private :_parse_slaveopts
def _create_slave_ip_name
- @@SLAVE_IP_ID.mutex.synchronize{
- name = @@SLAVE_IP_ID.join('')
- @@SLAVE_IP_ID[1].succ!
- name.freeze
- }
+ name = @@SLAVE_IP_ID.join('')
+ @@SLAVE_IP_ID[1].succ!
+ name.freeze
end
private :_create_slave_ip_name
@@ -1266,20 +1206,7 @@ class MultiTkIp
if safeip == nil
# create master-ip
- unless WITH_RUBY_VM
- @interp = TclTkIp.new(name, _keys2opts(tk_opts))
- else ### Ruby 1.9 !!!!!!!!!!!
- @interp_thread = Thread.new{
- Thread.current[:interp] = interp = TclTkIp.new(name, _keys2opts(tk_opts))
- #sleep
- TclTkLib.mainloop(true)
- }
- until @interp_thread[:interp]
- Thread.pass
- end
- # INTERP_THREAD.run
- @interp = @interp_thread[:interp]
- end
+ @interp = TclTkIp.new(name, _keys2opts(tk_opts))
@ip_name = nil
if safe
@@ -1294,8 +1221,6 @@ class MultiTkIp
@safe_base = true
@interp, @ip_name = master.__create_safe_slave_obj(safe_opts,
name, tk_opts)
- # @interp_thread = nil if RUBY_VERSION < '1.9.0' ### !!!!!!!!!!!
- @interp_thread = nil unless WITH_RUBY_VM ### Ruby 1.9 !!!!!!!!!!!
if safe
safe = master.safe_level if safe < master.safe_level
@safe_level = [safe]
@@ -1304,8 +1229,6 @@ class MultiTkIp
end
else
@interp, @ip_name = master.__create_trusted_slave_obj(name, tk_opts)
- # @interp_thread = nil if RUBY_VERSION < '1.9.0' ### !!!!!!!!!!!
- @interp_thread = nil unless WITH_RUBY_VM ### Ruby 1.9 !!!!!!!!!!!
if safe
safe = master.safe_level if safe < master.safe_level
@safe_level = [safe]
@@ -1340,11 +1263,11 @@ class MultiTkIp
@@DEFAULT_MASTER.assign_receiver_and_watchdog(self)
@@IP_TABLE[@threadgroup] = self
+ _init_ip_internal(@@INIT_IP_ENV, @@ADD_TK_PROCS)
@@TK_TABLE_LIST.size.times{
(tbl = {}).tainted? || tbl.taint
@tk_table_list << tbl
}
- _init_ip_internal(@@INIT_IP_ENV, @@ADD_TK_PROCS)
class << self
undef :instance_eval
@@ -1422,13 +1345,8 @@ class << MultiTkIp
alias __new new
private :__new
- def new_master(safe=nil, keys={})
- if MultiTkIp::WITH_RUBY_VM
- #### TODO !!!!!!
- fail RuntimeError,
- 'sorry, still not support multiple master-interpreters on Ruby VM'
- end
+ def new_master(safe=nil, keys={})
if safe.kind_of?(Hash)
keys = safe
elsif safe.kind_of?(Integer)
@@ -1645,13 +1563,8 @@ class MultiTkIp
return if slave?
names.each{|name|
name = name.to_s
-
- return if @interp.deleted?
@interp._invoke('rename', name, '')
-
- return if @interp.deleted?
@interp._invoke('interp', 'slaves').split.each{|slave|
- return if @interp.deleted?
@interp._invoke('interp', 'alias', slave, name, '') rescue nil
}
}
@@ -1701,16 +1614,11 @@ class MultiTkIp
id = @@TK_TABLE_LIST.size
obj = Object.new
@@TK_TABLE_LIST << obj
- obj.instance_variable_set(:@id, id)
- obj.instance_variable_set(:@mutex, Mutex.new)
- obj.instance_eval{
- def self.mutex
- @mutex
- end
+ obj.instance_eval <<-EOD
def self.method_missing(m, *args)
- MultiTkIp.tk_object_table(@id).__send__(m, *args)
+ MultiTkIp.tk_object_table(#{id}).__send__(m, *args)
end
- }
+ EOD
obj.freeze
@@IP_TABLE.each{|tg, ip| ip._add_new_tables }
return obj
@@ -2430,11 +2338,6 @@ end
class MultiTkIp
def mainloop(check_root = true, restart_on_dead = true)
raise SecurityError, "no permission to manipulate" unless self.manipulable?
-
- if WITH_RUBY_VM ### Ruby 1.9 !!!!!!!!!!!
- return @interp_thread.value if @interp_thread
- end
-
#return self if self.slave?
#return self if self != @@DEFAULT_MASTER
if self != @@DEFAULT_MASTER
@@ -2843,10 +2746,9 @@ class MultiTkIp
i = -1
brace = 1
str.each_byte {|c|
- c = c.chr
i += 1
- brace += 1 if c == '{'
- brace -= 1 if c == '}'
+ brace += 1 if c == ?{
+ brace -= 1 if c == ?}
break if brace == 0
}
if i == 0
@@ -3285,44 +3187,15 @@ end
# encoding convert
-class << MultiTkIp
- def encoding_table
- __getip.encoding_table
- end
-end
class MultiTkIp
- def encoding_table
- @interp.encoding_table
- end
-
- def force_default_encoding=(mode)
+ def encoding
raise SecurityError, "no permission to manipulate" unless self.manipulable?
- @interp.force_default_encoding = mode
+ @interp.encoding
end
- def force_default_encoding?
- raise SecurityError, "no permission to manipulate" unless self.manipulable?
- @interp.force_default_encoding?
- end
-
- def default_encoding=(enc)
- raise SecurityError, "no permission to manipulate" unless self.manipulable?
- @interp.default_encoding = enc
- end
-
def encoding=(enc)
raise SecurityError, "no permission to manipulate" unless self.manipulable?
@interp.encoding = enc
end
- def encoding_name
- raise SecurityError, "no permission to manipulate" unless self.manipulable?
- @interp.encoding_name
- end
- def encoding_obj
- raise SecurityError, "no permission to manipulate" unless self.manipulable?
- @interp.encoding_obj
- end
- alias encoding encoding_name
- alias default_encoding encoding_name
def encoding_convertfrom(str, enc=None)
raise SecurityError, "no permission to manipulate" unless self.manipulable?
@@ -3339,30 +3212,13 @@ end
# remove methods for security
-if MultiTkIp::WITH_RUBY_VM &&
- ! MultiTkIp::RUN_EVENTLOOP_ON_MAIN_THREAD ### check Ruby 1.9 !!!!!!!
- class MultiTkIp
- INTERP_THREAD = @@DEFAULT_MASTER.instance_variable_get('@interp_thread')
- INTERP_MUTEX = INTERP_THREAD[:mutex]
- INTERP_ROOT_CHECK = INTERP_THREAD[:root_check]
- end
- module TkCore
- INTERP_THREAD = MultiTkIp::INTERP_THREAD
- INTERP_MUTEX = MultiTkIp::INTERP_MUTEX
- INTERP_ROOT_CHECK = MultiTkIp::INTERP_ROOT_CHECK
- end
- class MultiTkIp
- remove_const(:INTERP_THREAD)
- remove_const(:INTERP_MUTEX)
- remove_const(:INTERP_ROOT_CHECK)
- end
-end
-
class MultiTkIp
# undef_method :instance_eval
undef_method :instance_variable_get
undef_method :instance_variable_set
end
+
+
# end of MultiTkIp definition
# defend against modification
diff --git a/ext/tk/lib/tcltk.rb b/ext/tk/lib/tcltk.rb
index 7f6f41605d..1a6694dbff 100644
--- a/ext/tk/lib/tcltk.rb
+++ b/ext/tk/lib/tcltk.rb
@@ -265,7 +265,7 @@ class TclTkWidget < TclTkCommand
# (used in TclTkInterpreter#initialize())
# need two arguments
- fail("invalid # of parameter") if args.size != 2
+ fail("illegal # of parameter") if args.size != 2
# ip: interpreter(TclTkIp)
# exp: tcl/tk representation
diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb
index c5d5b804d2..eba2f72f29 100644
--- a/ext/tk/lib/tk.rb
+++ b/ext/tk/lib/tk.rb
@@ -1,5 +1,6 @@
#
# tk.rb - Tk interface module using tcltklib
+# $Date: 2006/07/14 04:10:49 $
# by Yukihiro Matsumoto <matz@netlab.jp>
# use Shigehiro's tcltklib
@@ -9,9 +10,6 @@ require 'tkutil'
# autoload
require 'tk/autoload'
-# for Mutex
-require 'thread'
-
class TclTkIp
# backup original (without encoding) _eval and _invoke
alias _eval_without_enc _eval
@@ -39,12 +37,7 @@ module TkComm
#Tk_CMDTBL = {}
#Tk_WINDOWS = {}
- Tk_IDs = ["00000".taint, "00000".taint] # [0]-cmdid, [1]-winid
- Tk_IDs.instance_eval{
- @mutex = Mutex.new
- def mutex; @mutex; end
- freeze
- }
+ Tk_IDs = ["00000".taint, "00000".taint].freeze # [0]-cmdid, [1]-winid
# for backward compatibility
Tk_CMDTBL = Object.new
@@ -225,9 +218,7 @@ module TkComm
TkCore::INTERP.tk_windows[val]?
TkCore::INTERP.tk_windows[val] : _genobj_for_tkwidget(val)
when /\Ai(_\d+_)?\d+\z/
- TkImage::Tk_IMGTBL.mutex.synchronize{
- TkImage::Tk_IMGTBL[val]? TkImage::Tk_IMGTBL[val] : val
- }
+ TkImage::Tk_IMGTBL[val]? TkImage::Tk_IMGTBL[val] : val
when /\A-?\d+\.?\d*(e[-+]?\d+)?\z/
val.to_f
when /\\ /
@@ -344,8 +335,6 @@ if USE_TCLs_LIST_FUNCTIONS
if dst_enc != true && dst_enc != false
if (s_enc = s.instance_variable_get(:@encoding))
s_enc = s_enc.to_s
- elsif TkCore::WITH_ENCODING
- s_enc = s.encoding.name
else
s_enc = sys_enc
end
@@ -358,20 +347,11 @@ if USE_TCLs_LIST_FUNCTIONS
if sys_enc && dst_enc
dst.map!{|s| _toUTF8(s)}
ret = TkCore::INTERP._merge_tklist(*dst)
- if TkCore::WITH_ENCODING
- if dst_enc.kind_of?(String)
- ret = _fromUTF8(ret, dst_enc)
- ret.force_encoding(dst_enc)
- else
- ret.force_encoding('utf-8')
- end
- else # without encoding
- if dst_enc.kind_of?(String)
- ret = _fromUTF8(ret, dst_enc)
- ret.instance_variable_set(:@encoding, dst_enc)
- else
- ret.instance_variable_set(:@encoding, 'utf-8')
- end
+ if dst_enc.kind_of?(String)
+ ret = _fromUTF8(ret, dst_enc)
+ ret.instance_variable_set(:@encoding, dst_enc)
+ else
+ ret.instance_variable_set(:@encoding, 'utf-8')
end
ret
else
@@ -431,6 +411,46 @@ else
tk_split_sublist(token, depth - 1)
}
end
+=begin
+ def tk_split_list(str)
+ return [] if str == ""
+ idx = str.index('{')
+ while idx and idx > 0 and str[idx-1] == ?\\
+ idx = str.index('{', idx+1)
+ end
+ unless idx
+ list = tk_tcl2ruby(str)
+ unless Array === list
+ list = [list]
+ end
+ return list
+ end
+
+ list = tk_tcl2ruby(str[0,idx])
+ list = [] if list == ""
+ str = str[idx+1..-1]
+ i = -1
+ escape = false
+ brace = 1
+ str.each_byte {|c|
+ i += 1
+ brace += 1 if c == ?{ && !escape
+ brace -= 1 if c == ?} && !escape
+ escape = (c == ?\\)
+ break if brace == 0
+ }
+ if str.size == i + 1
+ return tk_split_list(str[0, i])
+ end
+ if str[0, i] == ' '
+ list.push ' '
+ else
+ list.push tk_split_list(str[0, i])
+ end
+ list += tk_split_list(str[i+1..-1])
+ list
+ end
+=end
def tk_split_simplelist(str, src_enc=true, dst_enc=true)
return [] if str == ""
@@ -581,9 +601,7 @@ end
end
def image_obj(val)
if val =~ /^i(_\d+_)?\d+$/
- TkImage::Tk_IMGTBL.mutex.synchronize{
- TkImage::Tk_IMGTBL[val]? TkImage::Tk_IMGTBL[val] : val
- }
+ TkImage::Tk_IMGTBL[val]? TkImage::Tk_IMGTBL[val] : val
else
val
end
@@ -765,17 +783,15 @@ end
id = "c" + TkCore::INTERP._ip_id_ + TkComm::Tk_IDs[0]
end
def _next_cmd_id
- TkComm::Tk_IDs.mutex.synchronize{
- id = _curr_cmd_id
- #Tk_IDs[0] += 1
- TkComm::Tk_IDs[0].succ!
- id
- }
+ id = _curr_cmd_id
+ #Tk_IDs[0] += 1
+ TkComm::Tk_IDs[0].succ!
+ id
end
private :_curr_cmd_id, :_next_cmd_id
module_function :_curr_cmd_id, :_next_cmd_id
- def TkComm.install_cmd(cmd, local_cmdtbl=nil)
+ def install_cmd(cmd)
return '' if cmd == ''
begin
ns = TkCore::INTERP._invoke_without_enc('namespace', 'current')
@@ -794,15 +810,6 @@ end
@cmdtbl = [] unless defined? @cmdtbl
@cmdtbl.taint unless @cmdtbl.tainted?
@cmdtbl.push id
-
- if local_cmdtbl && local_cmdtbl.kind_of?(Array)
- begin
- local_cmdtbl << id
- rescue Exception
- # ignore
- end
- end
-
#return Kernel.format("rb_out %s", id);
if ns
'rb_out' << TkCore::INTERP._ip_id_ << ' ' << ns << ' ' << id
@@ -810,30 +817,14 @@ end
'rb_out' << TkCore::INTERP._ip_id_ << ' ' << id
end
end
- def TkComm.uninstall_cmd(id, local_cmdtbl=nil)
+ def uninstall_cmd(id)
#id = $1 if /rb_out\S* (c(_\d+_)?\d+)/ =~ id
id = $4 if id =~ /rb_out\S*(?:\s+(::\S*|[{](::.*)[}]|["](::.*)["]))? (c(_\d+_)?(\d+))/
-
- if local_cmdtbl && local_cmdtbl.kind_of?(Array)
- begin
- local_cmdtbl.delete(id)
- rescue Exception
- # ignore
- end
- end
- @cmdtbl.delete(id)
-
#Tk_CMDTBL.delete(id)
TkCore::INTERP.tk_cmd_tbl.delete(id)
end
# private :install_cmd, :uninstall_cmd
- # module_function :install_cmd, :uninstall_cmd
- def install_cmd(cmd)
- TkComm.install_cmd(cmd, @cmdtbl)
- end
- def uninstall_cmd(id)
- TkComm.uninstall_cmd(id, @cmdtbl)
- end
+ module_function :install_cmd, :uninstall_cmd
=begin
def install_win(ppath,name=nil)
@@ -865,10 +856,8 @@ end
return TkCore::INTERP.tk_windows[@path] = self
end
else
- Tk_IDs.mutex.synchronize{
- name = "w" + TkCore::INTERP._ip_id_ + Tk_IDs[1]
- Tk_IDs[1].succ!
- }
+ name = "w" + TkCore::INTERP._ip_id_ + Tk_IDs[1]
+ Tk_IDs[1].succ!
end
if !ppath or ppath == '.'
@path = '.' + name
@@ -947,12 +936,7 @@ module TkComm
def _bindinfo(what, context=nil)
if context
- if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
- enum_obj = tk_call_without_enc(*what+["<#{tk_event_sequence(context)}>"]).each_line
- else
- enum_obj = tk_call_without_enc(*what+["<#{tk_event_sequence(context)}>"])
- end
- enum_obj.collect {|cmdline|
+ tk_call_without_enc(*what+["<#{tk_event_sequence(context)}>"]) .collect {|cmdline|
=begin
if cmdline =~ /^rb_out\S* (c(?:_\d+_)?\d+)\s+(.*)$/
#[Tk_CMDTBL[$1], $2]
@@ -1098,14 +1082,6 @@ module TkCore
include TkComm
extend TkComm
- WITH_RUBY_VM = Object.const_defined?(:VM) && ::VM.class == Class
- WITH_ENCODING = Object.const_defined?(:Encoding) && ::Encoding.class == Class
-
- unless self.const_defined? :RUN_EVENTLOOP_ON_MAIN_THREAD
- ### Ruby 1.9 !!!!!!!!!!!!!!!!!!!!!!!!!!
- RUN_EVENTLOOP_ON_MAIN_THREAD = false
- end
-
unless self.const_defined? :INTERP
if self.const_defined? :IP_NAME
name = IP_NAME.to_s
@@ -1123,49 +1099,14 @@ module TkCore
opts = ''
end
- if !WITH_RUBY_VM || RUN_EVENTLOOP_ON_MAIN_THREAD ### check Ruby 1.9 !!!!!!!
- INTERP = TclTkIp.new(name, opts)
- else
- INTERP_MUTEX = Mutex.new
- INTERP_ROOT_CHECK = ConditionVariable.new
- INTERP_THREAD = Thread.new{
- begin
- Thread.current[:interp] = interp = TclTkIp.new(name, opts)
- rescue => e
- Thread.current[:interp] = e
- raise e
- end
- Thread.current[:status] = nil
- #sleep
-
- begin
- Thread.current[:status] = TclTkLib.mainloop(true)
- rescue Exception=>e
- Thread.current[:status] = e
- ensure
- INTERP_MUTEX.synchronize{ INTERP_ROOT_CHECK.broadcast }
- end
- Thread.current[:status] = TclTkLib.mainloop(false)
- }
-
- until INTERP_THREAD[:interp]
- Thread.pass
- end
- # INTERP_THREAD.run
- raise INTERP_THREAD[:interp] if INTERP_THREAD[:interp].kind_of? Exception
-
- INTERP = INTERP_THREAD[:interp]
- end
+ INTERP = TclTkIp.new(name, opts)
def INTERP.__getip
self
end
INTERP.instance_eval{
- # @tk_cmd_tbl = {}.taint
- @tk_cmd_tbl = Hash.new{|hash, key|
- fail IndexError, "unknown command ID '#{key}'"
- }.taint
+ @tk_cmd_tbl = {}.taint
def @tk_cmd_tbl.[]=(idx,val)
if self.has_key?(idx) && Thread.current.group != ThreadGroup::Default
fail SecurityError,"cannot change the entried command"
@@ -1216,10 +1157,6 @@ module TkCore
class Tk_OBJECT_TABLE
def initialize(id)
@id = id
- @mutex = Mutex.new
- end
- def mutex
- @mutex
end
def method_missing(m, *args, &b)
TkCore::INTERP.tk_object_table(@id).__send__(m, *args, &b)
@@ -1298,7 +1235,7 @@ module TkCore
}) << ' %W')
INTERP.add_tk_procs(TclTkLib::FINALIZE_PROC_NAME, '',
- "catch { bind all <#{WIDGET_DESTROY_HOOK}> {} }")
+ "bind all <#{WIDGET_DESTROY_HOOK}> {}")
INTERP.add_tk_procs('rb_out', 'ns args', <<-'EOL')
if [regexp {^::} $ns] {
@@ -1405,11 +1342,7 @@ module TkCore
"\n---< backtrace of Ruby side >-----\n" +
_toUTF8(e.backtrace.join("\n")) +
"\n---< backtrace of Tk side >-------"
- if TkCore::WITH_ENCODING
- msg.force_encoding('utf-8')
- else
- msg.instance_variable_set(:@encoding, 'utf-8')
- end
+ msg.instance_variable_set(:@encoding, 'utf-8')
rescue Exception
msg = e.class.inspect + ': ' + e.message + "\n" +
"\n---< backtrace of Ruby side >-----\n" +
@@ -1465,13 +1398,6 @@ module TkCore
end
def after(ms, cmd=Proc.new)
- cmdid = install_cmd(proc{ret = cmd.call;uninstall_cmd(cmdid); ret})
- after_id = tk_call_without_enc("after",ms,cmdid)
- after_id.instance_variable_set('@cmdid', cmdid)
- after_id
- end
-=begin
- def after(ms, cmd=Proc.new)
crit_bup = Thread.critical
Thread.critical = true
@@ -1494,16 +1420,8 @@ module TkCore
# tk_call("after",ms,cmdid)
# end
end
-=end
def after_idle(cmd=Proc.new)
- cmdid = install_cmd(proc{ret = cmd.call;uninstall_cmd(cmdid); ret})
- after_id = tk_call_without_enc('after','idle',cmdid)
- after_id.instance_variable_set('@cmdid', cmdid)
- after_id
- end
-=begin
- def after_idle(cmd=Proc.new)
crit_bup = Thread.critical
Thread.critical = true
@@ -1514,15 +1432,9 @@ module TkCore
tk_call_without_enc('after','idle',cmdid)
end
-=end
def after_cancel(afterId)
tk_call_without_enc('after','cancel',afterId)
- if (cmdid = afterId.instance_variable_get('@cmdid'))
- afterId.instance_variable_set('@cmdid', nil)
- uninstall_cmd(cmdid)
- end
- afterId
end
def windowingsystem
@@ -1642,27 +1554,7 @@ module TkCore
end
def mainloop(check_root = true)
- if !TkCore::WITH_RUBY_VM || TkCore::RUN_EVENTLOOP_ON_MAIN_THREAD
- TclTkLib.mainloop(check_root)
- else ### Ruby 1.9 !!!!!
- begin
- TclTkLib.set_eventloop_window_mode(true)
- if check_root
- INTERP_MUTEX.synchronize{
- INTERP_ROOT_CHECK.wait(INTERP_MUTEX)
- status = INTERP_THREAD[:status]
- if status
- INTERP_THREAD[:status] = nil
- raise status if status.kind_of?(Exception)
- end
- }
- else
- INTERP_THREAD.value
- end
- ensure
- TclTkLib.set_eventloop_window_mode(false)
- end
- end
+ TclTkLib.mainloop(check_root)
end
def mainloop_thread?
@@ -1670,12 +1562,7 @@ module TkCore
# nil : there is no mainloop
# false : mainloop is running on the other thread
# ( At then, it is dangerous to call Tk interpreter directly. )
- if !TkCore::WITH_RUBY_VM || TkCore::RUN_EVENTLOOP_ON_MAIN_THREAD
- ### Ruby 1.9 !!!!!!!!!!!
- TclTkLib.mainloop_thread?
- else
- Thread.current == INTERP_THREAD
- end
+ TclTkLib.mainloop_thread?
end
def mainloop_exist?
@@ -2027,7 +1914,7 @@ module Tk
end
def root
- Tk::Root.new
+ TkRoot.new
end
def Tk.load_tclscript(file, enc=nil)
@@ -2143,27 +2030,6 @@ module Tk
tk_call_without_enc('destroy', '.')
end
- ################################################
-
- def Tk.sleep(ms = nil, id = nil)
- if id
- var = (id.kind_of?(TkVariable))? id: TkVarAccess.new(id.to_s)
- else
- var = TkVariable.new
- end
-
- var.value = tk_call_without_enc('after', ms, proc{ var.value = 0 }) if ms
- var.thread_wait
- ms
- end
-
- def Tk.wakeup(id)
- ((id.kind_of?(TkVariable))? id: TkVarAccess.new(id.to_s)).value = 0
- nil
- end
-
- ################################################
-
def Tk.pack(*args)
TkPack.configure(*args)
end
@@ -2339,431 +2205,15 @@ end
# convert kanji string to/from utf-8
###########################################
if (/^(8\.[1-9]|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK)
- module Tk
- module Encoding
- extend Encoding
-
- TkCommandNames = ['encoding'.freeze].freeze
-
- #############################################
-
- if TkCore::WITH_ENCODING ### Ruby 1.9
- RubyEncoding = ::Encoding
-
- # for saving GC cost
- #ENCNAMES_CMD = ['encoding'.freeze, 'names'.freeze]
- BINARY_NAME = 'binary'.freeze
- UTF8_NAME = 'utf-8'.freeze
- DEFAULT_EXTERNAL_NAME = RubyEncoding.default_external.name.freeze
-
- BINARY = RubyEncoding.find(BINARY_NAME)
- UNKNOWN = RubyEncoding.find('ASCII-8BIT')
-
- ### start of creating ENCODING_TABLE
- ENCODING_TABLE = TkCore::INTERP.encoding_table
-=begin
- ENCODING_TABLE = {
- 'binary' => BINARY,
- # 'UNKNOWN-8BIT' => UNKNOWN,
- }
-
- list = TkCore::INTERP._invoke_without_enc(ENCNAMES_CMD[0],
- ENCNAMES_CMD[1])
- TkCore::INTERP._split_tklist(list).each{|name|
- begin
- enc = RubyEncoding.find(name)
- rescue ArgumentError
- case name
- when 'identity'
- enc = BINARY
- when 'shiftjis'
- enc = RubyEncoding.find('Shift_JIS')
- when 'unicode'
- enc = RubyEncoding.find('UTF-8')
- #if Tk.tk_call('set', 'tcl_platform(byteOrder)') =='littleEndian'
- # enc = RubyEncoding.find('UTF-16LE')
- #else
- # enc = RubyEncoding.find('UTF-16BE')
- #end
- when 'symbol'
- # single byte data
- enc = RubyEncoding.find('ASCII-8BIT') ### ???
- else
- # unsupported on Ruby, but supported on Tk
- enc = TkCore::INTERP.create_dummy_encoding_for_tk(name)
- end
- end
- ENCODING_TABLE[name.freeze] = enc
- }
-=end
-=begin
- def ENCODING_TABLE.get_name(enc)
- orig_enc = enc
-
- # unles enc, use system default
- # 1st: Ruby/Tk default encoding
- # 2nd: Tcl/Tk default encoding
- # 3rd: Ruby's default_external
- enc ||= TkCore::INTERP.encoding
- enc ||= TclTkLib.encoding_system
- enc ||= DEFAULT_EXTERNAL_NAME
-
- if enc.kind_of?(RubyEncoding)
- # Ruby's Encoding object
- if (name = self.key(enc))
- return name
- end
-
- # Is it new ?
- list = TkCore::INTERP._invoke_without_enc(ENCNAMES_CMD[0],
- ENCNAMES_CMD[1])
- TkComm.simplelist(list).each{|name|
- if ((enc == RubyEncoding.find(name)) rescue false)
- # new relation!! update table
- self[name.freeze] = enc
- return name
- end
- }
- else
- # String or Symbol ?
- if self[name = enc.to_s]
- return name
- end
-
- # Is it new ?
- if (enc_obj = (RubyEncoding.find(name) rescue false))
- list = TkCore::INTERP._invoke_without_enc(ENCNAMES_CMD[0],
- ENCNAMES_CMD[1])
- if TkComm.simplelist(list).index(name)
- # Tk's encoding name ?
- self[name.freeze] = enc_obj # new relation!! update table
- return name
- else
- # Ruby's encoding name ?
- if (name = self.key(enc_obj))
- return name
- end
- end
- end
- end
-
- fail ArgumentError, "unsupported Tk encoding '#{orig_enc}'"
- end
-
- def ENCODING_TABLE.get_obj(enc)
- # returns the encoding object.
- # If 'enc' is the encoding name on Tk only, it returns nil.
- ((obj = self[self.get_name(enc)]).kind_of?(RubyEncoding))? obj: nil
- end
-=end
- ### end of creating ENCODING_TABLE
-
- end
-
- #############################################
-
- if TkCore::WITH_ENCODING
- ################################
- ### Ruby 1.9
- ################################
- def force_default_encoding(mode)
- TkCore::INTERP.force_default_encoding = mode
- end
-
- def force_default_encoding?
- TkCore::INTERP.force_default_encoding?
- end
-
- def default_encoding=(enc)
- TkCore::INTERP.default_encoding = Tk::Encoding::ENCODING_TABLE.get_name(enc)
- end
-
- def encoding=(enc)
- TkCore::INTERP.encoding = Tk::Encoding::ENCODING_TABLE.get_name(enc)
- end
-
- def encoding_name
- Tk::Encoding::ENCODING_TABLE.get_name(TkCore::INTERP.encoding)
- end
- def encoding_obj
- Tk::Encoding::ENCODING_TABLE.get_obj(TkCore::INTERP.encoding)
- end
- alias encoding encoding_name
- alias default_encoding encoding_name
-
- def tk_encoding_names
- TkComm.simplelist(TkCore::INTERP._invoke_without_enc(Tk::Encoding::ENCNAMES_CMD[0], Tk::Encoding::ENCNAMES_CMD[1]))
- end
- def encoding_names
- self.tk_encoding_names.find_all{|name|
- Tk::Encoding::ENCODING_TABLE.get_name(name) rescue false
- }
- end
- def encoding_objs
- self.tk_encoding_names.map!{|name|
- Tk::Encoding::ENCODING_TABLE.get_obj(name) rescue nil
- }.compact
- end
-
- def encoding_system=(enc)
- TclTkLib.encoding_system = Tk::Encoding::ENCODING_TABLE.get_name(enc)
- end
-
- def encoding_system_name
- Tk::Encoding::ENCODING_TABLE.get_name(TclTkLib.encoding_system)
- end
- def encoding_system_obj
- Tk::Encoding::ENCODING_TABLE.get_obj(TclTkLib.encoding_system)
- end
- alias encoding_system encoding_system_name
-
- ################################
- else
- ################################
- ### Ruby 1.8-
- ################################
- def force_default_encoding=(mode)
- true
- end
-
- def force_default_encoding?
- true
- end
-
- def default_encoding=(enc)
- TkCore::INTERP.default_encoding = enc
- end
-
- def encoding=(enc)
- TkCore::INTERP.encoding = enc
- end
-
- def encoding_obj
- TkCore::INTERP.encoding
- end
- def encoding_name
- TkCore::INTERP.encoding
- end
- alias encoding encoding_name
- alias default_encoding encoding_name
-
- def tk_encoding_names
- TkComm.simplelist(Tk.tk_call('encoding', 'names'))
- end
- def encoding_objs
- self.tk_encoding_names
- end
- def encoding_names
- self.tk_encoding_names
- end
-
- def encoding_system=(enc)
- TclTkLib.encoding_system = enc
- end
-
- def encoding_system_name
- TclTkLib.encoding_system
- end
- def encoding_system_obj
- TclTkLib.encoding_system
- end
- alias encoding_system encoding_system_name
-
- ################################
- end
-
- def encoding_convertfrom(str, enc=nil)
- enc = encoding_system_name unless enc
- str = str.dup
- if TkCore::WITH_ENCODING
- if str.kind_of?(Tk::EncodedString)
- str.__instance_variable_set('@encoding', nil)
- else
- str.instance_variable_set('@encoding', nil)
- end
- str.force_encoding('binary')
- else
- str.instance_variable_set('@encoding', 'binary')
- end
- ret = TkCore::INTERP._invoke_without_enc('encoding', 'convertfrom',
- enc, str)
- if TkCore::WITH_ENCODING
- ret.force_encoding('utf-8')
- else
- Tk::UTF8_String.new(ret)
- end
- ret
- end
- alias encoding_convert_from encoding_convertfrom
-
- def encoding_convertto(str, enc=nil)
- # str must be a UTF-8 string
- enc = encoding_system_name unless enc
- ret = TkCore::INTERP._invoke_without_enc('encoding', 'convertto',
- enc, str)
- #ret.instance_variable_set('@encoding', 'binary')
- if TkCore::WITH_ENCODING
- #ret.force_encoding(Tk::Encoding::ENCODING_TABLE.get_obj('binary'))
- ret.force_encoding(Tk::Encoding::ENCODING_TABLE.get_obj(enc))
- end
- ret
- end
- alias encoding_convert_to encoding_convertto
-
- def encoding_dirs
- # Tcl8.5 feature
- TkComm.simplelist(Tk.tk_call_without_enc('encoding', 'dirs'))
- end
-
- def encoding_dirs=(dir_list) # an array or a Tcl's list string
- # Tcl8.5 feature
- Tk.tk_call_without_enc('encoding', 'dirs', dir_list)
- end
- end
-
- extend Encoding
- end
-
class TclTkIp
- def force_default_encoding=(mode)
- @force_default_encoding = (mode)? true: false
- end
-
- def force_default_encoding?
- @force_default_encoding ||= false
- end
-
- def default_encoding=(name)
- name = name.name if name.kind_of?(::Encoding) if Tk::WITH_ENCODING
- @encoding = name
- end
-
# from tkencoding.rb by ttate@jaist.ac.jp
- #attr_accessor :encoding
- def encoding=(name)
- self.force_default_encoding = true # for comaptibility
- self.default_encoding = name
- end
-
- def encoding_name
- (@encoding)? @encoding.dup: nil
- end
- alias encoding encoding_name
- alias default_encoding encoding_name
-
- def encoding_obj
- if Tk::WITH_ENCODING
- Tk::Encoding.tcl2rb_encoding(@encoding)
- else
- (@encoding)? @encoding.dup: nil
- end
- end
-
- alias __toUTF8 _toUTF8
- alias __fromUTF8 _fromUTF8
-
- if Object.const_defined?(:Encoding) && ::Encoding.class == Class
- # with Encoding (Ruby 1.9+)
- #
- # use functions on Tcl as default.
- # but when unsupported encoding on Tcl, use methods on Ruby.
- #
- def _toUTF8(str, enc = nil)
- if enc
- # use given encoding
- begin
- enc_name = Tk::Encoding::ENCODING_TABLE.get_name(enc)
- rescue
- # unknown encoding for Tk -> try to convert encoding on Ruby
- str = str.dup.force_encoding(enc)
- str.encode!(Tk::Encoding::UTF8_NAME) # modify self !!
- return str # if no error, probably succeed converting
- end
- end
-
- enc_name ||= str.instance_variable_get(:@encoding)
-
- enc_name ||=
- Tk::Encoding::ENCODING_TABLE.get_name(str.encoding) rescue nil
-
- unless enc_name
- # str.encoding isn't supported by Tk -> try to convert on Ruby
- begin
- return str.encode(Tk::Encoding::UTF8_NAME) # new string
- rescue
- # error -> ignore, try to use default encoding of Ruby/Tk
- end
- end
-
- #enc_name ||=
- # Tk::Encoding::ENCODING_TABLE.get_name(Tk.encoding) rescue nil
- enc_name ||= Tk::Encoding::ENCODING_TABLE.get_name(nil)
-
- # is 'binary' encoding?
- if enc_name == Tk::Encoding::BINARY_NAME
- return str.dup.force_encoding(Tk::Encoding::BINARY_NAME)
- end
-
- # force default encoding?
- if ! str.kind_of?(Tk::EncodedString) && self.force_default_encoding?
- enc_name = Tk::Encoding::ENCODING_TABLE.get_name(Tk.default_encoding)
- end
-
- encstr = __toUTF8(str, enc_name)
- encstr.force_encoding(Tk::Encoding::UTF8_NAME)
- encstr
- end
- def _fromUTF8(str, enc = nil)
- # str must be UTF-8 or binary.
- enc_name = str.instance_variable_get(:@encoding)
- enc_name ||=
- Tk::Encoding::ENCODING_TABLE.get_name(str.encoding) rescue nil
-
- # is 'binary' encoding?
- if enc_name == Tk::Encoding::BINARY_NAME
- return str.dup.force_encoding(Tk::Encoding::BINARY_NAME)
- end
-
- # get target encoding name (if enc == nil, use default encoding)
- begin
- enc_name = Tk::Encoding::ENCODING_TABLE.get_name(enc)
- rescue
- # then, enc != nil
- # unknown encoding for Tk -> try to convert encoding on Ruby
- str = str.dup.force_encoding(Tk::Encoding::UTF8_NAME)
- str.encode!(enc) # modify self !!
- return str # if no error, probably succeed converting
- end
-
- encstr = __fromUTF8(str, enc_name)
- encstr.force_encoding(Tk::Encoding::ENCODING_TABLE.get_obj(enc_name))
- encstr
- end
- ###
- else
- # without Encoding (Ruby 1.8)
- def _toUTF8(str, encoding = nil)
- __toUTF8(str, encoding)
- end
- def _fromUTF8(str, encoding = nil)
- __fromUTF8(str, encoding)
- end
- ###
- end
+ attr_accessor :encoding
alias __eval _eval
alias __invoke _invoke
- def _eval(cmd)
- _fromUTF8(__eval(_toUTF8(cmd)))
- end
-
- def _invoke(*cmds)
- _fromUTF8(__invoke(*(cmds.collect{|cmd| _toUTF8(cmd)})))
- end
-
- alias _eval_with_enc _eval
- alias _invoke_with_enc _invoke
+ alias __toUTF8 _toUTF8
+ alias __fromUTF8 _fromUTF8
=begin
#### --> definition is moved to TclTkIp module
@@ -2814,6 +2264,17 @@ if (/^(8\.[1-9]|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK)
end
=end
+ def _eval(cmd)
+ _fromUTF8(__eval(_toUTF8(cmd)))
+ end
+
+ def _invoke(*cmds)
+ _fromUTF8(__invoke(*(cmds.collect{|cmd| _toUTF8(cmd)})))
+ end
+
+ alias _eval_with_enc _eval
+ alias _invoke_with_enc _invoke
+
=begin
def _eval(cmd)
if defined?(@encoding) && @encoding != 'utf-8'
@@ -2870,213 +2331,126 @@ if (/^(8\.[1-9]|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK)
module TclTkLib
class << self
- def force_default_encoding=(mode)
- TkCore::INTERP.force_default_encoding = mode
+ alias _encoding encoding
+ alias _encoding= encoding=
+ def encoding=(name)
+ TkCore::INTERP.encoding = name
end
-
- def force_default_encoding?
- TkCore::INTERP.force_default_encoding?
+ def encoding
+ TkCore::INTERP.encoding
end
+ end
+ end
- def default_encoding=(name)
- TkCore::INTERP.default_encoding = name
- end
+ module Tk
+ module Encoding
+ extend Encoding
+
+ TkCommandNames = ['encoding'.freeze].freeze
- alias _encoding encoding
- alias _encoding= encoding=
def encoding=(name)
- name = name.name if name.kind_of?(::Encoding) if Tk::WITH_ENCODING
TkCore::INTERP.encoding = name
end
- def encoding_name
+ def encoding
TkCore::INTERP.encoding
end
- alias encoding encoding_name
- alias default_encoding encoding_name
- def encoding_obj
- if Tk::WITH_ENCODING
- Tk::Encoding.tcl2rb_encoding(TkCore::INTERP.encoding)
- else
- TkCore::INTERP.encoding
- end
+ def encoding_names
+ TkComm.simplelist(Tk.tk_call('encoding', 'names'))
end
- end
- end
- # estimate encoding
- unless TkCore::WITH_ENCODING
- case $KCODE
- when /^e/i # EUC
- Tk.encoding = 'euc-jp'
- Tk.encoding_system = 'euc-jp'
- when /^s/i # SJIS
- begin
- if Tk.encoding_system == 'cp932'
- Tk.encoding = 'cp932'
- else
- Tk.encoding = 'shiftjis'
- Tk.encoding_system = 'shiftjis'
- end
- rescue StandardError, NameError
- Tk.encoding = 'shiftjis'
- Tk.encoding_system = 'shiftjis'
- end
- when /^u/i # UTF8
- Tk.encoding = 'utf-8'
- Tk.encoding_system = 'utf-8'
- else # NONE
- if defined? DEFAULT_TK_ENCODING
- Tk.encoding_system = DEFAULT_TK_ENCODING
- end
- begin
- Tk.encoding = Tk.encoding_system
- rescue StandardError, NameError
- Tk.encoding = 'utf-8'
- Tk.encoding_system = 'utf-8'
+ def encoding_system
+ Tk.tk_call('encoding', 'system')
end
- end
- else ### Ruby 1.9 !!!!!!!!!!!!
- loc_enc_obj = ::Encoding.find(::Encoding.locale_charmap)
- ext_enc_obj = ::Encoding.default_external
- tksys_enc_name = Tk::Encoding::ENCODING_TABLE.get_name(Tk.encoding_system)
- # p [Tk.encoding, Tk.encoding_system, loc_enc_obj, ext_enc_obj]
+ def encoding_system=(enc)
+ Tk.tk_call('encoding', 'system', enc)
+ end
-=begin
- if ext_enc_obj == Tk::Encoding::UNKNOWN
- if defind? DEFAULT_TK_ENCODING
- if DEFAULT_TK_ENCODING.kind_of?(::Encoding)
- tk_enc_name = DEFAULT_TK_ENCODING.name
- tksys_enc_name = DEFAULT_TK_ENCODING.name
- else
- tk_enc_name = DEFAULT_TK_ENCODING
- tksys_enc_name = DEFAULT_TK_ENCODING
- end
- else
- tk_enc_name = loc_enc_obj.name
- tksys_enc_name = loc_enc_obj.name
+ def encoding_convertfrom(str, enc=nil)
+ # str is an usual enc string or a Tcl's internal string expression
+ # in enc (which is returned from 'encoding_convertto' method).
+ # the return value is a UTF-8 string.
+ enc = encoding_system unless enc
+ ret = TkCore::INTERP.__invoke('encoding', 'convertfrom', enc, str)
+ ret.instance_variable_set('@encoding', 'utf-8')
+ ret
end
- else
- tk_enc_name = ext_enc_obj.name
- tksys_enc_name = ext_enc_obj.name
- end
+ alias encoding_convert_from encoding_convertfrom
- # Tk.encoding = tk_enc_name
- Tk.default_encoding = tk_enc_name
- Tk.encoding_system = tksys_enc_name
-=end
+ def encoding_convertto(str, enc=nil)
+ # str must be a UTF-8 string.
+ # The return value is a Tcl's internal string expression in enc.
+ # To get an usual enc string, use Tk.fromUTF8(ret_val, enc).
+ enc = encoding_system unless enc
+ ret = TkCore::INTERP.__invoke('encoding', 'convertto', enc, str)
+ ret.instance_variable_set('@encoding', 'binary')
+ ret
+ end
+ alias encoding_convert_to encoding_convertto
- if ext_enc_obj == Tk::Encoding::UNKNOWN
- if loc_enc_obj == Tk::Encoding::UNKNOWN
- # use Tk.encoding_system
- else
- # use locale_charmap
- begin
- loc_enc_name = Tk::Encoding::ENCODING_TABLE.get_name(loc_enc_obj)
- if loc_enc_name && loc_enc_name != tksys_enc_name
- # use locale_charmap
- Tk.encoding_system = loc_enc_name
- else
- # use Tk.encoding_system
- end
- rescue ArgumentError
- # unsupported encoding on Tk -> use Tk.encoding_system
- end
+ def encoding_dirs
+ # Tcl8.5 feature
+ TkComm.simplelist(Tk.tk_call_without_enc('encoding', 'dirs'))
end
- else
- begin
- ext_enc_name = Tk::Encoding::ENCODING_TABLE.get_name(ext_enc_obj)
- if ext_enc_name && ext_enc_name != tksys_enc_name
- # use default_external
- Tk.encoding_system = ext_enc_name
- else
- # use Tk.encoding_system
- end
- rescue ArgumentError
- # unsupported encoding on Tk -> use Tk.encoding_system
+
+ def encoding_dirs=(dir_list) # an array or a Tcl's list string
+ # Tcl8.5 feature
+ Tk.tk_call_without_enc('encoding', 'dirs', dir_list)
end
end
- # setup Tk.encoding
- enc_name = nil
+ extend Encoding
+ end
+ # estimate encoding
+ case $KCODE
+ when /^e/i # EUC
+ Tk.encoding = 'euc-jp'
+ Tk.encoding_system = 'euc-jp'
+ when /^s/i # SJIS
begin
- default_def = DEFAULT_TK_ENCODING
- if ::Encoding.find(default_def.to_s) != Tk::Encoding::UNKNOWN
- enc_name = Tk::Encoding::ENCODING_TABLE.get_name(default_def)
- end
- rescue NameError
- # ignore
- enc_name = nil
- rescue ArgumentError
- enc_name = nil
- fail ArgumentError,
- "DEFAULT_TK_ENCODING has an unknown encoding #{default_def}"
- end
-
- unless enc_name
- if ext_enc_obj == Tk::Encoding::UNKNOWN
- if loc_enc_obj == Tk::Encoding::UNKNOWN
- # use Tk.encoding_system
- enc_name = tksys_enc_name
- else
- # use locale_charmap
- begin
- loc_enc_name = Tk::Encoding::ENCODING_TABLE.get_name(loc_enc_obj)
- if loc_enc_name && loc_enc_name != tksys_enc_name
- # use locale_charmap
- enc_name = loc_enc_name
- else
- # use Tk.encoding_system
- enc_name = tksys_enc_name
- end
- rescue ArgumentError
- # unsupported encoding on Tk -> use Tk.encoding_system
- enc_name = tksys_enc_name
- end
- end
+ if Tk.encoding_system == 'cp932'
+ Tk.encoding = 'cp932'
else
- begin
- ext_enc_name = Tk::Encoding::ENCODING_TABLE.get_name(ext_enc_obj)
- if ext_enc_name && ext_enc_name != tksys_enc_name
- # use default_external
- enc_name = ext_enc_name
- else
- # use Tk.encoding_system
- enc_name = tksys_enc_name
- end
- rescue ArgumentError
- # unsupported encoding on Tk -> use Tk.encoding_system
- enc_name = tksys_enc_name
- end
+ Tk.encoding = 'shiftjis'
+ Tk.encoding_system = 'shiftjis'
end
+ rescue StandardError, NameError
+ Tk.encoding = 'shiftjis'
+ Tk.encoding_system = 'shiftjis'
+ end
+ when /^u/i # UTF8
+ Tk.encoding = 'utf-8'
+ Tk.encoding_system = 'utf-8'
+ else # NONE
+ if defined? DEFAULT_TK_ENCODING
+ Tk.encoding_system = DEFAULT_TK_ENCODING
+ end
+ begin
+ Tk.encoding = Tk.encoding_system
+ rescue StandardError, NameError
+ Tk.encoding = 'utf-8'
+ Tk.encoding_system = 'utf-8'
end
-
- Tk.default_encoding = (enc_name)? enc_name: tksys_enc_name
end
else
# dummy methods
- module Tk
- module Encoding
- extend Encoding
+ class TclTkIp
+ attr_accessor :encoding
- def force_default_encoding=(mode)
- nil
- end
+ alias __eval _eval
+ alias __invoke _invoke
- def force_default_encoding?
- nil
- end
+ alias _eval_with_enc _eval
+ alias _invoke_with_enc _invoke
+ end
- def default_encoding=(enc)
- nil
- end
- def default_encoding
- nil
- end
+ module Tk
+ module Encoding
+ extend Encoding
def encoding=(name)
nil
@@ -3113,16 +2487,6 @@ else
extend Encoding
end
-
- class TclTkIp
- attr_accessor :encoding
-
- alias __eval _eval
- alias __invoke _invoke
-
- alias _eval_with_enc _eval
- alias _invoke_with_enc _invoke
- end
end
@@ -3245,15 +2609,7 @@ module TkTreatFont
next
else
fnt = hash_kv(fnt) if fnt.kind_of?(Hash)
- unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
- tk_call(*(__config_cmd << "-#{optkey}" << fnt))
- else
- begin
- tk_call(*(__config_cmd << "-#{optkey}" << fnt))
- rescue
- # ignore
- end
- end
+ tk_call(*(__config_cmd << "-#{optkey}" << fnt))
end
end
next
@@ -3307,15 +2663,7 @@ module TkTreatFont
fobj = fontobj # create a new TkFont object
else
ltn = hash_kv(ltn) if ltn.kind_of?(Hash)
- unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
- tk_call(*(__config_cmd << "-#{optkey}" << ltn))
- else
- begin
- tk_call(*(__config_cmd << "-#{optkey}" << ltn))
- rescue => e
- # ignore
- end
- end
+ tk_call(*(__config_cmd << "-#{optkey}" << ltn))
next
end
@@ -3367,15 +2715,7 @@ module TkTreatFont
fobj = fontobj # create a new TkFont object
else
knj = hash_kv(knj) if knj.kind_of?(Hash)
- unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
- tk_call(*(__config_cmd << "-#{optkey}" << knj))
- else
- begin
- tk_call(*(__config_cmd << "-#{optkey}" << knj))
- rescue => e
- # ignore
- end
- end
+ tk_call(*(__config_cmd << "-#{optkey}" << knj))
next
end
@@ -3476,14 +2816,6 @@ module TkConfigMethod
include TkUtil
include TkTreatFont
- def TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
- @mode || false
- end
- def TkConfigMethod.__set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode)
- fail SecurityError, "can't change the mode" if $SAFE>=4
- @mode = (mode)? true: false
- end
-
def __cget_cmd
[self.path, 'cget']
end
@@ -3497,7 +2829,7 @@ module TkConfigMethod
def __confinfo_cmd
__config_cmd
end
- private :__confinfo_cmd
+ private :__config_cmd
def __configinfo_struct
{:key=>0, :alias=>1, :db_name=>1, :db_class=>2,
@@ -3505,11 +2837,6 @@ module TkConfigMethod
end
private :__configinfo_struct
- def __optkey_aliases
- {}
- end
- private :__optkey_aliases
-
def __numval_optkeys
[]
end
@@ -3599,7 +2926,6 @@ 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)
@@ -3616,7 +2942,7 @@ module TkConfigMethod
val
end
- def __cget_core(slot)
+ def cget(slot)
orig_slot = slot
slot = slot.to_s
@@ -3624,11 +2950,6 @@ module TkConfigMethod
fail ArgumentError, "Invalid option `#{orig_slot.inspect}'"
end
- alias_name, real_name = __optkey_aliases.find{|k, v| k.to_s == slot}
- if real_name
- slot = real_name.to_s
- end
-
if ( method = _symbolkey2str(__val2ruby_optkeys())[slot] )
optval = tk_call_without_enc(*(__cget_cmd << "-#{slot}"))
begin
@@ -3697,41 +3018,11 @@ module TkConfigMethod
tk_tcl2ruby(tk_call_without_enc(*(__cget_cmd << "-#{slot}")), true)
end
end
- private :__cget_core
- def cget(slot)
- unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
- __cget_core(slot)
- else
- begin
- __cget_core(slot)
- rescue => e
- if current_configinfo.has_key?(slot.to_s)
- # error on known option
- fail e
- else
- # unknown option
- nil
- end
- end
- end
- end
- def cget_strict(slot)
- # never use TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
- __cget_core(slot)
- end
-
- def __configure_core(slot, value=None)
+ def configure(slot, value=None)
if slot.kind_of? Hash
slot = _symbolkey2str(slot)
- __optkey_aliases.each{|alias_name, real_name|
- alias_name = alias_name.to_s
- if slot.has_key?(alias_name)
- slot[real_name.to_s] = slot.delete(alias_name)
- end
- }
-
__methodcall_optkeys.each{|key, method|
value = slot.delete(key.to_s)
self.__send__(method, value) if value
@@ -3768,11 +3059,6 @@ module TkConfigMethod
fail ArgumentError, "Invalid option `#{orig_slot.inspect}'"
end
- alias_name, real_name = __optkey_aliases.find{|k, v| k.to_s == slot}
- if real_name
- slot = real_name.to_s
- end
-
if ( conf = __keyonly_optkeys.find{|k, v| k.to_s == slot} )
defkey, undefkey = conf
if value
@@ -3796,55 +3082,12 @@ module TkConfigMethod
end
self
end
- private :__configure_core
-
- def __check_available_configure_options(keys)
- availables = self.current_configinfo.keys
-
- # add non-standard keys
- availables |= __font_optkeys.map{|k|
- [k.to_s, "latin#{k}", "ascii#{k}", "kanji#{k}"]
- }.flatten
- availables |= __methodcall_optkeys.keys.map{|k| k.to_s}
- availables |= __keyonly_optkeys.keys.map{|k| k.to_s}
-
- keys = _symbolkey2str(keys)
- keys.delete_if{|k, v| !(availables.include?(k))}
- end
-
- def configure(slot, value=None)
- unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
- __configure_core(slot, value)
- else
- if slot.kind_of?(Hash)
- begin
- __configure_core(slot)
- rescue
- slot = __check_available_configure_options(slot)
- __configure_core(slot) unless slot.empty?
- end
- else
- begin
- __configure_core(slot, value)
- rescue => e
- if current_configinfo.has_key?(slot.to_s)
- # error on known option
- fail e
- else
- # unknown option
- nil
- end
- end
- end
- end
- self
- end
def configure_cmd(slot, value)
configure(slot, install_cmd(value))
end
- def __configinfo_core(slot = nil)
+ def configinfo(slot = nil)
if TkComm::GET_CONFIGINFO_AS_ARRAY
if (slot &&
slot.to_s =~ /^(|latin|ascii|kanji)(#{__font_optkeys.join('|')})$/)
@@ -3855,10 +3098,6 @@ module TkConfigMethod
conf[__configinfo_struct[:key]][1..-1]
if ( ! __configinfo_struct[:alias] \
|| conf.size > __configinfo_struct[:alias] + 1 )
- fnt = conf[__configinfo_struct[:default_value]]
- if TkFont.is_system_font?(fnt)
- conf[__configinfo_struct[:default_value]] = TkNamedFont.new(fnt)
- end
conf[__configinfo_struct[:current_value]] = fontobj(fontkey)
elsif ( __configinfo_struct[:alias] \
&& conf.size == __configinfo_struct[:alias] + 1 \
@@ -3870,12 +3109,6 @@ module TkConfigMethod
else
if slot
slot = slot.to_s
-
- alias_name, real_name = __optkey_aliases.find{|k, v| k.to_s == slot}
- if real_name
- slot = real_name.to_s
- end
-
case slot
when /^(#{__val2ruby_optkeys().keys.join('|')})$/
method = _symbolkey2str(__val2ruby_optkeys())[slot]
@@ -4201,11 +3434,6 @@ module TkConfigMethod
fontconf = ret.assoc(optkey)
if fontconf && fontconf.size > 2
ret.delete_if{|inf| inf[0] =~ /^(|latin|ascii|kanji)#{optkey}$/}
- fnt = fontconf[__configinfo_struct[:default_value]]
- if TkFont.is_system_font?(fnt)
- fontconf[__configinfo_struct[:default_value]] \
- = TkNamedFont.new(fnt)
- end
fontconf[__configinfo_struct[:current_value]] = fontobj(optkey)
ret.push(fontconf)
end
@@ -4230,10 +3458,6 @@ module TkConfigMethod
if ( ! __configinfo_struct[:alias] \
|| conf.size > __configinfo_struct[:alias] + 1 )
- fnt = conf[__configinfo_struct[:default_value]]
- if TkFont.is_system_font?(fnt)
- conf[__configinfo_struct[:default_value]] = TkNamedFont.new(fnt)
- end
conf[__configinfo_struct[:current_value]] = fontobj(fontkey)
{ conf.shift => conf }
elsif ( __configinfo_struct[:alias] \
@@ -4249,12 +3473,6 @@ module TkConfigMethod
else
if slot
slot = slot.to_s
-
- alias_name, real_name = __optkey_aliases.find{|k, v| k.to_s == slot}
- if real_name
- slot = real_name.to_s
- end
-
case slot
when /^(#{__val2ruby_optkeys().keys.join('|')})$/
method = _symbolkey2str(__val2ruby_optkeys())[slot]
@@ -4587,11 +3805,6 @@ module TkConfigMethod
ret.delete('latin' << optkey)
ret.delete('ascii' << optkey)
ret.delete('kanji' << optkey)
- fnt = fontconf[__configinfo_struct[:default_value]]
- if TkFont.is_system_font?(fnt)
- fontconf[__configinfo_struct[:default_value]] \
- = TkNamedFont.new(fnt)
- end
fontconf[__configinfo_struct[:current_value]] = fontobj(optkey)
ret[optkey] = fontconf
end
@@ -4606,19 +3819,6 @@ module TkConfigMethod
end
end
end
- private :__configinfo_core
-
- def configinfo(slot = nil)
- if slot && TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
- begin
- __configinfo_core(slot)
- rescue
- Array.new(__configinfo_struct.values.max).unshift(slot.to_s)
- end
- else
- __configinfo_core(slot)
- end
- end
def current_configinfo(slot = nil)
if TkComm::GET_CONFIGINFO_AS_ARRAY
@@ -4718,12 +3918,7 @@ class TkObject<TkKernel
begin
cget(name)
rescue
- if self.kind_of?(TkWindow)
- fail NameError,
- "unknown option '#{id}' for #{self.inspect} (deleted widget?)"
- else
- super(id, *args)
- end
+ super(id, *args)
# fail NameError,
# "undefined local variable or method `#{name}' for #{self.to_s}",
# error_at
@@ -4778,15 +3973,6 @@ end
class TkWindow<TkObject
include TkWinfo
extend TkBindCore
- include Tk::Wm_for_General
-
- @@WIDGET_INSPECT_FULL = false
- def TkWindow._widget_inspect_full_?
- @@WIDGET_INSPECT_FULL
- end
- def TkWindow._widget_inspect_full_=(mode)
- @@WIDGET_INSPECT_FULL = (mode && true) || false
- end
TkCommandNames = [].freeze
## ==> If TkCommandNames[0] is a string (not a null string),
@@ -4850,13 +4036,6 @@ class TkWindow<TkObject
fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
}
- __optkey_aliases.each{|alias_name, real_name|
- alias_name = alias_name.to_s
- if keys.has_key?(alias_name)
- keys[real_name.to_s] = keys.delete(alias_name)
- end
- }
-
__methodcall_optkeys.each{|key|
key = key.to_s
methodkeys[key] = keys.delete(key) if keys.key?(key)
@@ -4889,48 +4068,13 @@ class TkWindow<TkObject
end
if keys and keys != None
- unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
- tk_call_without_enc(cmd, @path, *hash_kv(keys, true))
- else
- begin
- tk_call_without_enc(cmd, @path, *hash_kv(keys, true))
- rescue => e
- tk_call_without_enc(cmd, @path)
- keys = __check_available_configure_options(keys)
- unless keys.empty?
- begin
- # try to configure
- configure(keys)
- rescue
- # fail => includes options adaptable when creattion only?
- begin
- tk_call_without_enc('destroy', @path)
- rescue
- # cannot rescue options error
- fail e
- else
- # re-create widget
- tk_call_without_enc(cmd, @path, *hash_kv(keys, true))
- end
- end
- end
- end
- end
+ tk_call_without_enc(cmd, @path, *hash_kv(keys, true))
else
tk_call_without_enc(cmd, @path)
end
end
private :create_self
- def inspect
- if @@WIDGET_INSPECT_FULL
- super
- else
- str = super
- str[0..(str.index(' '))] << '@path=' << @path.inspect << '>'
- end
- end
-
def exist?
TkWinfo.exist?(self)
end
@@ -5052,15 +4196,6 @@ class TkWindow<TkObject
self
end
- def grid_anchor(anchor=None)
- if anchor == None
- TkGrid.anchor(self)
- else
- TkGrid.anchor(self, anchor)
- self
- end
- end
-
def grid_forget
#tk_call('grid', 'forget', epath)
TkGrid.forget(self)
@@ -5092,14 +4227,12 @@ class TkWindow<TkObject
TkGrid.columnconfigure(self, index, keys)
end
alias grid_columnconfigure grid_columnconfig
- alias grid_column grid_columnconfig
def grid_rowconfig(index, keys)
#tk_call('grid', 'rowconfigure', epath, index, *hash_kv(keys))
TkGrid.rowconfigure(self, index, keys)
end
alias grid_rowconfigure grid_rowconfig
- alias grid_row grid_rowconfig
def grid_columnconfiginfo(index, slot=nil)
#if slot
@@ -5342,13 +4475,11 @@ class TkWindow<TkObject
end
children.each{|path, obj|
- obj.instance_eval{
- if defined?(@cmdtbl)
- for id in @cmdtbl
- uninstall_cmd id
- end
+ if defined?(@cmdtbl)
+ for id in @cmdtbl
+ uninstall_cmd id
end
- }
+ end
TkCore::INTERP.tk_windows.delete(path)
}
@@ -5453,7 +4584,7 @@ class TkWindow<TkObject
bindtags(bindtags().unshift(tag))
end
end
-TkWidget = TkWindow
+
# freeze core modules
#TclTkLib.freeze
@@ -5466,7 +4597,7 @@ TkWidget = TkWindow
#Tk.freeze
module Tk
- RELEASE_DATE = '2008-05-23'.freeze
+ RELEASE_DATE = '2006-07-14'.freeze
autoload :AUTO_PATH, 'tk/variable'
autoload :TCL_PACKAGE_PATH, 'tk/variable'
@@ -5478,7 +4609,6 @@ 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 8c58210331..24a048ee32 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$
+# $Id: after.rb,v 1.1.2.1 2004/05/01 16:09:49 nagai Exp $
#
require 'tk/timer'
diff --git a/ext/tk/lib/tk/autoload.rb b/ext/tk/lib/tk/autoload.rb
index 0773f7708d..6b3773f4ea 100644
--- a/ext/tk/lib/tk/autoload.rb
+++ b/ext/tk/lib/tk/autoload.rb
@@ -1,19 +1,9 @@
#
# autoload
#
-############################################
-# geometry manager
-module Tk
- autoload :Grid, 'tk/grid'
- def Grid(*args); TkGrid.configure(*args); end
-
- autoload :Pack, 'tk/pack'
- def Pack(*args); TkPack.configure(*args); end
-
- autoload :Place, 'tk/place'
- def Place(*args); TkPlace.configure(*args); end
-end
+#######################
+# geometry manager
autoload :TkGrid, 'tk/grid'
def TkGrid(*args); TkGrid.configure(*args); end
@@ -24,117 +14,19 @@ autoload :TkPlace, 'tk/place'
def TkPlace(*args); TkPlace.configure(*args); end
-############################################
-# classes on Tk module
-module Tk
- autoload :Button, 'tk/button'
-
- autoload :Canvas, 'tk/canvas'
-
- autoload :CheckButton, 'tk/checkbutton'
- autoload :Checkbutton, 'tk/checkbutton'
-
- autoload :Entry, 'tk/entry'
-
- autoload :Frame, 'tk/frame'
-
- autoload :Label, 'tk/label'
-
- autoload :LabelFrame, 'tk/labelframe'
- autoload :Labelframe, 'tk/labelframe'
-
- autoload :Listbox, 'tk/listbox'
-
- autoload :Menu, 'tk/menu'
- autoload :MenuClone, 'tk/menu'
- autoload :CloneMenu, 'tk/menu'
- autoload :SystemMenu, 'tk/menu'
- autoload :SysMenu_Help, 'tk/menu'
- autoload :SysMenu_System, 'tk/menu'
- autoload :SysMenu_Apple, 'tk/menu'
- autoload :Menubutton, 'tk/menu'
- autoload :MenuButton, 'tk/menu'
- autoload :OptionMenubutton, 'tk/menu'
- autoload :OptionMenBbutton, 'tk/menu'
-
- autoload :Message, 'tk/message'
-
- autoload :PanedWindow, 'tk/panedwindow'
- autoload :Panedwindow, 'tk/panedwindow'
-
- autoload :RadioButton, 'tk/radiobutton'
- autoload :Radiobutton, 'tk/radiobutton'
-
- autoload :Root, 'tk/root'
-
- autoload :Scale, 'tk/scale'
-
- autoload :Scrollbar, 'tk/scrollbar'
- autoload :XScrollbar, 'tk/scrollbar'
- autoload :YScrollbar, 'tk/scrollbar'
-
- autoload :Spinbox, 'tk/spinbox'
-
- autoload :Text, 'tk/text'
-
- autoload :Toplevel, 'tk/toplevel'
-end
-
-
-############################################
-# sub-module of Tk
-module Tk
- autoload :Clock, 'tk/clock'
-
- autoload :OptionObj, 'tk/optionobj'
-
- autoload :X_Scrollable, 'tk/scrollable'
- autoload :Y_Scrollable, 'tk/scrollable'
- autoload :Scrollable, 'tk/scrollable'
-
- autoload :Wm, 'tk/wm'
- autoload :Wm_for_General, 'tk/wm'
-
- autoload :MacResource, 'tk/macpkg'
-
- autoload :WinDDE, 'tk/winpkg'
- autoload :WinRegistry, 'tk/winpkg'
-
- autoload :ValidateConfigure, 'tk/validation'
- autoload :ItemValidateConfigure, 'tk/validation'
-
- autoload :EncodedString, 'tk/encodedstr'
- def Tk.EncodedString(str, enc = nil); Tk::EncodedString.new(str, enc); end
-
- autoload :BinaryString, 'tk/encodedstr'
- def Tk.BinaryString(str); Tk::BinaryString.new(str); end
-
- autoload :UTF8_String, 'tk/encodedstr'
- def Tk.UTF8_String(str); Tk::UTF8_String.new(str); end
-
-end
-
-
-############################################
-# toplevel classes/modules (fixed)
+#######################
+# others
autoload :TkBgError, 'tk/bgerror'
autoload :TkBindTag, 'tk/bindtag'
autoload :TkBindTagAll, 'tk/bindtag'
autoload :TkDatabaseClass, 'tk/bindtag'
+autoload :TkButton, 'tk/button'
+
autoload :TkConsole, 'tk/console'
-autoload :TkcItem, 'tk/canvas'
-autoload :TkcArc, 'tk/canvas'
-autoload :TkcBitmap, 'tk/canvas'
-autoload :TkcImage, 'tk/canvas'
-autoload :TkcLine, 'tk/canvas'
-autoload :TkcOval, 'tk/canvas'
-autoload :TkcPolygon, 'tk/canvas'
-autoload :TkcRectangle, 'tk/canvas'
-autoload :TkcText, 'tk/canvas'
-autoload :TkcWindow, 'tk/canvas'
+autoload :TkCanvas, 'tk/canvas'
autoload :TkcTagAccess, 'tk/canvastag'
autoload :TkcTag, 'tk/canvastag'
@@ -144,6 +36,9 @@ autoload :TkcTagAll, 'tk/canvastag'
autoload :TkcTagCurrent, 'tk/canvastag'
autoload :TkcTagGroup, 'tk/canvastag'
+autoload :TkCheckButton, 'tk/checkbutton'
+autoload :TkCheckbutton, 'tk/checkbutton'
+
autoload :TkClipboard, 'tk/clipboard'
autoload :TkComposite, 'tk/composite'
@@ -157,10 +52,14 @@ autoload :TkWarning, 'tk/dialog'
autoload :TkWarning2, 'tk/dialog'
autoload :TkWarningObj, 'tk/dialog'
+autoload :TkEntry, 'tk/entry'
+
autoload :TkEvent, 'tk/event'
autoload :TkFont, 'tk/font'
-autoload :TkNamedFont, 'tk/font'
+autoload :TkTreatTagFont, 'tk/font'
+
+autoload :TkFrame, 'tk/frame'
autoload :TkImage, 'tk/image'
autoload :TkBitmapImage, 'tk/image'
@@ -172,12 +71,30 @@ autoload :TkTreatItemFont, 'tk/itemfont'
autoload :TkKinput, 'tk/kinput'
+autoload :TkLabel, 'tk/label'
+
+autoload :TkLabelFrame, 'tk/labelframe'
+autoload :TkLabelframe, 'tk/labelframe'
+
+autoload :TkListbox, 'tk/listbox'
+
+autoload :TkMacResource, 'tk/macpkg'
+
+autoload :TkMenu, 'tk/menu'
+autoload :TkMenuClone, 'tk/menu'
autoload :TkSystemMenu, 'tk/menu'
+autoload :TkSysMenu_Help, 'tk/menu'
+autoload :TkSysMenu_System, 'tk/menu'
+autoload :TkSysMenu_Apple, 'tk/menu'
+autoload :TkMenubutton, 'tk/menu'
+autoload :TkOptionMenubutton, 'tk/menu'
autoload :TkMenubar, 'tk/menubar'
autoload :TkMenuSpec, 'tk/menuspec'
+autoload :TkMessage, 'tk/message'
+
autoload :TkManageFocus, 'tk/mngfocus'
autoload :TkMsgCatalog, 'tk/msgcat'
@@ -193,46 +110,53 @@ autoload :TkPackage, 'tk/package'
autoload :TkPalette, 'tk/palette'
+autoload :TkPanedWindow, 'tk/panedwindow'
+autoload :TkPanedwindow, 'tk/panedwindow'
+
+autoload :TkRadioButton, 'tk/radiobutton'
+autoload :TkRadiobutton, 'tk/radiobutton'
+
autoload :TkRoot, 'tk/root'
+autoload :TkScale, 'tk/scale'
+
+autoload :TkScrollbar, 'tk/scrollbar'
+autoload :TkXScrollbar, 'tk/scrollbar'
+autoload :TkYScrollbar, 'tk/scrollbar'
+
autoload :TkScrollbox, 'tk/scrollbox'
autoload :TkSelection, 'tk/selection'
+autoload :TkSpinbox, 'tk/spinbox'
+
autoload :TkTreatTagFont, 'tk/tagfont'
+autoload :TkText, 'tk/text'
+
autoload :TkTextImage, 'tk/textimage'
-autoload :TktImage, 'tk/textimage'
autoload :TkTextMark, 'tk/textmark'
autoload :TkTextNamedMark, 'tk/textmark'
autoload :TkTextMarkInsert, 'tk/textmark'
autoload :TkTextMarkCurrent, 'tk/textmark'
autoload :TkTextMarkAnchor, 'tk/textmark'
-autoload :TktMark, 'tk/textmark'
-autoload :TktNamedMark, 'tk/textmark'
-autoload :TktMarkInsert, 'tk/textmark'
-autoload :TktMarkCurrent, 'tk/textmark'
-autoload :TktMarkAnchor, 'tk/textmark'
autoload :TkTextTag, 'tk/texttag'
autoload :TkTextNamedTag, 'tk/texttag'
autoload :TkTextTagSel, 'tk/texttag'
-autoload :TktTag, 'tk/texttag'
-autoload :TktNamedTag, 'tk/texttag'
-autoload :TktTagSel, 'tk/texttag'
autoload :TkTextWindow, 'tk/textwindow'
-autoload :TktWindow, 'tk/textwindow'
autoload :TkAfter, 'tk/timer'
autoload :TkTimer, 'tk/timer'
autoload :TkRTTimer, 'tk/timer'
+autoload :TkToplevel, 'tk/toplevel'
+
autoload :TkTextWin, 'tk/txtwin_abst'
autoload :TkValidation, 'tk/validation'
-autoload :TkValidateCommand, 'tk/validation'
autoload :TkVariable, 'tk/variable'
autoload :TkVarAccess, 'tk/variable'
@@ -242,173 +166,31 @@ autoload :TkNamedVirtualEvent,'tk/virtevent'
autoload :TkWinfo, 'tk/winfo'
+autoload :TkWinDDE, 'tk/winpkg'
+autoload :TkWinRegistry, 'tk/winpkg'
+
autoload :TkXIM, 'tk/xim'
-############################################
-# toplevel classes/modules (switchable)
+#######################
+# sub-module of Tk
module Tk
- @TOPLEVEL_ALIAS_TABLE = {}
- @TOPLEVEL_ALIAS_TABLE[:Tk] = {
- :TkButton => 'tk/button',
-
- :TkCanvas => 'tk/canvas',
-
- :TkCheckButton => 'tk/checkbutton',
- :TkCheckbutton => 'tk/checkbutton',
-
- # :TkDialog => 'tk/dialog',
- # :TkDialog2 => 'tk/dialog',
- # :TkDialogObj => 'tk/dialog',
- # :TkWarning => 'tk/dialog',
- # :TkWarning2 => 'tk/dialog',
- # :TkWarningObj => 'tk/dialog',
-
- :TkEntry => 'tk/entry',
-
- :TkFrame => 'tk/frame',
-
- :TkLabel => 'tk/label',
-
- :TkLabelFrame => 'tk/labelframe',
- :TkLabelframe => 'tk/labelframe',
-
- :TkListbox => 'tk/listbox',
-
- :TkMacResource => 'tk/macpkg',
-
- :TkMenu => 'tk/menu',
- :TkMenuClone => 'tk/menu',
- :TkCloneMenu => 'tk/menu',
- # :TkSystemMenu => 'tk/menu',
- :TkSysMenu_Help => 'tk/menu',
- :TkSysMenu_System => 'tk/menu',
- :TkSysMenu_Apple => 'tk/menu',
- :TkMenubutton => 'tk/menu',
- :TkMenuButton => 'tk/menu',
- :TkOptionMenubutton => 'tk/menu',
- :TkOptionMenuButton => 'tk/menu',
-
- :TkMessage => 'tk/message',
-
- :TkPanedWindow => 'tk/panedwindow',
- :TkPanedwindow => 'tk/panedwindow',
-
- :TkRadioButton => 'tk/radiobutton',
- :TkRadiobutton => 'tk/radiobutton',
-
- # :TkRoot => 'tk/root',
-
- :TkScale => 'tk/scale',
-
- :TkScrollbar => 'tk/scrollbar',
- :TkXScrollbar => 'tk/scrollbar',
- :TkYScrollbar => 'tk/scrollbar',
-
- :TkSpinbox => 'tk/spinbox',
-
- :TkText => 'tk/text',
-
- :TkToplevel => 'tk/toplevel',
-
- :TkWinDDE => 'tk/winpkg',
- :TkWinRegistry => 'tk/winpkg',
- }
-
- @TOPLEVEL_ALIAS_OWNER = {}
-
- @TOPLEVEL_ALIAS_SETUP_PROC = {}
-
- @current_default_widget_set = nil
-end
-
-
-############################################
-# methods to control default widget set
-############################################
-
-class << Tk
- def default_widget_set
- @current_default_widget_set
- end
-
- def default_widget_set=(target)
- target = target.to_sym
- return target if target == @current_default_widget_set
-
- if (cmd = @TOPLEVEL_ALIAS_SETUP_PROC[target])
- cmd.call(target)
- end
-
- _replace_toplevel_aliases(target)
- end
-
- def __set_toplevel_aliases__(target, obj, *symbols)
- @TOPLEVEL_ALIAS_TABLE[target = target.to_sym] ||= {}
- symbols.each{|sym|
- @TOPLEVEL_ALIAS_TABLE[target][sym = sym.to_sym] = obj
- # if @current_default_widget_set == target
- if @TOPLEVEL_ALIAS_OWNER[sym] == target
- Object.class_eval{remove_const sym} if Object.const_defined?(sym)
- Object.const_set(sym, obj)
- end
- }
- end
-
- ###################################
- private
- def _replace_toplevel_aliases(target)
- # check already autoloaded
- if (table = @TOPLEVEL_ALIAS_TABLE[current = @current_default_widget_set])
- table.each{|sym, file|
- if !Object.autoload?(sym) && Object.const_defined?(sym) &&
- @TOPLEVEL_ALIAS_TABLE[current][sym].kind_of?(String)
- # autoload -> class
- @TOPLEVEL_ALIAS_TABLE[current][sym] = Object.const_get(sym)
- end
- }
- end
-
- # setup autoloads
- @TOPLEVEL_ALIAS_TABLE[target].each{|sym, file|
- Object.class_eval{remove_const sym} if Object.const_defined?(sym)
- if file.kind_of?(String)
- # file => autoload target file
- Object.autoload(sym, file)
- else
- # file => loaded class object
- Object.const_set(sym, file)
- end
- @TOPLEVEL_ALIAS_OWNER[sym] = target
- }
-
- # update current alias
- @current_default_widget_set = target
- end
-end
-
-############################################
-# setup default widget set => :Tk
-Tk.default_widget_set = :Tk
+ autoload :Clock, 'tk/clock'
+ autoload :OptionObj, 'tk/optionobj'
+ autoload :X_Scrollable, 'tk/scrollable'
+ autoload :Y_Scrollable, 'tk/scrollable'
+ autoload :Scrollable, 'tk/scrollable'
+ autoload :Wm, 'tk/wm'
+ autoload :ValidateConfigure, 'tk/validation'
+ autoload :ItemValidateConfigure, 'tk/validation'
-############################################
-# depend on the version of Tcl/Tk
-# major, minor, type, type_name, patchlevel = TclTkLib.get_version
+ autoload :EncodedString, 'tk/encodedstr'
+ def Tk.EncodedString(str, enc = nil); Tk::EncodedString.new(str, enc); end
-############################################
-# Ttk (Tile) support
-=begin
-if major > 8 ||
- (major == 8 && minor > 5) ||
- (major == 8 && minor == 5 && type >= TclTkLib::RELEASE_TYPE::BETA)
- # Tcl/Tk 8.5 beta or later
- Object.autoload :Ttk, 'tkextlib/tile'
- Tk.autoload :Tile, 'tkextlib/tile'
+ autoload :BinaryString, 'tk/encodedstr'
+ def Tk.BinaryString(str); Tk::BinaryString.new(str); end
- require 'tk/ttk_selector'
+ autoload :UTF8_String, 'tk/encodedstr'
+ def Tk.UTF8_String(str); Tk::UTF8_String.new(str); end
end
-=end
-Object.autoload :Ttk, 'tkextlib/tile'
-Tk.autoload :Tile, 'tkextlib/tile'
-require 'tk/ttk_selector'
diff --git a/ext/tk/lib/tk/bindtag.rb b/ext/tk/lib/tk/bindtag.rb
index 88c8367a88..9023a08e06 100644
--- a/ext/tk/lib/tk/bindtag.rb
+++ b/ext/tk/lib/tk/bindtag.rb
@@ -8,64 +8,30 @@ class TkBindTag
#BTagID_TBL = {}
BTagID_TBL = TkCore::INTERP.create_table
+ Tk_BINDTAG_ID = ["btag".freeze, "00000".taint].freeze
- (Tk_BINDTAG_ID = ["btag".freeze, "00000".taint]).instance_eval{
- @mutex = Mutex.new
- def mutex; @mutex; end
- freeze
- }
-
- TkCore::INTERP.init_ip_env{
- BTagID_TBL.mutex.synchronize{ BTagID_TBL.clear }
- }
+ TkCore::INTERP.init_ip_env{ BTagID_TBL.clear }
def TkBindTag.id2obj(id)
- BTagID_TBL.mutex.synchronize{
- (BTagID_TBL[id])? BTagID_TBL[id]: id
- }
+ BTagID_TBL[id]? BTagID_TBL[id]: id
end
-=begin
def TkBindTag.new_by_name(name, *args, &b)
- BTagID_TBL.mutex.synchronize{
- return BTagID_TBL[name] if BTagID_TBL[name]
- }
-
+ return BTagID_TBL[name] if BTagID_TBL[name]
self.new.instance_eval{
- BTagID_TBL.mutex.synchronize{
- BTagID_TBL.delete @id
- @id = name
- BTagID_TBL[@id] = self
- }
+ BTagID_TBL.delete @id
+ @id = name
+ BTagID_TBL[@id] = self
bind(*args, &b) if args != []
self
}
end
-=end
- def TkBindTag.new_by_name(name, *args, &b)
- obj = nil
- BTagID_TBL.mutex.synchronize{
- if BTagID_TBL[name]
- obj = BTagID_TBL[name]
- else
- (obj = BTagID_TBL[name] = self.allocate).instance_eval{
- @id = name
- }
- end
- }
- bind(*args, &b) if obj && args != []
- obj
- end
def initialize(*args, &b)
- Tk_BINDTAG_ID.mutex.synchronize{
- # @id = Tk_BINDTAG_ID.join('')
- @id = Tk_BINDTAG_ID.join(TkCore::INTERP._ip_id_)
- Tk_BINDTAG_ID[1].succ!
- }
- BTagID_TBL.mutex.synchronize{
- BTagID_TBL[@id] = self
- }
+ # @id = Tk_BINDTAG_ID.join('')
+ @id = Tk_BINDTAG_ID.join(TkCore::INTERP._ip_id_)
+ Tk_BINDTAG_ID[1].succ!
+ BTagID_TBL[@id] = self
bind(*args, &b) if args != []
end
@@ -97,37 +63,14 @@ end
class TkDatabaseClass<TkBindTag
-=begin
def self.new(name, *args, &b)
- BTagID_TBL.mutex.synchronize{
- return BTagID_TBL[name] if BTagID_TBL[name]
- }
+ return BTagID_TBL[name] if BTagID_TBL[name]
super(name, *args, &b)
end
def initialize(name, *args, &b)
@id = name
- BTagID_TBL.mutex.synchronize{
- BTagID_TBL[@id] = self
- }
- bind(*args, &b) if args != []
- end
-=end
- def self.new(name, *args, &b)
- BTagID_TBL.mutex.synchronize{
- if BTagID_TBL[name]
- BTagID_TBL[name]
- else
- BTagID_TBL[name] = self.allocate.instance_eval{
- initialize(name, *args, &b)
- self
- }
- end
- }
- end
-
- def initialize(name, *args, &b)
- @id = name
+ BTagID_TBL[@id] = self
bind(*args, &b) if args != []
end
diff --git a/ext/tk/lib/tk/button.rb b/ext/tk/lib/tk/button.rb
index 770a5785bb..407a47c400 100644
--- a/ext/tk/lib/tk/button.rb
+++ b/ext/tk/lib/tk/button.rb
@@ -4,7 +4,7 @@
require 'tk'
require 'tk/label'
-class Tk::Button<Tk::Label
+class TkButton<TkLabel
TkCommandNames = ['button'.freeze].freeze
WidgetClassName = 'Button'.freeze
WidgetClassNames[WidgetClassName] = self
@@ -25,6 +25,3 @@ class Tk::Button<Tk::Label
self
end
end
-
-#TkButton = Tk::Button unless Object.const_defined? :TkButton
-Tk.__set_toplevel_aliases__(:Tk, Tk::Button, :TkButton)
diff --git a/ext/tk/lib/tk/canvas.rb b/ext/tk/lib/tk/canvas.rb
index 36ea008a17..0f55bff4ed 100644
--- a/ext/tk/lib/tk/canvas.rb
+++ b/ext/tk/lib/tk/canvas.rb
@@ -1,5 +1,6 @@
#
# tk/canvas.rb - Tk canvas classes
+# $Date: 2005/10/24 00:07:00 $
# by Yukihiro Matsumoto <matz@caelum.co.jp>
#
require 'tk'
@@ -39,9 +40,9 @@ module TkCanvasItemConfig
private :__item_pathname
end
-class Tk::Canvas<TkWindow
+class TkCanvas<TkWindow
include TkCanvasItemConfig
- include Tk::Scrollable
+ include Scrollable
TkCommandNames = ['canvas'.freeze].freeze
WidgetClassName = 'Canvas'.freeze
@@ -168,8 +169,6 @@ class Tk::Canvas<TkWindow
#tk_tcl2ruby(tk_send_without_enc('canvasy', screen_y, *args))
number(tk_send_without_enc('canvasy', screen_y, *args))
end
- alias canvas_x canvasx
- alias canvas_y canvasy
def coords(tag, *args)
if args == []
@@ -187,17 +186,11 @@ class Tk::Canvas<TkWindow
end
def delete(*args)
- tbl = nil
- TkcItem::CItemID_TBL.mutex.synchronize{
- tbl = TkcItem::CItemID_TBL[self.path]
- }
- if tbl
+ if TkcItem::CItemID_TBL[self.path]
args.each{|tag|
find('withtag', tag).each{|item|
if item.kind_of?(TkcItem)
- TkcItem::CItemID_TBL.mutex.synchronize{
- tbl.delete(item.id)
- }
+ TkcItem::CItemID_TBL[self.path].delete(item.id)
end
}
}
@@ -550,8 +543,8 @@ class Tk::Canvas<TkWindow
tk_send_without_enc('scan', 'mark', x, y)
self
end
- def scan_dragto(x, y, gain=None)
- tk_send_without_enc('scan', 'dragto', x, y, gain)
+ def scan_dragto(x, y)
+ tk_send_without_enc('scan', 'dragto', x, y)
self
end
@@ -580,10 +573,6 @@ class Tk::Canvas<TkWindow
end
end
-#TkCanvas = Tk::Canvas unless Object.const_defined? :TkCanvas
-Tk.__set_toplevel_aliases__(:Tk, Tk::Canvas, :TkCanvas)
-
-
class TkcItem<TkObject
extend Tk
include TkcTagAccess
@@ -592,12 +581,9 @@ class TkcItem<TkObject
CItemTypeName = nil
CItemTypeToClass = {}
-
CItemID_TBL = TkCore::INTERP.create_table
- TkCore::INTERP.init_ip_env{
- CItemID_TBL.mutex.synchronize{ CItemID_TBL.clear }
- }
+ TkCore::INTERP.init_ip_env{ CItemID_TBL.clear }
def TkcItem.type2class(type)
CItemTypeToClass[type]
@@ -605,13 +591,8 @@ class TkcItem<TkObject
def TkcItem.id2obj(canvas, id)
cpath = canvas.path
- CItemID_TBL.mutex.synchronize{
- if CItemID_TBL[cpath]
- CItemID_TBL[cpath][id]? CItemID_TBL[cpath][id]: id
- else
- id
- end
- }
+ return id unless CItemID_TBL[cpath]
+ CItemID_TBL[cpath][id]? CItemID_TBL[cpath][id]: id
end
########################################
@@ -644,13 +625,6 @@ class TkcItem<TkObject
fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
}
- __item_optkey_aliases(nil).each{|alias_name, real_name|
- alias_name = alias_name.to_s
- if keys.has_key?(alias_name)
- keys[real_name.to_s] = keys.delete(alias_name)
- end
- }
-
__item_methodcall_optkeys(nil).each{|key|
key = key.to_s
methodkeys[key] = keys.delete(key) if keys.key?(key)
@@ -684,17 +658,15 @@ class TkcItem<TkObject
########################################
def initialize(parent, *args)
- #unless parent.kind_of?(Tk::Canvas)
- # fail ArgumentError, "expect Tk::Canvas for 1st argument"
+ #unless parent.kind_of?(TkCanvas)
+ # fail ArgumentError, "expect TkCanvas for 1st argument"
#end
@parent = @c = parent
@path = parent.path
@id = create_self(*args) # an integer number as 'canvas item id'
- CItemID_TBL.mutex.synchronize{
- CItemID_TBL[@path] = {} unless CItemID_TBL[@path]
- CItemID_TBL[@path][@id] = self
- }
+ CItemID_TBL[@path] = {} unless CItemID_TBL[@path]
+ CItemID_TBL[@path][@id] = self
end
def create_self(*args)
self.class.create(@c, *args) # return an integer number as 'canvas item id'
@@ -715,9 +687,7 @@ class TkcItem<TkObject
def delete
@c.delete @id
- CItemID_TBL.mutex.synchronize{
- CItemID_TBL[@path].delete(@id) if CItemID_TBL[@path]
- }
+ CItemID_TBL[@path].delete(@id) if CItemID_TBL[@path]
self
end
alias remove delete
diff --git a/ext/tk/lib/tk/canvastag.rb b/ext/tk/lib/tk/canvastag.rb
index 49796d80b2..a5650ee68b 100644
--- a/ext/tk/lib/tk/canvastag.rb
+++ b/ext/tk/lib/tk/canvastag.rb
@@ -63,9 +63,6 @@ module TkcTagAccess
def cget(option)
@c.itemcget(@id, option)
end
- def cget_strict(option)
- @c.itemcget_strict(@id, option)
- end
def configure(key, value=None)
@c.itemconfigure(@id, key, value)
@@ -202,26 +199,14 @@ class TkcTag<TkObject
include TkcTagAccess
CTagID_TBL = TkCore::INTERP.create_table
+ Tk_CanvasTag_ID = ['ctag'.freeze, '00000'.taint].freeze
- (Tk_CanvasTag_ID = ['ctag'.freeze, '00000'.taint]).instance_eval{
- @mutex = Mutex.new
- def mutex; @mutex; end
- freeze
- }
-
- TkCore::INTERP.init_ip_env{
- CTagID_TBL.mutex.synchronize{ CTagID_TBL.clear }
- }
+ TkCore::INTERP.init_ip_env{ CTagID_TBL.clear }
def TkcTag.id2obj(canvas, id)
cpath = canvas.path
- CTagID_TBL.mutex.synchronize{
- if CTagID_TBL[cpath]
- CTagID_TBL[cpath][id]? CTagID_TBL[cpath][id]: id
- else
- id
- end
- }
+ return id unless CTagID_TBL[cpath]
+ CTagID_TBL[cpath][id]? CTagID_TBL[cpath][id]: id
end
def initialize(parent, mode=nil, *args)
@@ -230,15 +215,11 @@ class TkcTag<TkObject
#end
@c = parent
@cpath = parent.path
- Tk_CanvasTag_ID.mutex.synchronize{
- # @path = @id = Tk_CanvasTag_ID.join('')
- @path = @id = Tk_CanvasTag_ID.join(TkCore::INTERP._ip_id_)
- Tk_CanvasTag_ID[1].succ!
- }
- CTagID_TBL.mutex.synchronize{
- CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath]
- CTagID_TBL[@cpath][@id] = self
- }
+ # @path = @id = Tk_CanvasTag_ID.join('')
+ @path = @id = Tk_CanvasTag_ID.join(TkCore::INTERP._ip_id_)
+ CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath]
+ CTagID_TBL[@cpath][@id] = self
+ Tk_CanvasTag_ID[1].succ!
if mode
tk_call_without_enc(@c.path, "addtag", @id, mode, *args)
end
@@ -257,9 +238,7 @@ class TkcTag<TkObject
def delete
@c.delete @id
- CTagID_TBL.mutex.synchronize{
- CTagID_TBL[@cpath].delete(@id) if CTagID_TBL[@cpath]
- }
+ CTagID_TBL[@cpath].delete(@id) if CTagID_TBL[@cpath]
self
end
alias remove delete
@@ -309,38 +288,23 @@ class TkcTag<TkObject
end
class TkcTagString<TkcTag
- def self.new(parent, name, mode=nil, *args)
- obj = nil
- CTagID_TBL.mutex.synchronize{
- if CTagID_TBL[parent.path] && CTagID_TBL[parent.path][name]
- obj = CTagID_TBL[parent.path][name]
- else
- # super(parent, name, *args)
- (obj = self.allocate).instance_eval{
- @c = parent
- @cpath = parent.path
- @path = @id = name
- CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath]
- CTagID_TBL[@cpath][@id] = self
- }
- end
- }
- if obj && mode
- tk_call_without_enc(@c.path, "addtag", @id, mode, *args)
+ def self.new(parent, name, *args)
+ if CTagID_TBL[parent.path] && CTagID_TBL[parent.path][name]
+ return CTagID_TBL[parent.path][name]
+ else
+ super(parent, name, *args)
end
- obj
end
def initialize(parent, name, mode=nil, *args)
- # dummy:: not called by 'new' method
-
#unless parent.kind_of?(TkCanvas)
# fail ArgumentError, "expect TkCanvas for 1st argument"
#end
@c = parent
@cpath = parent.path
@path = @id = name
-
+ CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath]
+ CTagID_TBL[@cpath][@id] = self
if mode
tk_call_without_enc(@c.path, "addtag", @id, mode, *args)
end
@@ -348,11 +312,7 @@ class TkcTagString<TkcTag
end
TkcNamedTag = TkcTagString
-class TkcTagAll<TkcTagString
- def self.new(parent)
- super(parent, 'all')
- end
-=begin
+class TkcTagAll<TkcTag
def initialize(parent)
#unless parent.kind_of?(TkCanvas)
# fail ArgumentError, "expect TkCanvas for 1st argument"
@@ -360,19 +320,12 @@ class TkcTagAll<TkcTagString
@c = parent
@cpath = parent.path
@path = @id = 'all'
- CTagID_TBL.mutex.synchronize{
- CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath]
- CTagID_TBL[@cpath][@id] = self
- }
+ CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath]
+ CTagID_TBL[@cpath][@id] = self
end
-=end
end
-class TkcTagCurrent<TkcTagString
- def self.new(parent)
- super(parent, 'current')
- end
-=begin
+class TkcTagCurrent<TkcTag
def initialize(parent)
#unless parent.kind_of?(TkCanvas)
# fail ArgumentError, "expect TkCanvas for 1st argument"
@@ -380,21 +333,13 @@ class TkcTagCurrent<TkcTagString
@c = parent
@cpath = parent.path
@path = @id = 'current'
- CTagID_TBL.mutex.synchronize{
- CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath]
- CTagID_TBL[@cpath][@id] = self
- }
+ CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath]
+ CTagID_TBL[@cpath][@id] = self
end
-=end
end
class TkcGroup<TkcTag
- (Tk_cGroup_ID = ['tkcg'.freeze, '00000'.taint]).instance_eval{
- @mutex = Mutex.new
- def mutex; @mutex; end
- freeze
- }
-
+ Tk_cGroup_ID = ['tkcg'.freeze, '00000'.taint].freeze
#def create_self(parent, *args)
def initialize(parent, *args)
#unless parent.kind_of?(TkCanvas)
@@ -402,15 +347,11 @@ class TkcGroup<TkcTag
#end
@c = parent
@cpath = parent.path
- Tk_cGroup_ID.mutex.synchronize{
- # @path = @id = Tk_cGroup_ID.join('')
- @path = @id = Tk_cGroup_ID.join(TkCore::INTERP._ip_id_)
- Tk_cGroup_ID[1].succ!
- }
- CTagID_TBL.mutex.synchronize{
- CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath]
- CTagID_TBL[@cpath][@id] = self
- }
+ # @path = @id = Tk_cGroup_ID.join('')
+ @path = @id = Tk_cGroup_ID.join(TkCore::INTERP._ip_id_)
+ CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath]
+ CTagID_TBL[@cpath][@id] = self
+ Tk_cGroup_ID[1].succ!
include(*args) if args != []
end
#private :create_self
diff --git a/ext/tk/lib/tk/checkbutton.rb b/ext/tk/lib/tk/checkbutton.rb
index b1186a87ed..d76d99c0f2 100644
--- a/ext/tk/lib/tk/checkbutton.rb
+++ b/ext/tk/lib/tk/checkbutton.rb
@@ -4,7 +4,7 @@
require 'tk'
require 'tk/radiobutton'
-class Tk::CheckButton<Tk::RadioButton
+class TkCheckButton<TkRadioButton
TkCommandNames = ['checkbutton'.freeze].freeze
WidgetClassName = 'Checkbutton'.freeze
WidgetClassNames[WidgetClassName] = self
@@ -22,9 +22,4 @@ class Tk::CheckButton<Tk::RadioButton
self
end
end
-
-Tk::Checkbutton = Tk::CheckButton
-#TkCheckButton = Tk::CheckButton unless Object.const_defined? :TkCheckButton
-#TkCheckbutton = Tk::Checkbutton unless Object.const_defined? :TkCheckbutton
-Tk.__set_toplevel_aliases__(:Tk, Tk::CheckButton,
- :TkCheckButton, :TkCheckbutton)
+TkCheckbutton = TkCheckButton
diff --git a/ext/tk/lib/tk/composite.rb b/ext/tk/lib/tk/composite.rb
index 883d43c3ea..eaed8ed363 100644
--- a/ext/tk/lib/tk/composite.rb
+++ b/ext/tk/lib/tk/composite.rb
@@ -34,8 +34,7 @@ module TkComposite
if klass
# WidgetClassName is a known class
- #if klass <= TkFrame || klass < TkComposite
- if klass <= TkFrame || klass < Tk::Frame || klass < TkComposite
+ if klass <= TkFrame || klass < TkComposite
# klass is valid for the base frame
if self.class <= klass
# use my classname
@@ -51,8 +50,7 @@ module TkComposite
else
# klass is invalid for the base frame
- #if self.class < TkFrame || self.class.superclass < TkComposite
- if self.class < TkFrame || self.class.superclass < Tk::Frame || self.class.superclass < TkComposite
+ if self.class < TkFrame || self.class.superclass < TkComposite
# my class name is valid for the base frame -> use my classname
base_class_name = self.class.name
if base_class_name == ''
@@ -71,8 +69,7 @@ module TkComposite
else
# no valid WidgetClassName
- #if self.class < TkFrame || self.class.superclass < TkComposite
- if self.class < TkFrame || self.class.superclass < Tk::Frame || self.class.superclass < TkComposite
+ if self.class < TkFrame || self.class.superclass < TkComposite
# my class name is valid for the base frame -> use my classname
base_class_name = self.class.name
if base_class_name == ''
@@ -111,12 +108,8 @@ module TkComposite
end
if base_class_name
- # @frame = Tk::Frame.new(parent, :class=>base_class_name)
- # --> use current TkFrame class
@frame = TkFrame.new(parent, :class=>base_class_name)
else
- # @frame = Tk::Frame.new(parent)
- # --> use current TkFrame class
@frame = TkFrame.new(parent)
end
@path = @epath = @frame.path
@@ -140,11 +133,6 @@ module TkComposite
def initialize_composite(*args) end
private :initialize_composite
- def inspect
- str = super
- str.chop << ' @epath=' << @epath.inspect << '>'
- end
-
def option_methods(*opts)
opts.each{|m_set, m_cget, m_info|
m_set = m_set.to_s
@@ -181,57 +169,6 @@ module TkComposite
delegate_alias(option, option, *wins)
end
- def __cget_delegates(slot)
- slot = slot.to_s
-
- if @option_methods.include?(slot)
- if @option_methods[slot][:cget]
- return self.__send__(@option_methods[slot][:cget])
- else
- if @option_setting[slot]
- return @option_setting[slot]
- else
- return ''
- end
- end
- end
-
- tbl = @delegates[slot]
- tbl = @delegates['DEFAULT'] unless tbl
-
- begin
- if tbl
- opt, wins = tbl[-1]
- opt = slot if opt == 'DEFAULT'
- if wins && wins[-1]
- # return wins[-1].cget(opt)
- return wins[-1].cget_strict(opt)
- end
- end
- rescue
- end
-
- return None
- end
- private :__cget_delegates
-
- def cget(slot)
- if (ret = __cget_delegates(slot)) == None
- super(slot)
- else
- ret
- end
- end
-
- def cget_strict(slot)
- if (ret = __cget_delegates(slot)) == None
- super(slot)
- else
- ret
- end
- end
-
-=begin
def cget(slot)
slot = slot.to_s
@@ -263,7 +200,6 @@ module TkComposite
super(slot)
end
-=end
def configure(slot, value=None)
if slot.kind_of? Hash
diff --git a/ext/tk/lib/tk/encodedstr.rb b/ext/tk/lib/tk/encodedstr.rb
index 02de0b0d85..797e514a4c 100644
--- a/ext/tk/lib/tk/encodedstr.rb
+++ b/ext/tk/lib/tk/encodedstr.rb
@@ -70,89 +70,13 @@ module Tk
# @encoding = ( enc ||
# ((self.class::Encoding)?
# self.class::Encoding : Tk.encoding_system) )
- enc ||= (self.class::Encoding)?
+ @encoding = ( enc ||
+ ((self.class::Encoding)?
self.class::Encoding :
- ((Tk.encoding)? Tk.encoding : Tk.encoding_system)
- if TkCore::WITH_ENCODING
- unless encobj = Tk::Encoding::ENCODING_TABLE.get_obj(enc)
- fail ArgumentError, "unsupported Tk encoding '#{enc}'"
- end
- self.force_encoding(encobj)
- else
- @encoding = enc
- end
- end
-
- if TkCore::WITH_ENCODING
- alias encoding_obj encoding
- alias __encoding encoding
- def encoding
- Tk::Encoding::ENCODING_TABLE.get_name(super())
- end
- else
- def encoding
- @encoding
- end
- alias encoding_obj encoding
+ ((Tk.encoding)? Tk.encoding : Tk.encoding_system) ) )
end
- if TkCore::WITH_ENCODING
- # wrapper methods for compatibility
- alias __instance_variable_get instance_variable_get
- alias __instance_variable_set instance_variable_set
- alias __instance_eval instance_eval
- alias __instance_variables instance_variables
-
- def instance_variable_get(key)
- if (key.to_s == '@encoding')
- self.encoding
- else
- super(key)
- end
- end
-
- def instance_variable_set(key, value)
- if (key.to_s == '@encoding')
- if value
- self.force_encoding(value)
- else
- self.force_encoding(Tk::Encoding::UNKNOWN)
- end
- value
- else
- super(key, value)
- end
- end
-
- def instance_eval(*args, &b)
- old_enc = @encoding = self.encoding
-
- ret = super(*args, &b)
-
- if @encoding
- if @encoding != old_enc
- # modified by user
- self.force_encoding(@encoding)
- end
- remove_instance_variable(:@encoding)
- else
- begin
- remove_instance_variable(:@encoding)
- # user sets to nil -> use current default
- self.force_encoding(Tk.encoding)
- rescue NameError
- # removed by user -> ignore, because user don't use @encoding
- end
- end
- ret
- end
- end
-
- def instance_variables
- ret = super()
- ret << :@encoding # fake !!
- ret
- end
+ attr_reader :encoding
end
# def Tk.EncodedString(str, enc = nil)
# Tk::EncodedString.new(str, enc)
diff --git a/ext/tk/lib/tk/entry.rb b/ext/tk/lib/tk/entry.rb
index 8ce8def1e7..e4d69eb7bf 100644
--- a/ext/tk/lib/tk/entry.rb
+++ b/ext/tk/lib/tk/entry.rb
@@ -1,5 +1,6 @@
#
# tk/entry.rb - Tk entry classes
+# $Date: 2005/10/22 22:16:24 $
# by Yukihiro Matsumoto <matz@caelum.co.jp>
require 'tk'
@@ -7,7 +8,7 @@ require 'tk/label'
require 'tk/scrollable'
require 'tk/validation'
-class Tk::Entry<Tk::Label
+class TkEntry<TkLabel
include X_Scrollable
include TkValidation
@@ -114,6 +115,3 @@ class Tk::Entry<Tk::Label
val
end
end
-
-#TkEntry = Tk::Entry unless Object.const_defined? :TkEntry
-Tk.__set_toplevel_aliases__(:Tk, Tk::Entry, :TkEntry)
diff --git a/ext/tk/lib/tk/event.rb b/ext/tk/lib/tk/event.rb
index d8aad6248b..70a1e38bbe 100644
--- a/ext/tk/lib/tk/event.rb
+++ b/ext/tk/lib/tk/event.rb
@@ -39,9 +39,7 @@ module TkEvent
RESIZEREQ = 0x200000
CIRCREQ = 0x400000
- MWHEEL = KEY
-
- STRING_DATA = 0x80000000 # special flag for 'data' field
+ MWHEEL = 0x10000000
ALL = 0xFFFFFFFF
@@ -157,7 +155,7 @@ module TkEvent
'borderwidth' => (Grp::CREATE|Grp::CONFIG),
'button' => Grp::BUTTON,
'count' => Grp::EXPOSE,
- 'data' => (Grp::VIRTUAL|Grp::STRING_DATA),
+ 'data' => Grp::VIRTUAL,
'delta' => Grp::MWHEEL,
'detail' => (Grp::FOCUS|Grp::CROSSING),
'focus' => Grp::CROSSING,
@@ -225,8 +223,7 @@ module TkEvent
rescue
next
end
- # next if !val || val == '??'
- next if !val || (val == '??' && (flag & Grp::STRING_DATA))
+ next if !val || val == '??'
fields[key] = val
}
@@ -301,65 +298,34 @@ module TkEvent
[ ?b, ?n, :num ],
[ ?c, ?n, :count ],
[ ?d, ?s, :detail ],
- # ?e
[ ?f, ?b, :focus ],
- # ?g
[ ?h, ?n, :height ],
[ ?i, ?s, :win_hex ],
- # ?j
[ ?k, ?n, :keycode ],
- # ?l
[ ?m, ?s, :mode ],
- # ?n
[ ?o, ?b, :override ],
[ ?p, ?s, :place ],
- # ?q
- # ?r
[ ?s, ?x, :state ],
[ ?t, ?n, :time ],
- # ?u
- [ ?v, ?n, :value_mask ],
[ ?w, ?n, :width ],
[ ?x, ?n, :x ],
[ ?y, ?n, :y ],
- # ?z
[ ?A, ?s, :char ],
[ ?B, ?n, :borderwidth ],
- # ?C
[ ?D, ?n, :wheel_delta ],
[ ?E, ?b, :send_event ],
- # ?F
- # ?G
- # ?H
- # ?I
- # ?J
[ ?K, ?s, :keysym ],
- # ?L
- # ?M
[ ?N, ?n, :keysym_num ],
- # ?O
[ ?P, ?s, :property ],
- # ?Q
[ ?R, ?s, :rootwin_id ],
[ ?S, ?s, :subwindow ],
[ ?T, ?n, :type ],
- # ?U
- # ?V
[ ?W, ?w, :widget ],
[ ?X, ?n, :x_root ],
[ ?Y, ?n, :y_root ],
- # ?Z
nil
]
- # [ <'%' subst-key str>, <proc type char>, <instance var (accessor) name>]
- # the subst-key string will be converted to a bytecode (128+idx).
- LONGKEY_TBL = [
- # for example, for %CTT and %CST subst-key on tkdnd-2.0
- # ['CTT', ?l, :drop_target_type],
- # ['CST', ?l, :drop_source_type],
- ]
-
# [ <proc type char>, <proc/method to convert tcl-str to ruby-obj>]
PROC_TBL = [
[ ?n, TkComm.method(:num_or_str) ],
@@ -379,24 +345,6 @@ module TkEvent
nil
]
-=begin
- # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
- KEY_TBL.map!{|inf|
- if inf.kind_of?(Array)
- inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
- inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
- end
- inf
- }
-
- PROC_TBL.map!{|inf|
- if inf.kind_of?(Array)
- inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
- end
- inf
- }
-=end
-
# setup tables to be used by scan_args, _get_subst_key, _get_all_subst_keys
#
# _get_subst_key() and _get_all_subst_keys() generates key-string
@@ -409,8 +357,7 @@ module TkEvent
# ( which are Tcl strings ) to ruby objects based on the key string
# that is generated by _get_subst_key() or _get_all_subst_keys().
#
- _setup_subst_table(KEY_TBL, PROC_TBL)
- # _setup_subst_table(KEY_TBL, LONGKEY_TBL, PROC_TBL) # if use longname-keys
+ _setup_subst_table(KEY_TBL, PROC_TBL);
#
# NOTE: The order of parameters which passed to callback procedure is
@@ -458,7 +405,6 @@ module TkEvent
extra_args_tbl = klass._get_extra_args_tbl
if args.compact.size > 0
- args.map!{|arg| klass._sym2subst(arg)}
args = args.join(' ')
keys = klass._get_subst_key(args)
diff --git a/ext/tk/lib/tk/font.rb b/ext/tk/lib/tk/font.rb
index 62d628c132..de02d4957c 100644
--- a/ext/tk/lib/tk/font.rb
+++ b/ext/tk/lib/tk/font.rb
@@ -11,18 +11,13 @@ class TkFont
TkCommandNames = ['font'.freeze].freeze
- (Tk_FontID = ["@font".freeze, "00000".taint]).instance_eval{
- @mutex = Mutex.new
- def mutex; @mutex; end
- freeze
- }
-
+ Tk_FontID = ["@font".freeze, "00000".taint].freeze
Tk_FontNameTBL = TkCore::INTERP.create_table
Tk_FontUseTBL = TkCore::INTERP.create_table
TkCore::INTERP.init_ip_env{
- Tk_FontNameTBL.mutex.synchronize{ Tk_FontNameTBL.clear }
- Tk_FontUseTBL.mutex.synchronize{ Tk_FontUseTBL.clear }
+ Tk_FontNameTBL.clear
+ Tk_FontUseTBL.clear
}
# option_type : default => string
@@ -36,26 +31,13 @@ class TkFont
MetricType = Hash.new(?n)
MetricType['fixed'] = ?b
- # system font names
- SYSTEM_FONT_NAMES = []
- def SYSTEM_FONT_NAMES.add(font_names)
- (@mutex ||= Mutex.new).synchronize{
- self.replace(self | font_names.map{|name| name.to_s})
- }
- end
- def SYSTEM_FONT_NAMES.include?(name)
- (@mutex ||= Mutex.new).synchronize{
- super(name.to_s)
- }
- end
-
# set default font
case Tk::TK_VERSION
- when /^4\..*/
+ when /^4\.*/
DEFAULT_LATIN_FONT_NAME = 'a14'.freeze
DEFAULT_KANJI_FONT_NAME = 'k14'.freeze
- when /^8\.[0-4]/
+ when /^8\.*/
if JAPANIZED_TK
begin
fontnames = tk_call('font', 'names')
@@ -121,15 +103,6 @@ class TkFont
DEFAULT_LATIN_FONT_NAME = ltn.freeze
DEFAULT_KANJI_FONT_NAME = knj.freeze
- when /^8\.[5-9]/, /^9\..*/
- if tk_call('font', 'names') =~ /\bTkDefaultFont\b/
- DEFAULT_LATIN_FONT_NAME = 'TkDefaultFont'.freeze
- DEFAULT_KANJI_FONT_NAME = 'TkDefaultFont'.freeze
- else
- DEFAULT_LATIN_FONT_NAME = 'Helvetica'.freeze
- DEFAULT_KANJI_FONT_NAME = 'mincho'.freeze
- end
-
else # unknown version
DEFAULT_LATIN_FONT_NAME = 'Helvetica'.freeze
DEFAULT_KANJI_FONT_NAME = 'mincho'.freeze
@@ -148,7 +121,6 @@ class TkFont
unless compound.kind_of?(TkFont)
fail ArgumentError, "a TkFont object is expected for the 1st argument"
end
-
@compound = compound
case type
when 'kanji', 'latin', 'ascii'
@@ -173,9 +145,6 @@ class TkFont
def font
@compound.__send__(@type + '_font_id')
end
- alias font_id font
- alias name font
- alias to_s font
def [](slot)
@compound.__send__(@type + '_configinfo', slot)
@@ -194,14 +163,6 @@ class TkFont
###################################
# class methods
###################################
- def TkFont.is_system_font?(fnt)
- # true --> system font which is available on the current system
- # false --> not system font (or unknown system font)
- # nil --> system font name, but not available on the current system
- fnt = fnt.to_s
- SYSTEM_FONT_NAMES.include?(fnt) && self.names.index(fnt) && true
- end
-
def TkFont.actual(fnt, option=nil)
fnt = '{}' if fnt == ''
if fnt.kind_of?(TkFont)
@@ -210,9 +171,6 @@ class TkFont
actual_core(fnt, nil, option)
end
end
- def TkFont.actual_hash(fnt, option=nil)
- Hash[TkFont.actual_hash(fnt, option)]
- end
def TkFont.actual_displayof(fnt, win, option=nil)
fnt = '{}' if fnt == ''
@@ -223,9 +181,6 @@ class TkFont
actual_core(fnt, win, option)
end
end
- def TkFont.actual_hash_displayof(fnt, option=nil)
- Hash[TkFont.actual_hash_displayof(fnt, option)]
- end
def TkFont.configure(fnt, slot, value=None)
if fnt.kind_of?(TkFont)
@@ -279,33 +234,6 @@ class TkFont
metrics_core(fnt, nil, option)
end
end
- def TkFont.metrics_hash(fnt, option=nil)
- if option
- val = TkFont.metrics(fnt, option)
- case TkFont::MetricsType[option.to_s]
- when ?n
- val = TkComm::num_or_str(val)
- when ?b
- val = TkComm::bool(val)
- else
- # do nothing
- end
- return val
- end
-
- h = Hash[TkFont.metrics(fnt)]
- h.keys.each{|k|
- case TkFont::MetricsType[k.to_s]
- when ?n
- h[k] = TkComm::num_or_str(h[k])
- when ?b
- h[k] = TkComm::bool(h[k])
- else
- # do nothing
- end
- }
- h
- end
def TkFont.metrics_displayof(fnt, win, option=nil)
fnt = '{}' if fnt == ''
@@ -316,40 +244,13 @@ class TkFont
metrics_core(fnt, win, option)
end
end
- def TkFont.metrics_hash_displayof(fnt, win, option=nil)
- if option
- val = TkFont.metrics_displayof(fnt, win, option)
- case TkFont::MetricsType[option.to_s]
- when ?n
- val = TkComm::num_or_str(val)
- when ?b
- val = TkComm::bool(val)
- else
- # do nothing
- end
- return val
- end
-
- h = Hash[TkFont.metrics_displayof(fnt, win, option)]
- h.keys.each{|k|
- case TkFont::MetricsType[k.to_s]
- when ?n
- h[k] = TkComm::num_or_str(h[k])
- when ?b
- h[k] = TkComm::bool(h[k])
- else
- # do nothing
- end
- }
- h
- end
def TkFont.families(win=nil)
case (Tk::TK_VERSION)
- when /^4\..*/
+ when /^4\.*/
['fixed']
- when /^8\..*/
+ when /^8\.*/
if win
tk_split_simplelist(tk_call('font', 'families', '-displayof', win))
else
@@ -360,16 +261,13 @@ class TkFont
def TkFont.names
case (Tk::TK_VERSION)
- when /^4\..*/
+ when /^4\.*/
r = ['fixed']
r += ['a14', 'k14'] if JAPANIZED_TK
- Tk_FontNameTBL.mutex.synchronize{
- Tk_FontNameTBL.each_value{|obj| r.push(obj)}
- }
- #r | []
- r.uniq
+ Tk_FontNameTBL.each_value{|obj| r.push(obj)}
+ r | []
- when /^8\..*/
+ when /^8\.*/
tk_split_simplelist(tk_call('font', 'names'))
end
@@ -387,15 +285,10 @@ class TkFont
end
def TkFont.get_obj(name)
- name = name.to_s
if name =~ /^(@font[0-9]+)(|c|l|k)$/
- Tk_FontNameTBL.mutex.synchronize{
- Tk_FontNameTBL[$1]
- }
+ Tk_FontNameTBL[$1]
else
- Tk_FontNameTBL.mutex.synchronize{
- Tk_FontNameTBL[name]
- }
+ nil
end
end
@@ -405,7 +298,7 @@ class TkFont
path = [win, tag, key].join(';')
case (Tk::TK_VERSION)
- when /^4\..*/
+ when /^4\.*/
regexp = /^-(|kanji)#{key} /
conf_list = tk_split_simplelist(tk_call(*args)).
@@ -431,7 +324,7 @@ class TkFont
TkFont.new(ltn, knj).call_font_configure([path, key], *args)
- when /^8\.[0-4]/
+ when /^8\.*/
regexp = /^-#{key} /
conf_list = tk_split_simplelist(tk_call(*args)).
@@ -467,66 +360,26 @@ class TkFont
compound = []
end
if compound == []
- if TkFont.is_system_font?(fnt)
- TkNamedFont.new(fnt).call_font_configure([path, key], *args)
- else
- TkFont.new(fnt).call_font_configure([path, key], *args)
- end
+ TkFont.new(fnt).call_font_configure([path, key], *args)
else
TkFont.new(compound[0],
compound[1]).call_font_configure([path, key], *args)
end
end
-
- when /^8\.[5-9]/, /^9\..*/
- regexp = /^-#{key} /
-
- conf_list = tk_split_simplelist(tk_call(*args)).
- find_all{|prop| prop =~ regexp}.
- collect{|prop| tk_split_simplelist(prop)}
-
- if conf_list.size == 0
- raise RuntimeError, "the widget may not support 'font' option"
- end
-
- args << {}
-
- optkey = "-#{key}"
-
- info = conf_list.find{|conf| conf[0] == optkey}
- fnt = info[-1]
- fnt = nil if fnt == [] || fnt == ""
-
- unless fnt
- # create dummy
- # TkFont.new(nil, nil).call_font_configure([path, key], *args)
- dummy_fnt = TkFont.allocate
- dummy_fnt.instance_eval{ init_dummy_fontobj() }
- dummy_fnt
- else
- if TkFont.is_system_font?(fnt)
- TkNamedFont.new(fnt).call_font_configure([path, key], *args)
- else
- TkFont.new(fnt).call_font_configure([path, key], *args)
- end
- end
end
end
def TkFont.used_on(path=nil)
- Tk_FontUseTBL.mutex.synchronize{
- if path
- Tk_FontUseTBL[path]
- else
- # Tk_FontUseTBL.values | []
- Tk_FontUseTBL.values.uniq
- end
- }
+ if path
+ Tk_FontUseTBL[path]
+ else
+ Tk_FontUseTBL.values | []
+ end
end
def TkFont.failsafe(font)
begin
- if /^8\..*/ === Tk::TK_VERSION && JAPANIZED_TK
+ if /^8\.*/ === Tk::TK_VERSION && JAPANIZED_TK
tk_call('font', 'failsafe', font)
end
rescue
@@ -539,20 +392,15 @@ class TkFont
private
###################################
def init_dummy_fontobj
- Tk_FontID.mutex.synchronize{
- @id = Tk_FontID.join(TkCore::INTERP._ip_id_)
- Tk_FontID[1].succ!
- }
- Tk_FontNameTBL.mutex.synchronize{
- Tk_FontNameTBL[@id] = self
- }
+ @id = Tk_FontID.join(TkCore::INTERP._ip_id_)
+ Tk_FontID[1].succ!
+ Tk_FontNameTBL[@id] = self
- # @latin_desscendant = nil
- # @kanji_desscendant = nil
- @descendant = [nil, nil] # [latin, kanji]
+ @latin_desscendant = nil
+ @kanji_desscendant = nil
case (Tk::TK_VERSION)
- when /^4\..*/
+ when /^4\.*/
@latinfont = ""
@kanjifont = ""
if JAPANIZED_TK
@@ -588,23 +436,13 @@ class TkFont
ltn = '{}' if ltn == ''
knj = '{}' if knj == ''
- Tk_FontID.mutex.synchronize{
- # @id = Tk_FontID.join('')
- @id = Tk_FontID.join(TkCore::INTERP._ip_id_)
- Tk_FontID[1].succ!
- }
- Tk_FontNameTBL.mutex.synchronize{
- Tk_FontNameTBL[@id] = self
- }
-
- # @latin_desscendant = nil
- # @kanji_desscendant = nil
- @descendant = [nil, nil] # [latin, kanji]
+ # @id = Tk_FontID.join('')
+ @id = Tk_FontID.join(TkCore::INTERP._ip_id_)
+ Tk_FontID[1].succ!
+ Tk_FontNameTBL[@id] = self
- # @latinfont = @id + 'l'
- # @kanjifont = @id + 'k'
- # @compoundfont = @id + 'c'
- # @fontslot = {}
+ @latin_desscendant = nil
+ @kanji_desscendant = nil
if knj.kind_of?(Hash) && !keys
keys = knj
@@ -636,7 +474,7 @@ class TkFont
if ltn
if JAPANIZED_TK && !knj
- if Tk::TK_VERSION =~ /^4..*/
+ if Tk::TK_VERSION =~ /^4.*/
knj = DEFAULT_KANJI_FONT_NAME
else
knj = ltn
@@ -787,14 +625,9 @@ class TkFont
if JAPANIZED_TK
@compoundfont = [[@latinfont], [@kanjifont]]
@fontslot = {'font'=>@latinfont, 'kanjifont'=>@kanjifont}
- # @fontslot.clear
- # @fontslot['font'] = @latinfont
- # @fontslot['kanjifont'] = @kanjifont
else
@compoundfont = @latinfont
@fontslot = {'font'=>@latinfont}
- # @fontslot.clear
- # @fontslot['font'] = @latinfont
end
end
@@ -920,7 +753,6 @@ class TkFont
end
@fontslot = {'font'=>@compoundfont}
- # @fontslot['font'] = @compoundfont
begin
tk_call('font', 'create', @compoundfont,
'-compound', [@latinfont, @kanjifont], *hash_kv(keys))
@@ -1001,7 +833,6 @@ class TkFont
end
@fontslot = {'font'=>@compoundfont}
- # @fontslot['font'] = @compoundfont
tk_call('font', 'configure', @compoundfont, *hash_kv(keys))
end
end
@@ -1056,39 +887,25 @@ class TkFont
keys = _symbolkey2str(args.pop).update(fontslot)
args.concat(hash_kv(keys))
- begin
- tk_call(*args)
- rescue => e
- unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
- fail e
- end
- end
- Tk_FontUseTBL.mutex.synchronize{
- Tk_FontUseTBL[[win, tag, optkey].join(';')] = self
- }
+ tk_call(*args)
+ Tk_FontUseTBL[[win, tag, optkey].join(';')] = self
self
end
def used
ret = []
- table = nil
- Tk_FontUseTBL.mutex.synchronize{
- table = Tk_FontUseTBL.clone # to avoid deadlock
- }
- table.each{|key,value|
+ Tk_FontUseTBL.each{|key,value|
next unless self == value
if key.include?(';')
win, tag, optkey = key.split(';')
winobj = tk_tcl2ruby(win)
- #if winobj.kind_of? TkText
- if winobj.kind_of?(TkText) || winobj.kind_of?(Tk::Text)
+ if winobj.kind_of? TkText
if optkey
ret.push([winobj, winobj.tagid2obj(tag), optkey])
else
ret.push([winobj, winobj.tagid2obj(tag)])
end
- #elsif winobj.kind_of? TkCanvas
- elsif winobj.kind_of?(TkCanvas) || winobj.kind_of?(Tk::Canvas)
+ elsif winobj.kind_of? TkCanvas
if (tagobj = TkcTag.id2obj(winobj, tag)).kind_of? TkcTag
if optkey
ret.push([winobj, tagobj, optkey])
@@ -1108,8 +925,7 @@ class TkFont
ret.push([winobj, tag])
end
end
- #elsif winobj.kind_of? TkMenu
- elsif winobj.kind_of?(TkMenu) || winobj.kind_of?(Tk::Menu)
+ elsif winobj.kind_of? TkMenu
if optkey
ret.push([winobj, tag, optkey])
else
@@ -1141,8 +957,6 @@ class TkFont
@compoundfont
end
alias font_id font
- alias name font
- alias to_s font
def latin_font_id
@latinfont
@@ -1150,18 +964,11 @@ class TkFont
def latin_font
# @latinfont
- if @descendant[0] # [0] -> latin
- @descendant[0]
- else
- @descendant[0] = DescendantFont.new(self, 'latin')
- end
-=begin
if @latin_descendant
@latin_descendant
else
@latin_descendant = DescendantFont.new(self, 'latin')
end
-=end
end
alias latinfont latin_font
@@ -1171,87 +978,50 @@ class TkFont
def kanji_font
# @kanjifont
- if @descendant[1] # [1] -> kanji
- @descendant[1]
- else
- @descendant[1] = DescendantFont.new(self, 'kanji')
- end
-=begin
if @kanji_descendant
@kanji_descendant
else
@kanji_descendant = DescendantFont.new(self, 'kanji')
end
-=end
end
alias kanjifont kanji_font
def actual(option=nil)
actual_core(@compoundfont, nil, option)
end
- def actual_hash(option=nil)
- Hash[actual(option)]
- end
def actual_displayof(win, option=nil)
win = '.' unless win
actual_core(@compoundfont, win, option)
end
- def actual_hash_displayof(win, option=nil)
- Hash[actual_displayof(win, option)]
- end
def latin_actual(option=nil)
- if @latinfont == nil
- actual_core(@compoundfont, nil, option) # use @compoundfont
- else
- actual_core(@latinfont, nil, option)
- end
- end
- def latin_actual_hash(option=nil)
- Hash[latin_actual(option)]
+ actual_core(@latinfont, nil, option)
end
def latin_actual_displayof(win, option=nil)
win = '.' unless win
- if @latinfont == nil
- actual_core(@compoundfont, win, option) # use @compoundfont
- else
- actual_core(@latinfont, win, option)
- end
- end
- def latin_actual_hash_displayof(win, option=nil)
- Hash[latin_actual_displayof(win, option)]
+ actual_core(@latinfont, win, option)
end
def kanji_actual(option=nil)
#if JAPANIZED_TK
- if @kanjifont == nil
- actual_core(@compoundfont, nil, option) # use @compoundfont
- elsif @kanjifont != ""
+ if @kanjifont != ""
actual_core(@kanjifont, nil, option)
else
actual_core_tk4x(nil, nil, option)
end
end
- def kanji_actual_hash(option=nil)
- Hash[kanji_actual(option)]
- end
def kanji_actual_displayof(win, option=nil)
#if JAPANIZED_TK
- if @kanjifont == nil
- actual_core(@compoundfont, nil, option) # use @compoundfont
- elsif @kanjifont != ""
+ if @kanjifont != ""
win = '.' unless win
actual_core(@kanjifont, win, option)
else
actual_core_tk4x(nil, win, option)
end
end
- def kanji_actual_hash_displayof(win, option=nil)
- Hash[kanji_actual_displayof(win, option)]
- end
def [](slot)
configinfo slot
@@ -1295,15 +1065,10 @@ class TkFont
configinfo(slot)
end
end
- def latin_current_configinfo(slot=nil)
- Hash[latin_configinfo(slot)]
- end
def kanji_configure(slot, value=None)
#if JAPANIZED_TK
- if @kanjifont == nil
- configure_core(@compoundfont, slot, value) # use @compoundfont
- elsif @kanjifont != ""
+ if @kanjifont != ""
configure_core(@kanjifont, slot, value)
configure('size'=>configinfo('size')) # to reflect new configuration
else
@@ -1315,18 +1080,13 @@ class TkFont
def kanji_configinfo(slot=nil)
#if JAPANIZED_TK
- if @kanjifont == nil
- configure_core(@compoundfont, slot) # use @compoundfont
- elsif @kanjifont != ""
+ if @kanjifont != ""
configinfo_core(@kanjifont, slot)
else
#[]
configinfo(slot)
end
end
- def kanji_current_configinfo(slot=nil)
- Hash[kanji_configinfo(slot)]
- end
def replace(ltn, knj=None)
knj = ltn if knj == None
@@ -1336,30 +1096,12 @@ class TkFont
end
def latin_replace(ltn)
- if @latinfont
- latin_replace_core(ltn)
- reset_pointadjust
- else
- # not compound font -> copy properties of ltn
- latinkeys = {}
- begin
- actual_core(ltn).each{|key,val| latinkeys[key] = val}
- rescue
- latinkeys = {}
- end
- begin
- tk_call('font', 'configure', @compoundfont, *hash_kv(latinkeys))
- rescue
- # not exist? (deleted?) -> create font
- tk_call('font', 'create', @compoundfont, *hash_kv(latinkeys))
- end
- end
-
+ latin_replace_core(ltn)
+ reset_pointadjust
self
end
def kanji_replace(knj)
- return self unless @kanjifont # ignore
kanji_replace_core(knj)
reset_pointadjust
self
@@ -1377,215 +1119,41 @@ class TkFont
def metrics(option=nil)
metrics_core(@compoundfont, nil, option)
end
- def metrics_hash(option=nil)
- if option
- val = metrics(option)
- case TkFont::MetricsType[option.to_s]
- when ?n
- val = TkComm::num_or_str(val)
- when ?b
- val = TkComm::bool(val)
- else
- # do nothing
- end
- return val
- end
-
- h = Hash[metrics(option)]
- h.keys.each{|k|
- case TkFont::MetricsType[k.to_s]
- when ?n
- h[k] = TkComm::num_or_str(h[k])
- when ?b
- h[k] = TkComm::bool(h[k])
- else
- # do nothing
- end
- }
- h
- end
def metrics_displayof(win, option=nil)
win = '.' unless win
metrics_core(@compoundfont, win, option)
end
- def metrics_hash_displayof(win, option=nil)
- if option
- val = metrics_displayof(win, option)
- case TkFont::MetricsType[option.to_s]
- when ?n
- val = TkComm::num_or_str(val)
- when ?b
- val = TkComm::bool(val)
- else
- # do nothing
- end
- return val
- end
-
- h = Hash[metrics_displayof(win, option)]
- h.keys.each{|k|
- case TkFont::MetricsType[k.to_s]
- when ?n
- h[k] = TkComm::num_or_str(h[k])
- when ?b
- h[k] = TkComm::bool(h[k])
- else
- # do nothing
- end
- }
- h
- end
def latin_metrics(option=nil)
- if @latinfont == nil
- metrics_core(@compoundfont, nil, option) # use @compoundfont
- else
- metrics_core(@latinfont, nil, option)
- end
- end
- def latin_metrics_hash(option=nil)
- if option
- val = latin_metrics(option)
- case TkFont::MetricsType[option.to_s]
- when ?n
- val = TkComm::num_or_str(val)
- when ?b
- val = TkComm::bool(val)
- else
- # do nothing
- end
- return val
- end
-
- h = Hash[latin_metrics(option)]
- h.keys.each{|k|
- case TkFont::MetricsType[k.to_s]
- when ?n
- h[k] = TkComm::num_or_str(h[k])
- when ?b
- h[k] = TkComm::bool(h[k])
- else
- # do nothing
- end
- }
- h
+ metrics_core(@latinfont, nil, option)
end
def latin_metrics_displayof(win, option=nil)
win = '.' unless win
- if @latinfont == nil
- metrics_core(@compoundfont, win, option) # use @compoundfont
- else
- metrics_core(@latinfont, win, option)
- end
- end
- def latin_metrics_hash_displayof(win, option=nil)
- if option
- val = latin_metrics_displayof(win, option)
- case TkFont::MetricsType[option.to_s]
- when ?n
- val = TkComm::num_or_str(val)
- when ?b
- val = TkComm::bool(val)
- else
- # do nothing
- end
- return val
- end
-
- h = Hash[latin_metrics_displayof(win, option)]
- h.keys.each{|k|
- case TkFont::MetricsType[k.to_s]
- when ?n
- h[k] = TkComm::num_or_str(h[k])
- when ?b
- h[k] = TkComm::bool(h[k])
- else
- # do nothing
- end
- }
- h
+ metrics_core(@latinfont, win, option)
end
def kanji_metrics(option=nil)
- if @latinfont == nil
- metrics_core(@compoundfont, nil, option) # use @compoundfont
- elsif JAPANIZED_TK
+ if JAPANIZED_TK
metrics_core(@kanjifont, nil, option)
else
metrics_core_tk4x(nil, nil, option)
end
end
- def kanji_metrics_hash(option=nil)
- if option
- val = kanji_metrics(option)
- case TkFont::MetricsType[option.to_s]
- when ?n
- val = TkComm::num_or_str(val)
- when ?b
- val = TkComm::bool(val)
- else
- # do nothing
- end
- return val
- end
-
- h = Hash[kanji_metrics(option)]
- h.keys.each{|k|
- case TkFont::MetricsType[k.to_s]
- when ?n
- h[k] = TkComm::num_or_str(h[k])
- when ?b
- h[k] = TkComm::bool(h[k])
- else
- # do nothing
- end
- }
- h
- end
def kanji_metrics_displayof(win, option=nil)
- win = '.' unless win
- if @latinfont == nil
- metrics_core(@compoundfont, win, option) # use @compoundfont
- elsif JAPANIZED_TK
+ if JAPANIZED_TK
+ win = '.' unless win
metrics_core(@kanjifont, win, option)
else
metrics_core_tk4x(nil, win, option)
end
end
- def kanji_metrics_hash_displayof(win, option=nil)
- if option
- val = kanji_metrics_displayof(win, option)
- case TkFont::MetricsType[option.to_s]
- when ?n
- val = TkComm::num_or_str(val)
- when ?b
- val = TkComm::bool(val)
- else
- # do nothing
- end
- return val
- end
-
- h = Hash[kanji_metrics_displayof(win, option)]
- h.keys.each{|k|
- case TkFont::MetricsType[k.to_s]
- when ?n
- h[k] = TkComm::num_or_str(h[k])
- when ?b
- h[k] = TkComm::bool(h[k])
- else
- # do nothing
- end
- }
- h
- end
def reset_pointadjust
begin
- if /^8\..*/ === Tk::TK_VERSION && JAPANIZED_TK
+ if /^8\.*/ === Tk::TK_VERSION && JAPANIZED_TK
configure('pointadjust' => latin_actual.assoc('size')[1].to_f /
kanji_actual.assoc('size')[1].to_f )
end
@@ -1598,7 +1166,7 @@ class TkFont
# private alias
###################################
case (Tk::TK_VERSION)
- when /^4\..*/
+ when /^4\.*/
alias create_latinfont create_latinfont_tk4x
alias create_kanjifont create_kanjifont_tk4x
alias create_compoundfont create_compoundfont_tk4x
@@ -1881,7 +1449,7 @@ module TkFont::CoreMethods
end
else
l = tk_split_simplelist(tk_call('font', 'configure', font))
- h = {}
+ r = {}
while key=l.shift
if key == '-compound'
l.shift
@@ -1890,57 +1458,45 @@ module TkFont::CoreMethods
val = l.shift
case TkFont::OptionType[key]
when ?n
- h[key] = num_or_str(val)
+ r.push [key, num_or_str(val)]
when ?b
- h[key] = bool(val)
+ r.push [key, bool(val)]
else
- h[key] = val
+ r.push [key, val]
end
end
end
- h
+ r
end
end
def delete_core_tk4x
- TkFont::Tk_FontNameTBL.mutex.synchronize{
- TkFont::Tk_FontNameTBL.delete(@id)
- }
- TkFont::Tk_FontUseTBL.mutex.synchronize{
- TkFont::Tk_FontUseTBL.delete_if{|key,value| value == self}
- }
+ TkFont::Tk_FontNameTBL.delete(@id)
+ TkFont::Tk_FontUseTBL.delete_if{|key,value| value == self}
end
def delete_core_tk8x
begin
- tk_call('font', 'delete', @latinfont) if @latinfont
+ tk_call('font', 'delete', @latinfont)
rescue
end
begin
- tk_call('font', 'delete', @kanjifont) if @kanjifont
+ tk_call('font', 'delete', @kanjifont)
rescue
end
begin
- tk_call('font', 'delete', @compoundfont) if @compoundfont
+ tk_call('font', 'delete', @compoundfont)
rescue
end
- TkFont::Tk_FontNameTBL.mutex.synchronize{
- TkFont::Tk_FontNameTBL.delete(@id)
- }
- TkFont::Tk_FontUseTBL.mutex.synchronize{
- TkFont::Tk_FontUseTBL.delete_if{|key,value| value == self}
- }
+ TkFont::Tk_FontNameTBL.delete(@id)
+ TkFont::Tk_FontUseTBL.delete_if{|key,value| value == self}
end
def latin_replace_core_tk4x(ltn)
create_latinfont_tk4x(ltn)
@compoundfont[0] = [@latinfont] if JAPANIZED_TK
@fontslot['font'] = @latinfont
- table = nil
- TkFont::Tk_FontUseTBL.mutex.synchronize{
- table = TkFont::Tk_FontUseTBL.clone
- }
- table.each{|w, fobj|
+ TkFont::Tk_FontUseTBL.dup.each{|w, fobj|
if self == fobj
begin
if w.include?(';')
@@ -1948,14 +1504,11 @@ module TkFont::CoreMethods
optkey = 'font' if optkey == nil || optkey == ''
winobj = tk_tcl2ruby(win)
# winobj.tagfont_configure(tag, {'font'=>@latinfont})
- #if winobj.kind_of? TkText
- if winobj.kind_of?(TkText) || winobj.kind_of?(Tk::Text)
+ if winobj.kind_of? TkText
tk_call(win, 'tag', 'configure', tag, "-#{optkey}", @latinfont)
- #elsif winobj.kind_of? TkCanvas
- elsif winobj.kind_of?(TkCanvas) || winobj.kind_of?(Tk::Canvas)
+ elsif winobj.kind_of? TkCanvas
tk_call(win, 'itemconfigure', tag, "-#{optkey}", @latinfont)
- #elsif winobj.kind_of? TkMenu
- elsif winobj.kind_of?(TkMenu) || winobj.kind_of?(Tk::Menu)
+ elsif winobj.kind_of? TkMenu
tk_call(win, 'entryconfigure', tag, "-#{optkey}", @latinfont)
else
raise RuntimeError, "unknown widget type"
@@ -1965,9 +1518,7 @@ module TkFont::CoreMethods
tk_call(w, 'configure', '-font', @latinfont)
end
rescue
- TkFont::Tk_FontUseTBL.mutex.synchronize{
- TkFont::Tk_FontUseTBL.delete(w)
- }
+ TkFont::Tk_FontUseTBL.delete(w)
end
end
}
@@ -1980,11 +1531,7 @@ module TkFont::CoreMethods
create_kanjifont_tk4x(knj)
@compoundfont[1] = [@kanjifont]
@fontslot['kanjifont'] = @kanjifont
- table = nil
- TkFont::Tk_FontUseTBL.mutex.synchronize{
- table = TkFont::Tk_FontUseTBL.clone
- }
- table.dup.each{|w, fobj|
+ TkFont::Tk_FontUseTBL.dup.each{|w, fobj|
if self == fobj
begin
if w.include?(';')
@@ -1992,14 +1539,11 @@ module TkFont::CoreMethods
optkey = 'kanjifont' unless optkey
winobj = tk_tcl2ruby(win)
# winobj.tagfont_configure(tag, {'kanjifont'=>@kanjifont})
- #if winobj.kind_of? TkText
- if winobj.kind_of?(TkText) || winobj.kind_of?(Tk::Text)
+ if winobj.kind_of? TkText
tk_call(win, 'tag', 'configure', tag, "-#{optkey}", @kanjifont)
- #elsif winobj.kind_of? TkCanvas
- elsif winobj.kind_of?(TkCanvas) || winobj.kind_of?(Tk::Canvas)
+ elsif winobj.kind_of? TkCanvas
tk_call(win, 'itemconfigure', tag, "-#{optkey}", @kanjifont)
- #elsif winobj.kind_of? TkMenu
- elsif winobj.kind_of?(TkMenu) || winobj.kind_of?(Tk::Menu)
+ elsif winobj.kind_of? TkMenu
tk_call(win, 'entryconfigure', tag, "-#{optkey}", @latinfont)
else
raise RuntimeError, "unknown widget type"
@@ -2009,9 +1553,7 @@ module TkFont::CoreMethods
tk_call(w, 'configure', '-kanjifont', @kanjifont)
end
rescue
- Tk_FontUseTBL.mutex.synchronize{
- TkFont::Tk_FontUseTBL.delete(w)
- }
+ TkFont::Tk_FontUseTBL.delete(w)
end
end
}
@@ -2076,11 +1618,8 @@ module TkFont::CoreMethods
rescue
latinkeys = {}
end
- begin
+ if latinkeys != {}
tk_call('font', 'configure', @compoundfont, *hash_kv(latinkeys))
- rescue
- # not exist? (deleted?) -> create font
- tk_call('font', 'create', @compoundfont, *hash_kv(latinkeys))
end
end
self
@@ -2172,13 +1711,6 @@ module TkFont::CoreMethods
r = []
while key=l.shift
r.push [key[1..-1], l.shift.to_i]
-=begin
- if key == '-fixed' # boolean value
- r.push [key[1..-1], bool(l.shift)]
- else
- r.push [key[1..-1], l.shift.to_i]
- end
-=end
end
r
end
@@ -2188,7 +1720,7 @@ module TkFont::CoreMethods
# private alias
###################################
case (Tk::TK_VERSION)
- when /^4\..*/
+ when /^4\.*/
alias actual_core actual_core_tk4x
alias configure_core configure_core_tk4x
alias configinfo_core configinfo_core_tk4x
@@ -2228,117 +1760,3 @@ class TkFont
include TkFont::CoreMethods
extend TkFont::CoreMethods
end
-
-class TkNamedFont < TkFont
- # for built-in named fonts
- def TkNamedFont.find(name)
- name = name.to_s
- unless (obj = Tk_FontNameTBL[name])
- obj = self.new(name) if TkFont.is_system_font?(name)
- end
- obj
- end
-
- def TkNamedFont.new(name, keys=nil)
- name = name.to_s
- obj = nil
- Tk_FontNameTBL.mutex.synchronize{
- unless (obj = Tk_FontNameTBL[name])
- (obj = self.allocate).instance_eval{
- @id = @compoundfont = name.to_s
- @latinfont = nil
- @kanjifont = nil
- @descendant = [self, self] # [latin, kanji] : dummy
- Tk_FontNameTBL[@id] = self
- }
- end
- }
- obj.instance_eval{ initialize(name, keys) }
- obj
- end
-
- ###########################
- private
- ###########################
- def initialize(name, keys=nil)
- @id = @compoundfont = name.to_s
-
- # if not exist named font, create it.
- begin
- if keys
- tk_call('font', 'configure', @compoundfont, keys)
- else
- tk_call('font', 'configure', @compoundfont)
- end
- rescue
- # the named font doesn't exist -> create
- if keys
- tk_call('font', 'create', @compoundfont, keys)
- else
- tk_call('font', 'create', @compoundfont)
- end
- end
- end
-
- def create_latinfont(fnt)
- # ignore
- end
- def create_kanjifont(fnt)
- # ignore
- end
- def create_compoundfont(ltn, knj, keys)
- # ignore
- end
-
- ###########################
- public
- ###########################
- def latin_font_id
- @compoundfont
- end
- def kanji_font_id
- @compoundfont
- end
-end
-
-#######################################
-# define system font names
-#######################################
-if Tk::TCL_MAJOR_VERSION > 8 ||
- (Tk::TCL_MAJOR_VERSION == 8 && Tk::TCL_MINOR_VERSION >= 5)
- # add standard fonts of Tcl/Tk 8.5+
- TkFont::SYSTEM_FONT_NAMES.add [
- 'TkDefaultFont', 'TkTextFont', 'TkFixedFont', 'TkMenuFont',
- 'TkHeadingFont', 'TkCaptionFont', 'TkSmallCaptionFont',
- 'TkIconFont', 'TkTooltipFont'
- ]
-end
-
-# platform-specific fonts
-# -- windows
-TkFont::SYSTEM_FONT_NAMES.add [
- 'ansifixed', 'ansi', 'device', 'oemfixed', 'systemfixed', 'system'
-]
-
-# -- macintosh, macosx
-TkFont::SYSTEM_FONT_NAMES.add ['system', 'application']
-
-if Tk::TCL_MAJOR_VERSION > 8 ||
- (Tk::TCL_MAJOR_VERSION == 8 && Tk::TCL_MINOR_VERSION >= 5)
- TkFont::SYSTEM_FONT_NAMES.add ['menu']
-end
-
-# -- macosx (Aqua theme)
-if Tk::TCL_MAJOR_VERSION > 8 ||
- (Tk::TCL_MAJOR_VERSION == 8 && Tk::TCL_MINOR_VERSION >= 5)
- TkFont::SYSTEM_FONT_NAMES.add [
- 'systemSystemFont', 'systemEmphasizedSystemFont',
- 'systemSmallSystemFont', 'systemSmallEmphasizedSystemFont',
- 'systemApplicationFont', 'systemLabelFont', 'systemViewsFont',
- 'systemMenuTitleFont', 'systemMenuItemFont', 'systemMenuItemMarkFont',
- 'systemMenuItemCmdKeyFont', 'systemWindowTitleFont',
- 'systemPushButtonFont', 'systemUtilityWindowTitleFont',
- 'systemAlertHeaderFont', 'systemToolbarFont', 'systemMiniSystemFont',
- 'systemDetailSystemFont', 'systemDetailEmphasizedSystemFont'
- ]
-end
diff --git a/ext/tk/lib/tk/frame.rb b/ext/tk/lib/tk/frame.rb
index 263b160f29..6636fef5b5 100644
--- a/ext/tk/lib/tk/frame.rb
+++ b/ext/tk/lib/tk/frame.rb
@@ -3,7 +3,7 @@
#
require 'tk'
-class Tk::Frame<TkWindow
+class TkFrame<TkWindow
TkCommandNames = ['frame'.freeze].freeze
WidgetClassName = 'Frame'.freeze
WidgetClassNames[WidgetClassName] = self
@@ -126,6 +126,3 @@ class Tk::Frame<TkWindow
end
end
end
-
-#TkFrame = Tk::Frame unless Object.const_defined? :TkFrame
-Tk.__set_toplevel_aliases__(:Tk, Tk::Frame, :TkFrame)
diff --git a/ext/tk/lib/tk/grid.rb b/ext/tk/lib/tk/grid.rb
index 0dfd7263a7..10fdf3569b 100644
--- a/ext/tk/lib/tk/grid.rb
+++ b/ext/tk/lib/tk/grid.rb
@@ -22,7 +22,6 @@ module TkGrid
list(tk_call_without_enc('grid', 'bbox', *args))
end
-=begin
def configure(win, *args)
if args[-1].kind_of?(Hash)
opts = args.pop
@@ -54,48 +53,6 @@ module TkGrid
tk_call_without_enc('grid', 'configure', *params)
end
end
-=end
- def configure(*args)
- if args[-1].kind_of?(Hash)
- opts = args.pop
- else
- opts = {}
- end
- fail ArgumentError, 'no widget is given' if args.empty?
- params = []
- args.flatten(1).each{|win|
- case win
- when '-', ?- # RELATIVE PLACEMENT (increase columnspan)
- params.push('-')
- when /^-+$/ # RELATIVE PLACEMENT (increase columnspan)
- params.concat(win.to_s.split(//))
- when '^', ?^ # RELATIVE PLACEMENT (increase rowspan)
- params.push('^')
- when /^\^+$/ # RELATIVE PLACEMENT (increase rowspan)
- params.concat(win.to_s.split(//))
- when 'x', :x, ?x, nil, '' # RELATIVE PLACEMENT (empty column)
- params.push('x')
- when /^x+$/ # RELATIVE PLACEMENT (empty column)
- params.concat(win.to_s.split(//))
- else
- params.push(_epath(win))
- end
- }
- opts.each{|k, v|
- params.push("-#{k}")
- params.push(_epath(v)) # have to use 'epath' (hash_kv() is unavailable)
- }
- if Tk::TCL_MAJOR_VERSION < 8 ||
- (Tk::TCL_MAJOR_VERSION == 8 && Tk::TCL_MINOR_VERSION <= 3)
- if params[0] == '-' || params[0] == 'x' || params[0] == '^'
- tk_call_without_enc('grid', *params)
- else
- tk_call_without_enc('grid', 'configure', *params)
- end
- else
- tk_call_without_enc('grid', 'configure', *params)
- end
- end
alias grid configure
def columnconfigure(master, index, args)
@@ -104,14 +61,12 @@ module TkGrid
tk_call_without_enc("grid", 'columnconfigure',
master, index, *hash_kv(args))
end
- alias column columnconfigure
def rowconfigure(master, index, args)
# master = master.epath if master.kind_of?(TkObject)
master = _epath(master)
tk_call_without_enc("grid", 'rowconfigure', master, index, *hash_kv(args))
end
- alias row rowconfigure
def columnconfiginfo(master, index, slot=nil)
# master = master.epath if master.kind_of?(TkObject)
@@ -234,10 +189,10 @@ module TkGrid
list(tk_call_without_enc('grid', 'slaves', master, *hash_kv(args)))
end
- module_function :anchor, :bbox, :add, :forget, :propagate, :info
+ module_function :bbox, :forget, :propagate, :info
module_function :remove, :size, :slaves, :location
module_function :grid, :configure, :columnconfigure, :rowconfigure
- module_function :column, :row, :columnconfiginfo, :rowconfiginfo
+ module_function :columnconfiginfo, :rowconfiginfo
end
=begin
def TkGrid(win, *args)
diff --git a/ext/tk/lib/tk/image.rb b/ext/tk/lib/tk/image.rb
index dffdc19644..35e2c4e394 100644
--- a/ext/tk/lib/tk/image.rb
+++ b/ext/tk/lib/tk/image.rb
@@ -10,16 +10,9 @@ class TkImage<TkObject
TkCommandNames = ['image'.freeze].freeze
Tk_IMGTBL = TkCore::INTERP.create_table
+ Tk_Image_ID = ['i'.freeze, '00000'.taint].freeze
- (Tk_Image_ID = ['i'.freeze, '00000'.taint]).instance_eval{
- @mutex = Mutex.new
- def mutex; @mutex; end
- freeze
- }
-
- TkCore::INTERP.init_ip_env{
- Tk_IMGTBL.mutex.synchronize{ Tk_IMGTBL.clear }
- }
+ TkCore::INTERP.init_ip_env{ Tk_IMGTBL.clear }
def self.new(keys=nil)
if keys.kind_of?(Hash)
@@ -34,10 +27,7 @@ class TkImage<TkObject
obj = name
else
name = _get_eval_string(name)
- obj = nil
- Tk_IMGTBL.mutex.synchronize{
- obj = Tk_IMGTBL[name]
- }
+ obj = Tk_IMGTBL[name]
end
if obj
if !(keys[:without_creating] || keys['without_creating'])
@@ -53,13 +43,7 @@ class TkImage<TkObject
end
end
end
- (obj = self.allocate).instance_eval{
- Tk_IMGTBL.mutex.synchronize{
- initialize(keys)
- Tk_IMGTBL[@path] = self
- }
- }
- obj
+ super(keys)
end
def initialize(keys=nil)
@@ -71,22 +55,19 @@ class TkImage<TkObject
without_creating = keys.delete('without_creating')
end
unless @path
- Tk_Image_ID.mutex.synchronize{
- # @path = Tk_Image_ID.join('')
- @path = Tk_Image_ID.join(TkCore::INTERP._ip_id_)
- Tk_Image_ID[1].succ!
- }
+ # @path = Tk_Image_ID.join('')
+ @path = Tk_Image_ID.join(TkCore::INTERP._ip_id_)
+ Tk_Image_ID[1].succ!
end
unless without_creating
tk_call_without_enc('image', 'create',
@type, @path, *hash_kv(keys, true))
end
+ Tk_IMGTBL[@path] = self
end
def delete
- Tk_IMGTBL.mutex.synchronize{
- Tk_IMGTBL.delete(@id) if @id
- }
+ Tk_IMGTBL.delete(@id) if @id
tk_call_without_enc('image', 'delete', @path)
self
end
@@ -104,10 +85,8 @@ class TkImage<TkObject
end
def TkImage.names
- Tk_IMGTBL.mutex.synchronize{
- Tk.tk_call_without_enc('image', 'names').split.collect!{|id|
- (Tk_IMGTBL[id])? Tk_IMGTBL[id] : id
- }
+ Tk.tk_call_without_enc('image', 'names').split.collect!{|id|
+ (Tk_IMGTBL[id])? Tk_IMGTBL[id] : id
}
end
@@ -156,7 +135,7 @@ class TkPhotoImage<TkImage
self
end
- def cget_strict(option)
+ def cget(option)
case option.to_s
when 'data', 'file'
tk_send 'cget', '-' << option.to_s
@@ -164,23 +143,6 @@ class TkPhotoImage<TkImage
tk_tcl2ruby(tk_send('cget', '-' << option.to_s))
end
end
- def cget(option)
- unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
- cget_strict(option)
- else
- begin
- cget_strict(option)
- rescue => e
- if current_configinfo.has_key?(option.to_s)
- # error on known option
- fail e
- else
- # unknown option
- nil
- end
- end
- end
- end
def copy(src, *opts)
if opts.size == 0
diff --git a/ext/tk/lib/tk/itemconfig.rb b/ext/tk/lib/tk/itemconfig.rb
index 9c6a98d0f8..0b84be38b8 100644
--- a/ext/tk/lib/tk/itemconfig.rb
+++ b/ext/tk/lib/tk/itemconfig.rb
@@ -8,11 +8,6 @@ require 'tk/itemfont.rb'
module TkItemConfigOptkeys
include TkUtil
- def __item_optkey_aliases(id)
- {}
- end
- private :__item_optkey_aliases
-
def __item_numval_optkeys(id)
[]
end
@@ -120,14 +115,6 @@ module TkItemConfigMethod
include TkTreatItemFont
include TkItemConfigOptkeys
- def TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
- @mode || false
- end
- def TkItemConfigMethod.__set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode)
- fail SecurityError, "can't change the mode" if $SAFE>=4
- @mode = (mode)? true: false
- end
-
def __item_cget_cmd(id)
# maybe need to override
[self.path, 'itemcget', id]
@@ -162,7 +149,7 @@ module TkItemConfigMethod
################################################
- def __itemcget_core(tagOrId, option)
+ def itemcget(tagOrId, option)
orig_opt = option
option = option.to_s
@@ -170,11 +157,6 @@ module TkItemConfigMethod
fail ArgumentError, "Invalid option `#{orig_opt.inspect}'"
end
- alias_name, real_name = __item_optkey_aliases(tagid(tagOrId)).find{|k, v| k.to_s == option}
- if real_name
- option = real_name.to_s
- end
-
if ( method = _symbolkey2str(__item_val2ruby_optkeys(tagid(tagOrId)))[option] )
optval = tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}"))
begin
@@ -242,45 +224,11 @@ module TkItemConfigMethod
tk_tcl2ruby(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}")), true)
end
end
- private :__itemcget_core
- def itemcget(tagOrId, option)
- unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
- __itemcget_core(tagOrId, option)
- else
- begin
- __itemcget_core(tagOrId, option)
- rescue => e
- begin
- if __current_itemconfiginfo(tagOrId).has_key?(option.to_s)
- # not tag error & option is known -> error on known option
- fail e
- else
- # not tag error & option is unknown
- nil
- end
- rescue
- fail e # tag error
- end
- end
- end
- end
- def itemcget_strict(tagOrId, option)
- # never use TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
- __itemcget_core(tagOrId, option)
- end
-
- def __itemconfigure_core(tagOrId, slot, value=None)
+ def itemconfigure(tagOrId, slot, value=None)
if slot.kind_of? Hash
slot = _symbolkey2str(slot)
- __item_optkey_aliases(tagid(tagOrId)).each{|alias_name, real_name|
- alias_name = alias_name.to_s
- if slot.has_key?(alias_name)
- slot[real_name.to_s] = slot.delete(alias_name)
- end
- }
-
__item_methodcall_optkeys(tagid(tagOrId)).each{|key, method|
value = slot.delete(key.to_s)
self.__send__(method, tagOrId, value) if value
@@ -317,11 +265,6 @@ module TkItemConfigMethod
fail ArgumentError, "Invalid option `#{orig_slot.inspect}'"
end
- alias_name, real_name = __item_optkey_aliases(tagid(tagOrId)).find{|k, v| k.to_s == slot}
- if real_name
- slot = real_name.to_s
- end
-
if ( conf = __item_keyonly_optkeys(tagid(tagOrId)).find{|k, v| k.to_s == slot } )
defkey, undefkey = conf
if value
@@ -345,58 +288,8 @@ module TkItemConfigMethod
end
self
end
- private :__itemconfigure_core
-
- def __check_available_itemconfigure_options(tagOrId, keys)
- id = tagid(tagOrId)
-
- availables = self.__current_itemconfiginfo(id).keys
- # add non-standard keys
- availables |= __font_optkeys.map{|k|
- [k.to_s, "latin#{k}", "ascii#{k}", "kanji#{k}"]
- }.flatten
- availables |= __item_methodcall_optkeys(id).keys.map{|k| k.to_s}
- availables |= __item_keyonly_optkeys(id).keys.map{|k| k.to_s}
-
- keys = _symbolkey2str(keys)
-
- keys.delete_if{|k, v| !(availables.include?(k))}
- end
-
- def itemconfigure(tagOrId, slot, value=None)
- unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
- __itemconfigure_core(tagOrId, slot, value)
- else
- if slot.kind_of?(Hash)
- begin
- __itemconfigure_core(tagOrId, slot)
- rescue
- slot = __check_available_itemconfigure_options(tagOrId, slot)
- __itemconfigure_core(tagOrId, slot) unless slot.empty?
- end
- else
- begin
- __itemconfigure_core(tagOrId, slot, value)
- rescue => e
- begin
- if __current_itemconfiginfo(tagOrId).has_key?(slot.to_s)
- # not tag error & option is known -> error on known option
- fail e
- else
- # not tag error & option is unknown
- nil
- end
- rescue
- fail e # tag error
- end
- end
- end
- end
- self
- end
-
- def __itemconfiginfo_core(tagOrId, slot = nil)
+ def itemconfiginfo(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
@@ -406,10 +299,6 @@ module TkItemConfigMethod
conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1]
if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \
|| conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
- fnt = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]
- if TkFont.is_system_font?(fnt)
- conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = TkNamedFont.new(fnt)
- end
conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = tagfontobj(tagid(tagOrId), fontkey)
elsif ( __item_configinfo_struct(tagid(tagOrId))[:alias] \
&& conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 \
@@ -421,12 +310,6 @@ module TkItemConfigMethod
else
if slot
slot = slot.to_s
-
- alias_name, real_name = __item_optkey_aliases(tagid(tagOrId)).find{|k, v| k.to_s == slot}
- if real_name
- slot = real_name.to_s
- end
-
case slot
when /^(#{__item_val2ruby_optkeys(tagid(tagOrId)).keys.join('|')})$/
method = _symbolkey2str(__item_val2ruby_optkeys(tagid(tagOrId)))[slot]
@@ -711,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(v)
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = TkVarAccess.new
end
end
@@ -752,10 +635,6 @@ module TkItemConfigMethod
fontconf = ret.assoc(optkey)
if fontconf && fontconf.size > 2
ret.delete_if{|inf| inf[0] =~ /^(|latin|ascii|kanji)#{optkey}$/}
- fnt = fontconf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]
- if TkFont.is_system_font?(fnt)
- fontconf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = TkNamedFont.new(fnt)
- end
fontconf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = tagfontobj(tagid(tagOrId), optkey)
ret.push(fontconf)
end
@@ -779,11 +658,7 @@ module TkItemConfigMethod
if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \
|| conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
- fnt = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]
- if TkFont.is_system_font?(fnt)
- conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = TkNamedFont.new(fnt)
- end
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = tagfontobj(tagid(tagOrId), fontkey)
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = fontobj(tagid(tagOrId), fontkey)
{ conf.shift => conf }
elsif ( __item_configinfo_struct(tagid(tagOrId))[:alias] \
&& conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
@@ -798,12 +673,6 @@ module TkItemConfigMethod
else
if slot
slot = slot.to_s
-
- alias_name, real_name = __item_optkey_aliases(tagid(tagOrId)).find{|k, v| k.to_s == slot}
- if real_name
- slot = real_name.to_s
- end
-
case slot
when /^(#{__item_val2ruby_optkeys(tagid(tagOrId)).keys.join('|')})$/
method = _symbolkey2str(__item_val2ruby_optkeys(tagid(tagOrId)))[slot]
@@ -1137,10 +1006,6 @@ module TkItemConfigMethod
ret.delete('latin' << optkey)
ret.delete('ascii' << optkey)
ret.delete('kanji' << optkey)
- fnt = fontconf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]
- if TkFont.is_system_font?(fnt)
- fontconf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = TkNamedFont.new(fnt)
- end
fontconf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = tagfontobj(tagid(tagOrId), optkey)
ret[optkey] = fontconf
end
@@ -1155,32 +1020,13 @@ module TkItemConfigMethod
end
end
end
- private :__itemconfiginfo_core
- def itemconfiginfo(tagOrId, slot = nil)
- if slot && TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
- begin
- __itemconfiginfo_core(tagOrId, slot)
- rescue => e
- begin
- __itemconfiginfo_core(tagOrId)
- # not tag error -> option is unknown
- Array.new(__item_configinfo_struct.values.max).unshift(slot.to_s)
- rescue
- fail e # tag error
- end
- end
- else
- __itemconfiginfo_core(tagOrId, slot)
- end
- end
-
- def __current_itemconfiginfo(tagOrId, slot = nil)
+ def current_itemconfiginfo(tagOrId, slot = nil)
if TkComm::GET_CONFIGINFO_AS_ARRAY
if slot
org_slot = slot
begin
- conf = __itemconfiginfo_core(tagOrId, slot)
+ conf = itemconfiginfo(tagOrId, slot)
if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \
|| conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
return {conf[0] => conf[-1]}
@@ -1191,25 +1037,20 @@ module TkItemConfigMethod
"there is a configure alias loop about '#{org_slot}'"
else
ret = {}
- __itemconfiginfo_core(tagOrId).each{|conf|
+ itemconfiginfo(tagOrId).each{|conf|
if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \
|| conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
ret[conf[0]] = conf[-1]
end
}
-
ret
end
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
ret = {}
- __itemconfiginfo_core(tagOrId, slot).each{|key, conf|
+ itemconfiginfo(slot).each{|key, conf|
ret[key] = conf[-1] if conf.kind_of?(Array)
}
ret
end
end
-
- def current_itemconfiginfo(tagOrId, slot = nil)
- __current_itemconfiginfo(tagOrId, slot)
- end
end
diff --git a/ext/tk/lib/tk/itemfont.rb b/ext/tk/lib/tk/itemfont.rb
index 4c5c917c57..ab9e3ff6c9 100644
--- a/ext/tk/lib/tk/itemfont.rb
+++ b/ext/tk/lib/tk/itemfont.rb
@@ -94,16 +94,7 @@ module TkTreatItemFont
*(__item_config_cmd(tagid(tagOrId)) << {}))
next
else
- fnt = hash_kv(fnt) if fnt.kind_of?(Hash)
- unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
- tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << fnt))
- else
- begin
- tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << fnt))
- rescue => e
- # ignore
- end
- end
+ tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << fnt))
end
end
next
@@ -156,16 +147,7 @@ module TkTreatItemFont
elsif Tk::JAPANIZED_TK
fobj = fontobj # create a new TkFont object
else
- ltn = hash_kv(ltn) if ltn.kind_of?(Hash)
- unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
- tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << ltn))
- else
- begin
- tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << ltn))
- rescue => e
- # ignore
- end
- end
+ tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << ltn))
next
end
@@ -216,16 +198,7 @@ module TkTreatItemFont
elsif Tk::JAPANIZED_TK
fobj = fontobj # create a new TkFont object
else
- knj = hash_kv(knj) if knj.kind_of?(Hash)
- unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
- tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << knj))
- else
- begin
- tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << knj))
- rescue => e
- # ignore
- end
- end
+ tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << knj))
next
end
diff --git a/ext/tk/lib/tk/label.rb b/ext/tk/lib/tk/label.rb
index 80b3d778f1..8b45db9b30 100644
--- a/ext/tk/lib/tk/label.rb
+++ b/ext/tk/lib/tk/label.rb
@@ -3,7 +3,7 @@
#
require 'tk'
-class Tk::Label<TkWindow
+class TkLabel<TkWindow
TkCommandNames = ['label'.freeze].freeze
WidgetClassName = 'Label'.freeze
WidgetClassNames[WidgetClassName] = self
@@ -16,6 +16,3 @@ class Tk::Label<TkWindow
#end
#private :create_self
end
-
-#TkLabel = Tk::Label unless Object.const_defined? :TkLabel
-Tk.__set_toplevel_aliases__(:Tk, Tk::Label, :TkLabel)
diff --git a/ext/tk/lib/tk/labelframe.rb b/ext/tk/lib/tk/labelframe.rb
index 995b5b7e72..73d5603200 100644
--- a/ext/tk/lib/tk/labelframe.rb
+++ b/ext/tk/lib/tk/labelframe.rb
@@ -4,7 +4,7 @@
require 'tk'
require 'tk/frame'
-class Tk::LabelFrame<Tk::Frame
+class TkLabelFrame<TkFrame
TkCommandNames = ['labelframe'.freeze].freeze
WidgetClassName = 'Labelframe'.freeze
WidgetClassNames[WidgetClassName] = self
@@ -22,8 +22,4 @@ class Tk::LabelFrame<Tk::Frame
end
private :__val2ruby_optkeys
end
-
-Tk::Labelframe = Tk::LabelFrame
-#TkLabelFrame = Tk::LabelFrame unless Object.const_defined? :TkLabelFrame
-#TkLabelframe = Tk::Labelframe unless Object.const_defined? :TkLabelframe
-Tk.__set_toplevel_aliases__(:Tk, Tk::LabelFrame, :TkLabelFrame, :TkLabelframe)
+TkLabelframe = TkLabelFrame
diff --git a/ext/tk/lib/tk/listbox.rb b/ext/tk/lib/tk/listbox.rb
index bb039ffb0e..41d02d279e 100644
--- a/ext/tk/lib/tk/listbox.rb
+++ b/ext/tk/lib/tk/listbox.rb
@@ -15,7 +15,7 @@ module TkListItemConfig
private :__item_listval_optkeys
end
-class Tk::Listbox<TkTextWin
+class TkListbox<TkTextWin
include TkListItemConfig
include Scrollable
@@ -277,6 +277,3 @@ class Tk::Listbox<TkTextWin
end
=end
end
-
-#TkListbox = Tk::Listbox unless Object.const_defined? :TkListbox
-Tk.__set_toplevel_aliases__(:Tk, Tk::Listbox, :TkListbox)
diff --git a/ext/tk/lib/tk/macpkg.rb b/ext/tk/lib/tk/macpkg.rb
index 67b0a4bb60..1802073f46 100644
--- a/ext/tk/lib/tk/macpkg.rb
+++ b/ext/tk/lib/tk/macpkg.rb
@@ -20,14 +20,9 @@ module Tk
end
end
-module Tk::MacResource
-end
-#TkMacResource = Tk::MacResource
-Tk.__set_toplevel_aliases__(:Tk, Tk::MacResource, :TkMacResource)
-
-module Tk::MacResource
+module TkMacResource
extend Tk
- extend Tk::MacResource
+ extend TkMacResource
TkCommandNames = ['resource'.freeze].freeze
diff --git a/ext/tk/lib/tk/menu.rb b/ext/tk/lib/tk/menu.rb
index 3ae0548dd1..ddddc8e53e 100644
--- a/ext/tk/lib/tk/menu.rb
+++ b/ext/tk/lib/tk/menu.rb
@@ -34,16 +34,15 @@ module TkMenuEntryConfig
private :__item_val2ruby_optkeys
alias entrycget itemcget
- alias entrycget_strict itemcget_strict
alias entryconfigure itemconfigure
alias entryconfiginfo itemconfiginfo
alias current_entryconfiginfo current_itemconfiginfo
- private :itemcget, :itemcget_strict
- private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+ private :itemcget, :itemconfigure
+ private :itemconfiginfo, :current_itemconfiginfo
end
-class Tk::Menu<TkWindow
+class TkMenu<TkWindow
include Wm
include TkMenuEntryConfig
extend TkMenuSpec
@@ -141,9 +140,9 @@ class Tk::Menu<TkWindow
type = keys.delete('type') if keys.has_key?('type')
if keys.empty?
- Tk::MenuClone.new(self, parent, type)
+ TkMenuClone.new(self, parent, type)
else
- Tk::MenuClone.new(self, parent, type, keys)
+ TkMenuClone.new(self, parent, type, keys)
end
end
@@ -203,9 +202,6 @@ class Tk::Menu<TkWindow
tk_send_without_enc('unpost')
self
end
- def xposition(index)
- number(tk_send_without_enc('xposition', _get_eval_enc_str(index)))
- end
def yposition(index)
number(tk_send_without_enc('yposition', _get_eval_enc_str(index)))
end
@@ -385,11 +381,8 @@ class Tk::Menu<TkWindow
=end
end
-#TkMenu = Tk::Menu unless Object.const_defined? :TkMenu
-Tk.__set_toplevel_aliases__(:Tk, Tk::Menu, :TkMenu)
-
-class Tk::MenuClone<Tk::Menu
+class TkMenuClone<TkMenu
=begin
def initialize(parent, type=None)
widgetname = nil
@@ -443,12 +436,9 @@ class Tk::MenuClone<Tk::Menu
@src_menu
end
end
-Tk::CloneMenu = Tk::MenuClone
-#TkMenuClone = Tk::MenuClone unless Object.const_defined? :TkMenuClone
-#TkCloneMenu = Tk::CloneMenu unless Object.const_defined? :TkCloneMenu
-Tk.__set_toplevel_aliases__(:Tk, Tk::MenuClone, :TkMenuClone, :TkCloneMenu)
+TkCloneMenu = TkMenuClone
-module Tk::SystemMenu
+module TkSystemMenu
def initialize(parent, keys=nil)
if parent.kind_of? Hash
keys = _symbolkey2str(parent)
@@ -471,60 +461,38 @@ module Tk::SystemMenu
end
end
end
-TkSystemMenu = Tk::SystemMenu
-class Tk::SysMenu_Help<Tk::Menu
+class TkSysMenu_Help<TkMenu
# for all platform
- include Tk::SystemMenu
+ include TkSystemMenu
SYSMENU_NAME = 'help'
end
-#TkSysMenu_Help = Tk::SysMenu_Help unless Object.const_defined? :TkSysMenu_Help
-Tk.__set_toplevel_aliases__(:Tk, Tk::SysMenu_Help, :TkSysMenu_Help)
-class Tk::SysMenu_System<Tk::Menu
+class TkSysMenu_System<TkMenu
# for Windows
- include Tk::SystemMenu
+ include TkSystemMenu
SYSMENU_NAME = 'system'
end
-#TkSysMenu_System = Tk::SysMenu_System unless Object.const_defined? :TkSysMenu_System
-Tk.__set_toplevel_aliases__(:Tk, Tk::SysMenu_System, :TkSysMenu_System)
-class Tk::SysMenu_Apple<Tk::Menu
+class TkSysMenu_Apple<TkMenu
# for Machintosh
- include Tk::SystemMenu
+ include TkSystemMenu
SYSMENU_NAME = 'apple'
end
-#TkSysMenu_Apple = Tk::SysMenu_Apple unless Object.const_defined? :TkSysMenu_Apple
-Tk.__set_toplevel_aliases__(:Tk, Tk::SysMenu_Apple, :TkSysMenu_Apple)
-class Tk::Menubutton<Tk::Label
+class TkMenubutton<TkLabel
TkCommandNames = ['menubutton'.freeze].freeze
WidgetClassName = 'Menubutton'.freeze
WidgetClassNames[WidgetClassName] = self
def create_self(keys)
if keys and keys != None
- unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
- # tk_call_without_enc('menubutton', @path, *hash_kv(keys, true))
- tk_call_without_enc(self.class::TkCommandNames[0], @path,
- *hash_kv(keys, true))
- else
- begin
- tk_call_without_enc(self.class::TkCommandNames[0], @path,
- *hash_kv(keys, true))
- rescue
- tk_call_without_enc(self.class::TkCommandNames[0], @path)
- keys = __check_available_configure_options(keys)
- unless keys.empty?
- tk_call_without_enc('destroy', @path) rescue nil
- tk_call_without_enc(self.class::TkCommandNames[0], @path,
- *hash_kv(keys, true))
- end
- end
- end
+ # tk_call_without_enc('menubutton', @path, *hash_kv(keys, true))
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
else
# tk_call_without_enc('menubutton', @path)
tk_call_without_enc(self.class::TkCommandNames[0], @path)
@@ -538,13 +506,10 @@ class Tk::Menubutton<Tk::Label
private :__boolval_optkeys
end
-Tk::MenuButton = Tk::Menubutton
-#TkMenubutton = Tk::Menubutton unless Object.const_defined? :TkMenubutton
-#TkMenuButton = Tk::MenuButton unless Object.const_defined? :TkMenuButton
-Tk.__set_toplevel_aliases__(:Tk, Tk::Menubutton, :TkMenubutton, :TkMenuButton)
+TkMenuButton = TkMenubutton
-class Tk::OptionMenubutton<Tk::Menubutton
+class TkOptionMenubutton<TkMenubutton
TkCommandNames = ['tk_optionMenu'.freeze].freeze
class OptionMenu<TkMenu
@@ -631,9 +596,6 @@ class Tk::OptionMenubutton<Tk::Menubutton
@menu.delete(index, last)
self
end
- def xposition(index)
- @menu.xposition(index)
- end
def yposition(index)
@menu.yposition(index)
end
@@ -643,9 +605,6 @@ class Tk::OptionMenubutton<Tk::Menubutton
def menucget(key)
@menu.cget(key)
end
- def menucget_strict(key)
- @menu.cget_strict(key)
- end
def menuconfigure(key, val=None)
@menu.configure(key, val)
self
@@ -659,9 +618,6 @@ class Tk::OptionMenubutton<Tk::Menubutton
def entrycget(index, key)
@menu.entrycget(index, key)
end
- def entrycget_strict(index, key)
- @menu.entrycget_strict(index, key)
- end
def entryconfigure(index, key, val=None)
@menu.entryconfigure(index, key, val)
self
@@ -673,9 +629,4 @@ class Tk::OptionMenubutton<Tk::Menubutton
@menu.current_entryconfiginfo(index, key)
end
end
-
-Tk::OptionMenuButton = Tk::OptionMenubutton
-#TkOptionMenubutton = Tk::OptionMenubutton unless Object.const_defined? :TkOptionMenubutton
-#TkOptionMenuButton = Tk::OptionMenuButton unless Object.const_defined? :TkOptionMenuButton
-Tk.__set_toplevel_aliases__(:Tk, Tk::OptionMenubutton,
- :TkOptionMenubutton, :TkOptionMenuButton)
+TkOptionMenuButton = TkOptionMenubutton
diff --git a/ext/tk/lib/tk/menubar.rb b/ext/tk/lib/tk/menubar.rb
index ef9da809b9..392b6fbd4e 100644
--- a/ext/tk/lib/tk/menubar.rb
+++ b/ext/tk/lib/tk/menubar.rb
@@ -89,7 +89,7 @@ require 'tk/frame'
require 'tk/composite'
require 'tk/menuspec'
-class TkMenubar<Tk::Frame
+class TkMenubar<TkFrame
include TkComposite
include TkMenuSpec
diff --git a/ext/tk/lib/tk/menuspec.rb b/ext/tk/lib/tk/menuspec.rb
index 2a2eb9ba3c..118a4f42b1 100644
--- a/ext/tk/lib/tk/menuspec.rb
+++ b/ext/tk/lib/tk/menuspec.rb
@@ -61,12 +61,8 @@ module TkMenuSpec
tearoff = orig_opts.delete('tearoff') if orig_opts.key?('tearoff')
if menu_name
- #menu = Tk::Menu.new(parent, :widgetname=>menu_name, :tearoff=>tearoff)
- # --> use current TkMenu class
menu = TkMenu.new(parent, :widgetname=>menu_name, :tearoff=>tearoff)
else
- #menu = Tk::Menu.new(parent, :tearoff=>tearoff)
- # --> use current TkMenu class
menu = TkMenu.new(parent, :tearoff=>tearoff)
end
@@ -154,22 +150,21 @@ module TkMenuSpec
def _use_menubar?(parent)
use_menubar = false
- if parent.kind_of?(Tk::Root) || parent.kind_of?(Tk::Toplevel)
- true
- elsif parent.current_configinfo.has_key?('menu')
- true
+ if parent.kind_of?(TkRoot) || parent.kind_of?(TkToplevel)
+ return true
else
- false
+ begin
+ parent.cget('menu')
+ return true
+ rescue
+ end
end
+ false
end
private :_use_menubar?
def _create_menu_for_menubar(parent)
- #unless (mbar = parent.menu).kind_of?(TkMenu)
- # --> use current TkMenu class
- mbar = parent.menu
- unless mbar.kind_of?(Tk::Menu) || mbar.kind_of?(TkMenu)
- #mbar = Tk::Menu.new(parent, :tearoff=>false)
+ unless (mbar = parent.menu).kind_of?(TkMenu)
mbar = TkMenu.new(parent, :tearoff=>false)
parent.menu(mbar)
end
@@ -195,6 +190,7 @@ module TkMenuSpec
if _use_menubar?(parent)
# menubar by menu entries
+
mbar = _create_menu_for_menubar(parent)
menu_name = nil
@@ -225,8 +221,6 @@ module TkMenuSpec
else
# menubar by menubuttons
- #mbtn = Tk::Menubutton.new(parent)
- # --> use current TkMenubutton class
mbtn = TkMenubutton.new(parent)
menu_name = nil
diff --git a/ext/tk/lib/tk/message.rb b/ext/tk/lib/tk/message.rb
index 946b68c704..79121bebb3 100644
--- a/ext/tk/lib/tk/message.rb
+++ b/ext/tk/lib/tk/message.rb
@@ -4,7 +4,7 @@
require 'tk'
require 'tk/label'
-class Tk::Message<Tk::Label
+class TkMessage<TkLabel
TkCommandNames = ['message'.freeze].freeze
WidgetClassName = 'Message'.freeze
WidgetClassNames[WidgetClassName] = self
@@ -17,6 +17,3 @@ class Tk::Message<Tk::Label
#end
private :create_self
end
-
-#TkMessage = Tk::Message unless Object.const_defined? :TkMessage
-Tk.__set_toplevel_aliases__(:Tk, Tk::Message, :TkMessage)
diff --git a/ext/tk/lib/tk/msgcat.rb b/ext/tk/lib/tk/msgcat.rb
index 162953f425..061e43fd89 100644
--- a/ext/tk/lib/tk/msgcat.rb
+++ b/ext/tk/lib/tk/msgcat.rb
@@ -74,11 +74,7 @@ class TkMsgCatalog < TkObject
"\n---< backtrace of Ruby side >-----\n" +
_toUTF8(e.backtrace.join("\n")) +
"\n---< backtrace of Tk side >-------"
- if TkCore::WITH_ENCODING
- msg.force_encoding('utf-8')
- else
- msg.instance_variable_set(:@encoding, 'utf-8')
- end
+ msg.instance_variable_set(:@encoding, 'utf-8')
rescue Exception
msg = e.class.inspect + ': ' + e.message + "\n" +
"\n---< backtrace of Ruby side >-----\n" +
diff --git a/ext/tk/lib/tk/namespace.rb b/ext/tk/lib/tk/namespace.rb
index 20a8d65215..5bf6474c5b 100644
--- a/ext/tk/lib/tk/namespace.rb
+++ b/ext/tk/lib/tk/namespace.rb
@@ -12,24 +12,17 @@ class TkNamespace < TkObject
].freeze
Tk_Namespace_ID_TBL = TkCore::INTERP.create_table
-
- (Tk_Namespace_ID = ["ns".freeze, "00000".taint]).instance_eval{
- @mutex = Mutex.new
- def mutex; @mutex; end
- freeze
- }
+ Tk_Namespace_ID = ["ns".freeze, "00000".taint].freeze
Tk_NsCode_RetObjID_TBL = TkCore::INTERP.create_table
TkCore::INTERP.init_ip_env{
- Tk_Namespace_ID_TBL.mutex.synchronize{ Tk_Namespace_ID_TBL.clear }
- Tk_NsCode_RetObjID_TBL.mutex.synchronize{ Tk_NsCode_RetObjID_TBL.clear }
+ Tk_Namespace_ID_TBL.clear
+ Tk_NsCode_RetObjID_TBL.clear
}
def TkNamespace.id2obj(id)
- Tk_Namespace_ID_TBL.mutex.synchronize{
- Tk_Namespace_ID_TBL[id]? Tk_Namespace_ID_TBL[id]: id
- }
+ Tk_Namespace_ID_TBL[id]? Tk_Namespace_ID_TBL[id]: id
end
#####################################
@@ -72,27 +65,11 @@ class TkNamespace < TkObject
def cget(slot)
if slot == :namespace || slot == 'namespace'
ns = super(slot)
- Tk_Namespace_ID_TBL.mutex.synchronize{
- if TkNamespace::Tk_Namespace_ID_TBL.key?(ns)
- TkNamespace::Tk_Namespace_ID_TBL[ns]
- else
- ns
- end
- }
- else
- super(slot)
- end
- end
- def cget_strict(slot)
- if slot == :namespace || slot == 'namespace'
- ns = super(slot)
- Tk_Namespace_ID_TBL.mutex.synchronize{
- if TkNamespace::Tk_Namespace_ID_TBL.key?(ns)
- TkNamespace::Tk_Namespace_ID_TBL[ns]
- else
- ns
- end
- }
+ if TkNamespace::Tk_Namespace_ID_TBL.key?(ns)
+ TkNamespace::Tk_Namespace_ID_TBL[ns]
+ else
+ ns
+ end
else
super(slot)
end
@@ -102,11 +79,9 @@ class TkNamespace < TkObject
if slot
if slot == :namespace || slot == 'namespace'
val = super(slot)
- Tk_Namespace_ID_TBL.mutex.synchronize{
- if TkNamespace::Tk_Namespace_ID_TBL.key?(val)
- val = TkNamespace::Tk_Namespace_ID_TBL[val]
- end
- }
+ if TkNamespace::Tk_Namespace_ID_TBL.key?(val)
+ val = TkNamespace::Tk_Namespace_ID_TBL[val]
+ end
else
val = super(slot)
end
@@ -121,23 +96,19 @@ class TkNamespace < TkObject
info = super()
if TkComm::GET_CONFIGINFO_AS_ARRAY
- Tk_Namespace_ID_TBL.mutex.synchronize{
- info.map!{|inf|
- if inf[0] == 'namespace' &&
- TkNamespace::Tk_Namespace_ID_TBL.key?(inf[-1])
- [inf[0], TkNamespace::Tk_Namespace_ID_TBL[inf[-1]]]
- else
- inf
- end
- }
+ info.map!{|inf|
+ if inf[0] == 'namespace' &&
+ TkNamespace::Tk_Namespace_ID_TBL.key?(inf[-1])
+ [inf[0], TkNamespace::Tk_Namespace_ID_TBL[inf[-1]]]
+ else
+ inf
+ end
}
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
val = info['namespace']
- Tk_Namespace_ID_TBL.mutex.synchronize{
- if TkNamespace::Tk_Namespace_ID_TBL.key?(val)
- info['namespace'] = TkNamespace::Tk_Namespace_ID_TBL[val]
- end
- }
+ if TkNamespace::Tk_Namespace_ID_TBL.key?(val)
+ info['namespace'] = TkNamespace::Tk_Namespace_ID_TBL[val]
+ end
end
info
@@ -244,11 +215,9 @@ class TkNamespace < TkObject
def initialize(name = nil, parent = nil)
unless name
- Tk_Namespace_ID.mutex.synchronize{
- # name = Tk_Namespace_ID.join('')
- name = Tk_Namespace_ID.join(TkCore::INTERP._ip_id_)
- Tk_Namespace_ID[1].succ!
- }
+ # name = Tk_Namespace_ID.join('')
+ name = Tk_Namespace_ID.join(TkCore::INTERP._ip_id_)
+ Tk_Namespace_ID[1].succ!
end
name = __tk_call('namespace', 'current') if name == ''
if parent
@@ -283,9 +252,7 @@ class TkNamespace < TkObject
# create namespace
__tk_call('namespace', 'eval', @fullname, '')
- Tk_Namespace_ID_TBL.mutex.synchronize{
- Tk_Namespace_ID_TBL[@fullname] = self
- }
+ Tk_Namespace_ID_TBL[@fullname] = self
end
def self.children(*args)
@@ -293,13 +260,11 @@ class TkNamespace < TkObject
# <pattern> must be glob-style pattern
tk_split_simplelist(tk_call('namespace', 'children', *args)).collect{|ns|
# ns is fullname
- Tk_Namespace_ID_TBL.mutex.synchronize{
- if Tk_Namespace_ID_TBL.key?(ns)
- Tk_Namespace_ID_TBL[ns]
- else
- ns
- end
- }
+ if Tk_Namespace_ID_TBL.key?(ns)
+ Tk_Namespace_ID_TBL[ns]
+ else
+ ns
+ end
}
end
def children(pattern=None)
@@ -325,24 +290,14 @@ class TkNamespace < TkObject
def code(script = Proc.new)
if script.kind_of?(String)
cmd = proc{|*args|
- if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
- obj = ScopeArgs.new(@fullname,*args)
- ret = obj.instance_exec(obj, script)
- else
- ret = ScopeArgs.new(@fullname,*args).instance_eval(script)
- end
+ ret = ScopeArgs.new(@fullname,*args).instance_eval(script)
id = ret.object_id
TkNamespace::Tk_NsCode_RetObjID_TBL[id] = ret
id
}
elsif script.kind_of?(Proc)
cmd = proc{|*args|
- if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
- obj = ScopeArgs.new(@fullname,*args)
- ret = obj.instance_exec(obj, &script)
- else
- ret = ScopeArgs.new(@fullname,*args).instance_eval(&script)
- end
+ ret = ScopeArgs.new(@fullname,*args).instance_eval(&script)
id = ret.object_id
TkNamespace::Tk_NsCode_RetObjID_TBL[id] = ret
id
@@ -364,13 +319,11 @@ class TkNamespace < TkObject
def self.current
ns = self.current_path
- Tk_Namespace_ID_TBL.mutex.synchronize{
- if Tk_Namespace_ID_TBL.key?(ns)
- Tk_Namespace_ID_TBL[ns]
- else
- ns
- end
- }
+ if Tk_Namespace_ID_TBL.key?(ns)
+ Tk_Namespace_ID_TBL[ns]
+ else
+ ns
+ end
end
def current_namespace
# ns_tk_call('namespace', 'current')
@@ -382,13 +335,11 @@ class TkNamespace < TkObject
def self.delete(*ns_list)
tk_call('namespace', 'delete', *ns_list)
ns_list.each{|ns|
- Tk_Namespace_ID_TBL.mutex.synchronize{
- if ns.kind_of?(TkNamespace)
- Tk_Namespace_ID_TBL.delete(ns.path)
- else
- Tk_Namespace_ID_TBL.delete(ns.to_s)
- end
- }
+ if ns.kind_of?(TkNamespace)
+ Tk_Namespace_ID_TBL.delete(ns.path)
+ else
+ Tk_Namespace_ID_TBL.delete(ns.to_s)
+ end
}
end
def delete
@@ -420,7 +371,7 @@ class TkNamespace < TkObject
def self.eval(namespace, cmd = Proc.new, *args)
#tk_call('namespace', 'eval', namespace, cmd, *args)
- TkNamespace.new(namespace).eval(cmd, *args)
+ TkNamespace.new(namespece).eval(cmd, *args)
end
=begin
def eval(cmd = Proc.new, *args)
@@ -493,13 +444,11 @@ class TkNamespace < TkObject
def self.parent(namespace=None)
ns = tk_call('namespace', 'parent', namespace)
- Tk_Namespace_ID_TBL.mutex.synchronize{
- if Tk_Namespace_ID_TBL.key?(ns)
- Tk_Namespace_ID_TBL[ns]
- else
- ns
- end
- }
+ if Tk_Namespace_ID_TBL.key?(ns)
+ Tk_Namespace_ID_TBL[ns]
+ else
+ ns
+ end
end
def parent
tk_call('namespace', 'parent', @fullname)
diff --git a/ext/tk/lib/tk/optiondb.rb b/ext/tk/lib/tk/optiondb.rb
index 186811d37d..a806f3971d 100644
--- a/ext/tk/lib/tk/optiondb.rb
+++ b/ext/tk/lib/tk/optiondb.rb
@@ -8,11 +8,7 @@ module TkOptionDB
extend Tk
TkCommandNames = ['option'.freeze].freeze
- (CmdClassID = ['CMD_CLASS'.freeze, '00000'.taint]).instance_eval{
- @mutex = Mutex.new
- def mutex; @mutex; end
- freeze
- }
+ CmdClassID = ['CMD_CLASS'.freeze, '00000'.taint].freeze
module Priority
WidgetDefault = 20
@@ -254,10 +250,8 @@ module TkOptionDB
def __create_new_class(klass, func, safe = 4, add = false, parent = nil)
if klass.kind_of?(TkWindow)
carrier = klass.path
- CmdClassID.mutex.synchronize{
- klass = CmdClassID.join(TkCore::INTERP._ip_id_)
- CmdClassID[1].succ!
- }
+ klass = CmdClassID.join(TkCore::INTERP._ip_id_)
+ CmdClassID[1].succ!
parent = nil # ignore parent
else
klass = klass.to_s if klass.kind_of?(Symbol)
@@ -318,7 +312,7 @@ module TkOptionDB
:singleton_methods, :remove_const, :remove_method, :undef_method,
:to_s, :inspect, :display, :method, :methods, :respond_to?,
:instance_variable_get, :instance_variable_set, :instance_method,
- :instance_eval, :instance_exec, :instance_variables, :kind_of?, :is_a?,
+ :instance_eval, :instance_variables, :kind_of?, :is_a?,
:private_methods, :protected_methods, :public_methods ].each{|m|
alias_method(m, :__null_method)
}
@@ -368,7 +362,7 @@ module TkOptionDB
def new_proc_class_random(klass, func, safe = 4, add = false, &b)
eval_under_random_base(){
- TkOptionDB.new_proc_class(klass, func, safe, add, self, &b)
+ TkOption.new_proc_class(klass, func, safe, add, self, &b)
}
end
module_function :new_proc_class_random
diff --git a/ext/tk/lib/tk/pack.rb b/ext/tk/lib/tk/pack.rb
index 220a38e524..8fab363121 100644
--- a/ext/tk/lib/tk/pack.rb
+++ b/ext/tk/lib/tk/pack.rb
@@ -9,7 +9,6 @@ module TkPack
TkCommandNames = ['pack'.freeze].freeze
-=begin
def configure(win, *args)
if args[-1].kind_of?(Hash)
opts = args.pop
@@ -30,22 +29,6 @@ module TkPack
}
tk_call_without_enc("pack", 'configure', *params)
end
-=end
- def configure(*args)
- if args[-1].kind_of?(Hash)
- opts = args.pop
- else
- opts = {}
- end
- fail ArgumentError, 'no widget is given' if args.empty?
- params = []
- args.flatten(1).each{|win| params.push(_epath(win))}
- opts.each{|k, v|
- params.push("-#{k}")
- params.push(_epath(v)) # have to use 'epath' (hash_kv() is unavailable)
- }
- tk_call_without_enc("pack", 'configure', *params)
- end
alias pack configure
def forget(*args)
diff --git a/ext/tk/lib/tk/package.rb b/ext/tk/lib/tk/package.rb
index 0c329732f5..d1eb27674d 100644
--- a/ext/tk/lib/tk/package.rb
+++ b/ext/tk/lib/tk/package.rb
@@ -136,8 +136,4 @@ module TkPackage
def vsatisfies(version1, version2)
bool(tk_call('package', 'vsatisfies', version1, version2))
end
-
- def prefer(setting = None)
- tk_call('package', 'prefer', setting)
- end
end
diff --git a/ext/tk/lib/tk/palette.rb b/ext/tk/lib/tk/palette.rb
index 2d08d50f6a..2b6fdf5d90 100644
--- a/ext/tk/lib/tk/palette.rb
+++ b/ext/tk/lib/tk/palette.rb
@@ -15,7 +15,7 @@ module TkPalette
].freeze
def TkPalette.set(*args)
- args = args[0].to_a.flatten if args[0].kind_of? Hash
+ args = args.to_a.flatten if args.kind_of? Hash
tk_call('tk_setPalette', *args)
end
def TkPalette.setPalette(*args)
diff --git a/ext/tk/lib/tk/panedwindow.rb b/ext/tk/lib/tk/panedwindow.rb
index 030144e677..c6cf3cd11f 100644
--- a/ext/tk/lib/tk/panedwindow.rb
+++ b/ext/tk/lib/tk/panedwindow.rb
@@ -3,7 +3,7 @@
#
require 'tk'
-class Tk::PanedWindow<TkWindow
+class TkPanedWindow<TkWindow
TkCommandNames = ['panedwindow'.freeze].freeze
WidgetClassName = 'Panedwindow'.freeze
WidgetClassNames[WidgetClassName] = self
@@ -76,32 +76,11 @@ class Tk::PanedWindow<TkWindow
self
end
- def panecget_strict(win, key)
+ def panecget(win, key)
# win = win.epath if win.kind_of?(TkObject)
win = _epath(win)
tk_tcl2ruby(tk_send_without_enc('panecget', win, "-#{key}"))
end
- def panecget(win, key)
- unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
- panecget_strict(win, key)
- else
- begin
- panecget_strict(win, key)
- rescue => e
- begin
- if current_paneconfiginfo(win).has_key?(option.to_s)
- # not tag error & option is known -> error on known option
- fail e
- else
- # not tag error & option is unknown
- nil
- end
- rescue
- fail e # tag error
- end
- end
- end
- end
def paneconfigure(win, key, value=nil)
# win = win.epath if win.kind_of?(TkObject)
@@ -250,9 +229,4 @@ class Tk::PanedWindow<TkWindow
list(tk_send_without_enc('panes'))
end
end
-
-Tk::Panedwindow = Tk::PanedWindow
-#TkPanedWindow = Tk::PanedWindow unless Object.const_defined? :TkPanedWindow
-#TkPanedwindow = Tk::Panedwindow unless Object.const_defined? :TkPanedwindow
-Tk.__set_toplevel_aliases__(:Tk, Tk::PanedWindow,
- :TkPanedWindow, :TkPanedwindow)
+TkPanedwindow = TkPanedWindow
diff --git a/ext/tk/lib/tk/radiobutton.rb b/ext/tk/lib/tk/radiobutton.rb
index 1f864ec06b..f8f67d709a 100644
--- a/ext/tk/lib/tk/radiobutton.rb
+++ b/ext/tk/lib/tk/radiobutton.rb
@@ -4,7 +4,7 @@
require 'tk'
require 'tk/button'
-class Tk::RadioButton<Tk::Button
+class TkRadioButton<TkButton
TkCommandNames = ['radiobutton'.freeze].freeze
WidgetClassName = 'Radiobutton'.freeze
WidgetClassNames[WidgetClassName] = self
@@ -63,9 +63,4 @@ class Tk::RadioButton<Tk::Button
end
end
end
-
-Tk::Radiobutton = Tk::RadioButton
-#TkRadioButton = Tk::RadioButton unless Object.const_defined? :TkRadioButton
-#TkRadiobutton = Tk::Radiobutton unless Object.const_defined? :TkRadiobutton
-Tk.__set_toplevel_aliases__(:Tk, Tk::RadioButton,
- :TkRadioButton, :TkRadiobutton)
+TkRadiobutton = TkRadioButton
diff --git a/ext/tk/lib/tk/root.rb b/ext/tk/lib/tk/root.rb
index 7237b4c614..0e5584c7c1 100644
--- a/ext/tk/lib/tk/root.rb
+++ b/ext/tk/lib/tk/root.rb
@@ -5,7 +5,7 @@ require 'tk'
require 'tk/wm'
require 'tk/menuspec'
-class Tk::Root<TkWindow
+class TkRoot<TkWindow
include Wm
include TkMenuSpec
@@ -14,7 +14,28 @@ class Tk::Root<TkWindow
end
private :__methodcall_optkeys
- def Root.new(keys=nil, &b)
+=begin
+ ROOT = []
+ def TkRoot.new(keys=nil)
+ if ROOT[0]
+ Tk_WINDOWS["."] = ROOT[0]
+ return ROOT[0]
+ end
+ new = super(:without_creating=>true, :widgetname=>'.')
+ if keys # wm commands
+ keys.each{|k,v|
+ if v.kind_of? Array
+ new.send(k,*v)
+ else
+ new.send(k,v)
+ end
+ }
+ end
+ ROOT[0] = new
+ Tk_WINDOWS["."] = new
+ end
+=end
+ def TkRoot.new(keys=nil, &b)
unless TkCore::INTERP.tk_windows['.']
TkCore::INTERP.tk_windows['.'] =
super(:without_creating=>true, :widgetname=>'.'){}
@@ -41,13 +62,7 @@ class Tk::Root<TkWindow
}
end
- if block_given?
- if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
- root.instance_exec(root, &b)
- else
- root.instance_eval(&b)
- end
- end
+ root.instance_eval(&b) if block_given?
root
end
@@ -87,9 +102,7 @@ class Tk::Root<TkWindow
self.menu
end
- def Root.destroy
+ def TkRoot.destroy
TkCore::INTERP._invoke('destroy', '.')
end
end
-
-TkRoot = Tk::Root unless Object.const_defined? :TkRoot
diff --git a/ext/tk/lib/tk/scale.rb b/ext/tk/lib/tk/scale.rb
index 7e758d92f4..0b703aa055 100644
--- a/ext/tk/lib/tk/scale.rb
+++ b/ext/tk/lib/tk/scale.rb
@@ -3,7 +3,7 @@
#
require 'tk'
-class Tk::Scale<TkWindow
+class TkScale<TkWindow
TkCommandNames = ['scale'.freeze].freeze
WidgetClassName = 'Scale'.freeze
WidgetClassNames[WidgetClassName] = self
@@ -14,31 +14,9 @@ class Tk::Scale<TkWindow
cmd = keys.delete('command')
keys['command'] = proc{|val| cmd.call(val.to_f)}
end
- unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
- #tk_call_without_enc('scale', @path, *hash_kv(keys, true))
- tk_call_without_enc(self.class::TkCommandNames[0], @path,
- *hash_kv(keys, true))
- else
- begin
- tk_call_without_enc(self.class::TkCommandNames[0], @path,
- *hash_kv(keys, true))
- rescue
- tk_call_without_enc(self.class::TkCommandNames[0], @path)
- keys = __check_available_configure_options(keys)
- unless keys.empty?
- begin
- tk_call_without_enc('destroy', @path)
- rescue
- # cannot destroy
- configure(keys)
- else
- # re-create widget
- tk_call_without_enc(self.class::TkCommandNames[0], @path,
- *hash_kv(keys, true))
- end
- end
- end
- end
+ #tk_call_without_enc('scale', @path, *hash_kv(keys, true))
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
else
#tk_call_without_enc('scale', @path)
tk_call_without_enc(self.class::TkCommandNames[0], @path)
@@ -106,6 +84,3 @@ class Tk::Scale<TkWindow
val
end
end
-
-#TkScale = Tk::Scale unless Object.const_defined? :TkScale
-Tk.__set_toplevel_aliases__(:Tk, Tk::Scale, :TkScale)
diff --git a/ext/tk/lib/tk/scrollable.rb b/ext/tk/lib/tk/scrollable.rb
index 96959b7a4b..ec27b76467 100644
--- a/ext/tk/lib/tk/scrollable.rb
+++ b/ext/tk/lib/tk/scrollable.rb
@@ -4,7 +4,7 @@
require 'tk'
module Tk
- module XScrollable
+ module X_Scrollable
def xscrollcommand(cmd=Proc.new)
configure_cmd 'xscrollcommand', cmd
# Tk.update # avoid scrollbar trouble
@@ -38,7 +38,7 @@ module Tk
end
end
- module YScrollable
+ module Y_Scrollable
def yscrollcommand(cmd=Proc.new)
configure_cmd 'yscrollcommand', cmd
# Tk.update # avoid scrollbar trouble
@@ -72,11 +72,8 @@ module Tk
end
end
- X_Scrollable = XScrollable
- Y_Scrollable = YScrollable
-
module Scrollable
- include XScrollable
- include YScrollable
+ include X_Scrollable
+ include Y_Scrollable
end
end
diff --git a/ext/tk/lib/tk/scrollbar.rb b/ext/tk/lib/tk/scrollbar.rb
index 87db46a9f9..70aadfdd4c 100644
--- a/ext/tk/lib/tk/scrollbar.rb
+++ b/ext/tk/lib/tk/scrollbar.rb
@@ -3,7 +3,7 @@
#
require 'tk'
-class Tk::Scrollbar<TkWindow
+class TkScrollbar<TkWindow
TkCommandNames = ['scrollbar'.freeze].freeze
WidgetClassName = 'Scrollbar'.freeze
WidgetClassNames[WidgetClassName] = self
@@ -19,31 +19,9 @@ class Tk::Scrollbar<TkWindow
}
if keys and keys != None
- unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
- #tk_call_without_enc('scrollbar', @path, *hash_kv(keys, true))
- tk_call_without_enc(self.class::TkCommandNames[0], @path,
- *hash_kv(keys, true))
- else
- begin
- tk_call_without_enc(self.class::TkCommandNames[0], @path,
- *hash_kv(keys, true))
- rescue
- tk_call_without_enc(self.class::TkCommandNames[0], @path)
- keys = __check_available_configure_options(keys)
- unless keys.empty?
- begin
- tk_call_without_enc('destroy', @path)
- rescue
- # cannot destroy
- configure(keys)
- else
- # re-create widget
- tk_call_without_enc(self.class::TkCommandNames[0], @path,
- *hash_kv(keys, true))
- end
- end
- end
- end
+ #tk_call_without_enc('scrollbar', @path, *hash_kv(keys, true))
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
else
#tk_call_without_enc('scrollbar', @path)
tk_call_without_enc(self.class::TkCommandNames[0], @path)
@@ -125,33 +103,9 @@ class Tk::Scrollbar<TkWindow
def activate(element=None)
tk_send_without_enc('activate', element)
end
-
- def moveto(fraction)
- tk_send_without_enc('moveto', fraction)
- self
- end
-
- def scroll(*args)
- tk_send_without_enc('scroll', *args)
- self
- end
-
- def scroll_units(num)
- scroll(num, 'units')
- self
- end
-
- def scroll_pages(num)
- scroll(num, 'pages')
- self
- end
end
-#TkScrollbar = Tk::Scrollbar unless Object.const_defined? :TkScrollbar
-Tk.__set_toplevel_aliases__(:Tk, Tk::Scrollbar, :TkScrollbar)
-
-
-class Tk::XScrollbar<Tk::Scrollbar
+class TkXScrollbar<TkScrollbar
def create_self(keys)
keys = {} unless keys
keys['orient'] = 'horizontal'
@@ -160,11 +114,7 @@ class Tk::XScrollbar<Tk::Scrollbar
private :create_self
end
-#TkXScrollbar = Tk::XScrollbar unless Object.const_defined? :TkXScrollbar
-Tk.__set_toplevel_aliases__(:Tk, Tk::XScrollbar, :TkXScrollbar)
-
-
-class Tk::YScrollbar<Tk::Scrollbar
+class TkYScrollbar<TkScrollbar
def create_self(keys)
keys = {} unless keys
keys['orient'] = 'vertical'
@@ -172,6 +122,3 @@ class Tk::YScrollbar<Tk::Scrollbar
end
private :create_self
end
-
-#TkYScrollbar = Tk::YScrollbar unless Object.const_defined? :TkYScrollbar
-Tk.__set_toplevel_aliases__(:Tk, Tk::YScrollbar, :TkYScrollbar)
diff --git a/ext/tk/lib/tk/scrollbox.rb b/ext/tk/lib/tk/scrollbox.rb
index d20742a666..833505be17 100644
--- a/ext/tk/lib/tk/scrollbox.rb
+++ b/ext/tk/lib/tk/scrollbox.rb
@@ -1,19 +1,16 @@
#
# tk/scrollbox.rb - Tk Listbox with Scrollbar
# as an example of Composite Widget
+# $Date: 2004/10/11 04:51:07 $
# by Yukihiro Matsumoto <matz@netlab.co.jp>
#
require 'tk'
require 'tk/listbox'
-class TkScrollbox<Tk::Listbox
+class TkScrollbox<TkListbox
include TkComposite
def initialize_composite(keys=nil)
- #list = Tk::Listbox.new(@frame)
- # -> use current TkListbox class
list = TkListbox.new(@frame)
- #scroll = Tk::Scrollbar.new(@frame)
- # -> use current TkScrollbar class
scroll = TkScrollbar.new(@frame)
@path = list.path
diff --git a/ext/tk/lib/tk/spinbox.rb b/ext/tk/lib/tk/spinbox.rb
index 34dc1904f7..1eed4d1dc4 100644
--- a/ext/tk/lib/tk/spinbox.rb
+++ b/ext/tk/lib/tk/spinbox.rb
@@ -1,11 +1,12 @@
#
# tk/spinbox.rb - Tk spinbox classes
+# $Date: 2005/10/22 22:16:24 $
# by Yukihiro Matsumoto <matz@caelum.co.jp>
#
require 'tk'
require 'tk/entry'
-class Tk::Spinbox<Tk::Entry
+class TkSpinbox<TkEntry
TkCommandNames = ['spinbox'.freeze].freeze
WidgetClassName = 'Spinbox'.freeze
WidgetClassNames[WidgetClassName] = self
@@ -37,24 +38,6 @@ class Tk::Spinbox<Tk::Entry
nil
]
-=begin
- # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
- KEY_TBL.map!{|inf|
- if inf.kind_of?(Array)
- inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
- inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
- end
- inf
- }
-
- PROC_TBL.map!{|inf|
- if inf.kind_of?(Array)
- inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
- end
- inf
- }
-=end
-
_setup_subst_table(KEY_TBL, PROC_TBL);
def self.ret_val(val)
@@ -114,6 +97,3 @@ class Tk::Spinbox<Tk::Entry
_fromUTF8(tk_send_without_enc('set', _get_eval_enc_str(str)))
end
end
-
-#TkSpinbox = Tk::Spinbox unless Object.const_defined? :TkSpinbox
-Tk.__set_toplevel_aliases__(:Tk, Tk::Spinbox, :TkSpinbox)
diff --git a/ext/tk/lib/tk/text.rb b/ext/tk/lib/tk/text.rb
index 4ec82bed1d..0db10a653f 100644
--- a/ext/tk/lib/tk/text.rb
+++ b/ext/tk/lib/tk/text.rb
@@ -1,5 +1,6 @@
#
# tk/text.rb - Tk text classes
+# $Date: 2005/11/23 12:01:05 $
# by Yukihiro Matsumoto <matz@caelum.co.jp>
require 'tk'
require 'tk/itemfont'
@@ -32,40 +33,34 @@ module TkTextTagConfig
def tag_cget(tagOrId, option)
itemcget(['tag', tagOrId], option)
end
- def tag_cget_strict(tagOrId, option)
- itemcget_strict(['tag', tagOrId], option)
- end
def tag_configure(tagOrId, slot, value=None)
itemconfigure(['tag', tagOrId], slot, value)
end
def tag_configinfo(tagOrId, slot=nil)
- itemconfiginfo(['tag', tagOrId], slot)
+ itemconfigure(['tag', tagOrId], slot)
end
def current_tag_configinfo(tagOrId, slot=nil)
- current_itemconfiginfo(['tag', tagOrId], slot)
+ itemconfigure(['tag', tagOrId], slot)
end
def window_cget(tagOrId, option)
itemcget(['window', tagOrId], option)
end
- def window_cget_strict(tagOrId, option)
- itemcget_strict(['window', tagOrId], option)
- end
def window_configure(tagOrId, slot, value=None)
itemconfigure(['window', tagOrId], slot, value)
end
def window_configinfo(tagOrId, slot=nil)
- itemconfiginfo(['window', tagOrId], slot)
+ itemconfigure(['window', tagOrId], slot)
end
def current_window_configinfo(tagOrId, slot=nil)
- current_itemconfiginfo(['window', tagOrId], slot)
+ itemconfigure(['window', tagOrId], slot)
end
- private :itemcget, :itemcget_strict
- private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+ private :itemcget, :itemconfigure
+ private :itemconfiginfo, :current_itemconfiginfo
end
-class Tk::Text<TkTextWin
+class TkText<TkTextWin
ItemConfCMD = ['tag'.freeze, 'configure'.freeze].freeze
#include TkTreatTextTagFont
include TkTextTagConfig
@@ -79,9 +74,9 @@ class Tk::Text<TkTextWin
mod = mod.to_s
if mod =~ /^\s*[+-]?\d/
- Tk::Text::IndexString.new(String.new(id) << ' + ' << mod)
+ TkText::IndexString.new(String.new(id) << ' + ' << mod)
else
- Tk::Text::IndexString.new(String.new(id) << ' ' << mod)
+ TkText::IndexString.new(String.new(id) << ' ' << mod)
end
end
@@ -90,20 +85,20 @@ class Tk::Text<TkTextWin
mod = mod.to_s
if mod =~ /^\s*[+-]?\d/
- Tk::Text::IndexString.new(String.new(id) << ' - ' << mod)
+ TkText::IndexString.new(String.new(id) << ' - ' << mod)
elsif mod =~ /^\s*[-]\s+(\d.*)$/
- Tk::Text::IndexString.new(String.new(id) << ' - -' << $1)
+ TkText::IndexString.new(String.new(id) << ' - -' << $1)
else
- Tk::Text::IndexString.new(String.new(id) << ' ' << mod)
+ TkText::IndexString.new(String.new(id) << ' ' << mod)
end
end
def chars(mod)
fail ArgumentError, 'expect Integer' unless mod.kind_of?(Integer)
if mod < 0
- Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' chars')
+ TkText::IndexString.new(String.new(id) << ' ' << mod.to_s << ' chars')
else
- Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' chars')
+ TkText::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' chars')
end
end
alias char chars
@@ -112,9 +107,9 @@ class Tk::Text<TkTextWin
# Tk8.5 feature
fail ArgumentError, 'expect Integer' unless mod.kind_of?(Integer)
if mod < 0
- Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' display chars')
+ TkText::IndexString.new(String.new(id) << ' ' << mod.to_s << ' display chars')
else
- Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' display chars')
+ TkText::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' display chars')
end
end
alias display_char display_chars
@@ -123,9 +118,9 @@ class Tk::Text<TkTextWin
# Tk8.5 feature
fail ArgumentError, 'expect Integer' unless mod.kind_of?(Integer)
if mod < 0
- Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' any chars')
+ TkText::IndexString.new(String.new(id) << ' ' << mod.to_s << ' any chars')
else
- Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' any chars')
+ TkText::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' any chars')
end
end
alias any_char any_chars
@@ -134,9 +129,9 @@ class Tk::Text<TkTextWin
# Tk8.5 feature
fail ArgumentError, 'expect Integer' unless mod.kind_of?(Integer)
if mod < 0
- Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' indices')
+ TkText::IndexString.new(String.new(id) << ' ' << mod.to_s << ' indices')
else
- Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' indices')
+ TkText::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' indices')
end
end
@@ -144,9 +139,9 @@ class Tk::Text<TkTextWin
# Tk8.5 feature
fail ArgumentError, 'expect Integer' unless mod.kind_of?(Integer)
if mod < 0
- Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' display indices')
+ TkText::IndexString.new(String.new(id) << ' ' << mod.to_s << ' display indices')
else
- Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' display indices')
+ TkText::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' display indices')
end
end
@@ -154,18 +149,18 @@ class Tk::Text<TkTextWin
# Tk8.5 feature
fail ArgumentError, 'expect Integer' unless mod.kind_of?(Integer)
if mod < 0
- Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' any indices')
+ TkText::IndexString.new(String.new(id) << ' ' << mod.to_s << ' any indices')
else
- Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' any indices')
+ TkText::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' any indices')
end
end
def lines(mod)
fail ArgumentError, 'expect Integer' unless mod.kind_of?(Integer)
if mod < 0
- Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' lines')
+ TkText::IndexString.new(String.new(id) << ' ' << mod.to_s << ' lines')
else
- Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' lines')
+ TkText::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' lines')
end
end
alias line lines
@@ -174,9 +169,9 @@ class Tk::Text<TkTextWin
# Tk8.5 feature
fail ArgumentError, 'expect Integer' unless mod.kind_of?(Integer)
if mod < 0
- Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' display_lines')
+ TkText::IndexString.new(String.new(id) << ' ' << mod.to_s << ' display_lines')
else
- Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' display lines')
+ TkText::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' display lines')
end
end
alias display_line display_lines
@@ -185,43 +180,43 @@ class Tk::Text<TkTextWin
# Tk8.5 feature
fail ArgumentError, 'expect Integer' unless mod.kind_of?(Integer)
if mod < 0
- Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' any_lines')
+ TkText::IndexString.new(String.new(id) << ' ' << mod.to_s << ' any_lines')
else
- Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' any lines')
+ TkText::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' any lines')
end
end
alias any_line any_lines
def linestart
- Tk::Text::IndexString.new(String.new(id) << ' linestart')
+ TkText::IndexString.new(String.new(id) << ' linestart')
end
def lineend
- Tk::Text::IndexString.new(String.new(id) << ' lineend')
+ TkText::IndexString.new(String.new(id) << ' lineend')
end
def display_linestart
# Tk8.5 feature
- Tk::Text::IndexString.new(String.new(id) << ' display linestart')
+ TkText::IndexString.new(String.new(id) << ' display linestart')
end
def display_lineend
# Tk8.5 feature
- Tk::Text::IndexString.new(String.new(id) << ' display lineend')
+ TkText::IndexString.new(String.new(id) << ' display lineend')
end
def wordstart
- Tk::Text::IndexString.new(String.new(id) << ' wordstart')
+ TkText::IndexString.new(String.new(id) << ' wordstart')
end
def wordend
- Tk::Text::IndexString.new(String.new(id) << ' wordend')
+ TkText::IndexString.new(String.new(id) << ' wordend')
end
def display_wordstart
# Tk8.5 feature
- Tk::Text::IndexString.new(String.new(id) << ' display wordstart')
+ TkText::IndexString.new(String.new(id) << ' display wordstart')
end
def display_wordend
# Tk8.5 feature
- Tk::Text::IndexString.new(String.new(id) << ' display wordend')
+ TkText::IndexString.new(String.new(id) << ' display wordend')
end
end
@@ -256,11 +251,7 @@ class Tk::Text<TkTextWin
def self.new(*args, &block)
obj = super(*args){}
obj.init_instance_variable
- if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
- obj.instance_exec(obj, &block) if defined? yield
- else
- obj.instance_eval(&block) if defined? yield
- end
+ obj.instance_eval(&block) if defined? yield
obj
end
@@ -270,12 +261,8 @@ class Tk::Text<TkTextWin
end
def __destroy_hook__
- TkTextTag::TTagID_TBL.mutex.synchronize{
- TkTextTag::TTagID_TBL.delete(@path)
- }
- TkTextTag::TMarkID_TBL.mutex.synchronize{
- TkTextMark::TMarkID_TBL.delete(@path)
- }
+ TkTextTag::TTagID_TBL.delete(@path)
+ TkTextMark::TMarkID_TBL.delete(@path)
end
def create_self(keys)
@@ -298,16 +285,16 @@ class Tk::Text<TkTextWin
private :__strval_optkeys
def self.at(x, y)
- Tk::Text::IndexString.at(x, y)
+ TkText::IndexString.at(x, y)
end
def at(x, y)
- Tk::Text::IndexString.at(x, y)
+ TkText::IndexString.at(x, y)
end
def index(idx)
- Tk::Text::IndexString.new(tk_send_without_enc('index',
- _get_eval_enc_str(idx)))
+ TkText::IndexString.new(tk_send_without_enc('index',
+ _get_eval_enc_str(idx)))
end
def get_displaychars(*index)
@@ -409,7 +396,7 @@ class Tk::Text<TkTextWin
end
alias previous_mark mark_previous
- def image_cget_strict(index, slot)
+ def image_cget(index, slot)
case slot.to_s
when 'text', 'label', 'show', 'data', 'file'
_fromUTF8(tk_send_without_enc('image', 'cget',
@@ -421,28 +408,6 @@ class Tk::Text<TkTextWin
end
end
- def image_cget(index, slot)
- unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
- image_cget_strict(index, slot)
- else
- begin
- image_cget_strict(index, slot)
- rescue => e
- begin
- if current_image_configinfo(index).has_key?(slot.to_s)
- # not tag error & option is known -> error on known option
- fail e
- else
- # not tag error & option is unknown
- nil
- end
- rescue
- fail e # tag error
- end
- end
- end
- end
-
def image_configure(index, slot, value=None)
if slot.kind_of?(Hash)
_fromUTF8(tk_send_without_enc('image', 'configure',
@@ -748,17 +713,15 @@ class Tk::Text<TkTextWin
def tag_delete(*tags)
tk_send_without_enc('tag', 'delete',
*(tags.collect{|tag| _get_eval_enc_str(tag)}))
- TkTextTag::TTagID_TBL.mutex.synchronize{
- if TkTextTag::TTagID_TBL[@path]
- tags.each{|tag|
- if tag.kind_of?(TkTextTag)
- TkTextTag::TTagID_TBL[@path].delete(tag.id)
- else
- TkTextTag::TTagID_TBL[@path].delete(tag)
- end
- }
- end
- }
+ if TkTextTag::TTagID_TBL[@path]
+ tags.each{|tag|
+ if tag.kind_of?(TkTextTag)
+ TkTextTag::TTagID_TBL[@path].delete(tag.id)
+ else
+ TkTextTag::TTagID_TBL[@path].delete(tag)
+ end
+ }
+ end
self
end
alias deltag tag_delete
@@ -1005,7 +968,7 @@ class Tk::Text<TkTextWin
false, true)
r = []
while key=l.shift
- r.push [Tk::Text::IndexString.new(key), Tk::Text::IndexString.new(l.shift)]
+ r.push [TkText::IndexString.new(key), TkText::IndexString.new(l.shift)]
end
r
end
@@ -1015,7 +978,7 @@ class Tk::Text<TkTextWin
_get_eval_enc_str(tag),
_get_eval_enc_str(first),
_get_eval_enc_str(last))).collect{|idx|
- Tk::Text::IndexString.new(idx)
+ TkText::IndexString.new(idx)
}
end
@@ -1024,7 +987,7 @@ class Tk::Text<TkTextWin
_get_eval_enc_str(tag),
_get_eval_enc_str(first),
_get_eval_enc_str(last))).collect{|idx|
- Tk::Text::IndexString.new(idx)
+ TkText::IndexString.new(idx)
}
end
@@ -1220,11 +1183,6 @@ class Tk::Text<TkTextWin
end
def _ktext_length(txt)
- if TkCore::WITH_ENCODING ### Ruby 1.9 !!!!!!!!!!!!!
- return txt.length
- end
- ###########################
-
if $KCODE !~ /n/i
return txt.gsub(/[^\Wa-zA-Z_\d]/, ' ').length
end
@@ -1274,7 +1232,7 @@ class Tk::Text<TkTextWin
if ret == ""
nil
else
- Tk::Text::IndexString.new(ret)
+ TkText::IndexString.new(ret)
end
end
@@ -1309,7 +1267,7 @@ class Tk::Text<TkTextWin
if ret == ""
nil
else
- Tk::Text::IndexString.new(ret)
+ TkText::IndexString.new(ret)
end
end
@@ -1498,10 +1456,10 @@ class Tk::Text<TkTextWin
# retrieve index
idx = str.index(/ /, i)
if idx
- result.push(Tk::Text::IndexString.new(str[i..(idx-1)]))
+ result.push(TkText::IndexString.new(str[i..(idx-1)]))
i = idx + 1
else
- result.push(Tk::Text::IndexString.new(str[i..-1]))
+ result.push(TkText::IndexString.new(str[i..-1]))
break
end
end
@@ -1569,17 +1527,13 @@ class Tk::Text<TkTextWin
end
end
-#TkText = Tk::Text unless Object.const_defined? :TkText
-Tk.__set_toplevel_aliases__(:Tk, Tk::Text, :TkText)
-
-
#######################################
-class Tk::Text::Peer < Tk::Text
+class TkText::Peer < TkText
# Tk8.5 feature
def initialize(text, parent=nil, keys={})
- unless text.kind_of?(Tk::Text)
- fail ArgumentError, "Tk::Text is expected for 1st argument"
+ unless text.kind_of?(TkText)
+ fail ArgumentError, "TkText is expected for 1st argument"
end
@src_text = text
super(parent, keys)
diff --git a/ext/tk/lib/tk/textimage.rb b/ext/tk/lib/tk/textimage.rb
index fb306a9c17..a29b23c7dd 100644
--- a/ext/tk/lib/tk/textimage.rb
+++ b/ext/tk/lib/tk/textimage.rb
@@ -5,11 +5,11 @@ require 'tk'
require 'tk/text'
class TkTextImage<TkObject
- include Tk::Text::IndexModMethods
+ include TkText::IndexModMethods
def initialize(parent, index, keys)
- #unless parent.kind_of?(Tk::Text)
- # fail ArgumentError, "expect Tk::Text for 1st argument"
+ #unless parent.kind_of?(TkText)
+ # fail ArgumentError, "expect TkText for 1st argument"
#end
@t = parent
if index == 'end' || index == :end
@@ -34,7 +34,7 @@ class TkTextImage<TkObject
end
def id
- Tk::Text::IndexString.new(@id)
+ TkText::IndexString.new(@id)
end
def mark
@path
@@ -52,10 +52,6 @@ class TkTextImage<TkObject
@t.image_cget(@index, slot)
end
- def cget_strict(slot)
- @t.image_cget_strict(@index, slot)
- end
-
def configure(slot, value=None)
@t.image_configure(@index, slot, value)
self
@@ -84,5 +80,3 @@ class TkTextImage<TkObject
value
end
end
-
-TktImage = TkTextImage
diff --git a/ext/tk/lib/tk/textmark.rb b/ext/tk/lib/tk/textmark.rb
index 72c1ce1ab4..650d95af70 100644
--- a/ext/tk/lib/tk/textmark.rb
+++ b/ext/tk/lib/tk/textmark.rb
@@ -5,54 +5,38 @@ require 'tk'
require 'tk/text'
class TkTextMark<TkObject
- include Tk::Text::IndexModMethods
+ include TkText::IndexModMethods
TMarkID_TBL = TkCore::INTERP.create_table
+ Tk_TextMark_ID = ['mark'.freeze, '00000'.taint].freeze
- (Tk_TextMark_ID = ['mark'.freeze, '00000'.taint]).instance_eval{
- @mutex = Mutex.new
- def mutex; @mutex; end
- freeze
- }
-
- TkCore::INTERP.init_ip_env{
- TMarkID_TBL.mutex.synchronize{ TMarkID_TBL.clear }
- }
+ TkCore::INTERP.init_ip_env{ TMarkID_TBL.clear }
def TkTextMark.id2obj(text, id)
tpath = text.path
- TMarkID_TBL.mutex.synchronize{
- if TMarkID_TBL[tpath]
- TMarkID_TBL[tpath][id]? TMarkID_TBL[tpath][id]: id
- else
- id
- end
- }
+ return id unless TMarkID_TBL[tpath]
+ TMarkID_TBL[tpath][id]? TMarkID_TBL[tpath][id]: id
end
def initialize(parent, index)
- #unless parent.kind_of?(Tk::Text)
- # fail ArgumentError, "expect Tk::Text for 1st argument"
+ #unless parent.kind_of?(TkText)
+ # fail ArgumentError, "expect TkText for 1st argument"
#end
@parent = @t = parent
@tpath = parent.path
- Tk_TextMark_ID.mutex.synchronize{
- # @path = @id = Tk_TextMark_ID.join('')
- @path = @id = Tk_TextMark_ID.join(TkCore::INTERP._ip_id_).freeze
- Tk_TextMark_ID[1].succ!
- }
- TMarkID_TBL.mutex.synchronize{
- TMarkID_TBL[@id] = self
- TMarkID_TBL[@tpath] = {} unless TMarkID_TBL[@tpath]
- TMarkID_TBL[@tpath][@id] = self
- }
+ # @path = @id = Tk_TextMark_ID.join('')
+ @path = @id = Tk_TextMark_ID.join(TkCore::INTERP._ip_id_).freeze
+ TMarkID_TBL[@id] = self
+ TMarkID_TBL[@tpath] = {} unless TMarkID_TBL[@tpath]
+ TMarkID_TBL[@tpath][@id] = self
+ Tk_TextMark_ID[1].succ!
tk_call_without_enc(@t.path, 'mark', 'set', @id,
_get_eval_enc_str(index))
@t._addtag id, self
end
def id
- Tk::Text::IndexString.new(@id)
+ TkText::IndexString.new(@id)
end
def exist?
@@ -65,15 +49,15 @@ class TkTextMark<TkObject
end
=begin
- # move to Tk::Text::IndexModMethods module
+ # move to TkText::IndexModMethods module
def +(mod)
return chars(mod) if mod.kind_of?(Numeric)
mod = mod.to_s
if mod =~ /^\s*[+-]?\d/
- Tk::Text::IndexString.new(@id + ' + ' + mod)
+ TkText::IndexString.new(@id + ' + ' + mod)
else
- Tk::Text::IndexString.new(@id + ' ' + mod)
+ TkText::IndexString.new(@id + ' ' + mod)
end
end
@@ -82,11 +66,11 @@ class TkTextMark<TkObject
mod = mod.to_s
if mod =~ /^\s*[+-]?\d/
- Tk::Text::IndexString.new(@id + ' - ' + mod)
+ TkText::IndexString.new(@id + ' - ' + mod)
elsif mod =~ /^\s*[-]\s+(\d.*)$/
- Tk::Text::IndexString.new(@id + ' - -' + $1)
+ TkText::IndexString.new(@id + ' - -' + $1)
else
- Tk::Text::IndexString.new(@id + ' ' + mod)
+ TkText::IndexString.new(@id + ' ' + mod)
end
end
=end
@@ -137,68 +121,46 @@ class TkTextMark<TkObject
end
end
end
-TktMark = TkTextMark
class TkTextNamedMark<TkTextMark
- def self.new(parent, name, index=nil)
- TMarkID_TBL.mutex.synchronize{
- if TMarkID_TBL[parent.path] && TMarkID_TBL[parent.path][name]
- obj = TMarkID_TBL[parent.path][name]
- else
- # super(parent, name, *args)
- (obj = self.allocate).instance_eval{
- @parent = @t = parent
- @tpath = parent.path
- @path = @id = name
- TMarkID_TBL[@id] = self
- TMarkID_TBL[@tpath] = {} unless TMarkID_TBL[@tpath]
- TMarkID_TBL[@tpath][@id] = self unless TMarkID_TBL[@tpath][@id]
- @t._addtag @id, self
- }
- obj
- end
-
- if obj && index
- tk_call_without_enc(parent.path, 'mark', 'set', name,
- _get_eval_enc_str(index))
- end
- obj
- }
+ def self.new(parent, name, *args)
+ if TMarkID_TBL[parent.path] && TMarkID_TBL[parent.path][name]
+ return TMarkID_TBL[parent.path][name]
+ else
+ super(parent, name, *args)
+ end
end
def initialize(parent, name, index=nil)
- # dummy:: not called by 'new' method
-
- #unless parent.kind_of?(Tk::Text)
- # fail ArgumentError, "expect Tk::Text for 1st argument"
+ #unless parent.kind_of?(TkText)
+ # fail ArgumentError, "expect TkText for 1st argument"
#end
@parent = @t = parent
@tpath = parent.path
@path = @id = name
+ TMarkID_TBL[@id] = self
+ TMarkID_TBL[@tpath] = {} unless TMarkID_TBL[@tpath]
+ TMarkID_TBL[@tpath][@id] = self unless TMarkID_TBL[@tpath][@id]
tk_call_without_enc(@t.path, 'mark', 'set', @id,
_get_eval_enc_str(index)) if index
- @t._addtag @id, self
+ @t._addtag id, self
end
end
-TktNamedMark = TkTextNamedMark
class TkTextMarkInsert<TkTextNamedMark
def self.new(parent,*args)
super(parent, 'insert', *args)
end
end
-TktMarkInsert = TkTextMarkInsert
class TkTextMarkCurrent<TkTextNamedMark
def self.new(parent,*args)
super(parent, 'current', *args)
end
end
-TktMarkCurrent = TkTextMarkCurrent
class TkTextMarkAnchor<TkTextNamedMark
def self.new(parent,*args)
super(parent, 'anchor', *args)
end
end
-TktMarkAnchor = TkTextMarkAnchor
diff --git a/ext/tk/lib/tk/texttag.rb b/ext/tk/lib/tk/texttag.rb
index b08d923ea1..cc2c56210f 100644
--- a/ext/tk/lib/tk/texttag.rb
+++ b/ext/tk/lib/tk/texttag.rb
@@ -7,29 +7,17 @@ require 'tk/tagfont'
class TkTextTag<TkObject
include TkTreatTagFont
- include Tk::Text::IndexModMethods
+ include TkText::IndexModMethods
TTagID_TBL = TkCore::INTERP.create_table
+ Tk_TextTag_ID = ['tag'.freeze, '00000'.taint].freeze
- (Tk_TextTag_ID = ['tag'.freeze, '00000'.taint]).instance_eval{
- @mutex = Mutex.new
- def mutex; @mutex; end
- freeze
- }
-
- TkCore::INTERP.init_ip_env{
- TTagID_TBL.mutex.synchronize{ TTagID_TBL.clear }
- }
+ TkCore::INTERP.init_ip_env{ TTagID_TBL.clear }
def TkTextTag.id2obj(text, id)
tpath = text.path
- TTagID_TBL.mutex.synchronize{
- if TTagID_TBL[tpath]
- TTagID_TBL[tpath][id]? TTagID_TBL[tpath][id]: id
- else
- id
- end
- }
+ return id unless TTagID_TBL[tpath]
+ TTagID_TBL[tpath][id]? TTagID_TBL[tpath][id]: id
end
def initialize(parent, *args)
@@ -38,16 +26,12 @@ class TkTextTag<TkObject
#end
@parent = @t = parent
@tpath = parent.path
- Tk_TextTag_ID.mutex.synchronize{
- # @path = @id = Tk_TextTag_ID.join('')
- @path = @id = Tk_TextTag_ID.join(TkCore::INTERP._ip_id_).freeze
- Tk_TextTag_ID[1].succ!
- }
- TTagID_TBL.mutex.synchronize{
- TTagID_TBL[@id] = self
- TTagID_TBL[@tpath] = {} unless TTagID_TBL[@tpath]
- TTagID_TBL[@tpath][@id] = self
- }
+ # @path = @id = Tk_TextTag_ID.join('')
+ @path = @id = Tk_TextTag_ID.join(TkCore::INTERP._ip_id_).freeze
+ # TTagID_TBL[@id] = self
+ TTagID_TBL[@tpath] = {} unless TTagID_TBL[@tpath]
+ TTagID_TBL[@tpath][@id] = self
+ Tk_TextTag_ID[1].succ!
#tk_call @t.path, "tag", "configure", @id, *hash_kv(keys)
if args != []
keys = args.pop
@@ -63,7 +47,7 @@ class TkTextTag<TkObject
end
def id
- Tk::Text::IndexString.new(@id)
+ TkText::IndexString.new(@id)
end
def exist?
@@ -76,11 +60,11 @@ class TkTextTag<TkObject
end
def first
- Tk::Text::IndexString.new(@id + '.first')
+ TkText::IndexString.new(@id + '.first')
end
def last
- Tk::Text::IndexString.new(@id + '.last')
+ TkText::IndexString.new(@id + '.last')
end
def add(*indices)
@@ -99,7 +83,7 @@ class TkTextTag<TkObject
l = tk_split_simplelist(tk_call_without_enc(@t.path, 'tag', 'ranges', @id))
r = []
while key=l.shift
- r.push [Tk::Text::IndexString.new(key), Tk::Text::IndexString.new(l.shift)]
+ r.push [TkText::IndexString.new(key), TkText::IndexString.new(l.shift)]
end
r
end
@@ -108,7 +92,7 @@ class TkTextTag<TkObject
simplelist(tk_call_without_enc(@t.path, 'tag', 'nextrange', @id,
_get_eval_enc_str(first),
_get_eval_enc_str(last))).collect{|idx|
- Tk::Text::IndexString.new(idx)
+ TkText::IndexString.new(idx)
}
end
@@ -116,7 +100,7 @@ class TkTextTag<TkObject
simplelist(tk_call_without_enc(@t.path, 'tag', 'prevrange', @id,
_get_eval_enc_str(first),
_get_eval_enc_str(last))).collect{|idx|
- Tk::Text::IndexString.new(idx)
+ TkText::IndexString.new(idx)
}
end
@@ -132,9 +116,6 @@ class TkTextTag<TkObject
def cget(key)
@t.tag_cget @id, key
end
- def cget_strict(key)
- @t.tag_cget_strict @id, key
- end
=begin
def cget(key)
case key.to_s
@@ -240,58 +221,40 @@ class TkTextTag<TkObject
def destroy
tk_call_without_enc(@t.path, 'tag', 'delete', @id)
- TTagID_TBL.mutex.synchronize{
- TTagID_TBL[@tpath].delete(@id) if TTagID_TBL[@tpath]
- }
+ TTagID_TBL[@tpath].delete(@id) if TTagID_TBL[@tpath]
self
end
end
-TktTag = TkTextTag
class TkTextNamedTag<TkTextTag
def self.new(parent, name, *args)
- tagobj = nil
- TTagID_TBL.mutex.synchronize{
- if TTagID_TBL[parent.path] && TTagID_TBL[parent.path][name]
- tagobj = TTagID_TBL[parent.path][name]
- else
- # super(parent, name, *args)
- (tagobj = self.allocate).instance_eval{
- @parent = @t = parent
- @tpath = parent.path
- @path = @id = name
- TTagID_TBL[@id] = self
- TTagID_TBL[@tpath] = {} unless TTagID_TBL[@tpath]
- TTagID_TBL[@tpath][@id] = self unless TTagID_TBL[@tpath][@id]
- @t._addtag @id, self
- }
- end
- }
-
- if args != []
- keys = args.pop
- if keys.kind_of?(Hash)
- tagobj.add(*args) if args != []
- tagobj.configure(keys)
- else
- args.push keys
- tagobj.add(*args)
+ if TTagID_TBL[parent.path] && TTagID_TBL[parent.path][name]
+ tagobj = TTagID_TBL[parent.path][name]
+ if args != []
+ keys = args.pop
+ if keys.kind_of?(Hash)
+ tagobj.add(*args) if args != []
+ tagobj.configure(keys)
+ else
+ args.push keys
+ tagobj.add(*args)
+ end
end
+ return tagobj
+ else
+ super(parent, name, *args)
end
-
- tagobj
end
def initialize(parent, name, *args)
- # dummy:: not called by 'new' method
-
- #unless parent.kind_of?(Tk::Text)
- # fail ArgumentError, "expect Tk::Text for 1st argument"
+ #unless parent.kind_of?(TkText)
+ # fail ArgumentError, "expect TkText for 1st argument"
#end
@parent = @t = parent
@tpath = parent.path
@path = @id = name
-
+ TTagID_TBL[@tpath] = {} unless TTagID_TBL[@tpath]
+ TTagID_TBL[@tpath][@id] = self unless TTagID_TBL[@tpath][@id]
#if mode
# tk_call @t.path, "addtag", @id, *args
#end
@@ -305,14 +268,12 @@ class TkTextNamedTag<TkTextTag
add(*args)
end
end
- @t._addtag @id, self
+ @t._addtag id, self
end
end
-TktNamedTag = TkTextNamedTag
class TkTextTagSel<TkTextNamedTag
def self.new(parent, *args)
super(parent, 'sel', *args)
end
end
-TktTagSel = TkTextTagSel
diff --git a/ext/tk/lib/tk/textwindow.rb b/ext/tk/lib/tk/textwindow.rb
index 004422e4f3..605c40addd 100644
--- a/ext/tk/lib/tk/textwindow.rb
+++ b/ext/tk/lib/tk/textwindow.rb
@@ -5,11 +5,11 @@ require 'tk'
require 'tk/text'
class TkTextWindow<TkObject
- include Tk::Text::IndexModMethods
+ include TkText::IndexModMethods
def initialize(parent, index, keys = {})
- #unless parent.kind_of?(Tk::Text)
- # fail ArgumentError, "expect Tk::Text for 1st argument"
+ #unless parent.kind_of?(TkText)
+ # fail ArgumentError, "expect TkText for 1st argument"
#end
@t = parent
if index == 'end' || index == :end
@@ -55,7 +55,7 @@ class TkTextWindow<TkObject
end
def id
- Tk::Text::IndexString.new(_epath(@id))
+ TkText::IndexString.new(_epath(@id))
end
def mark
@path
@@ -72,9 +72,6 @@ class TkTextWindow<TkObject
def cget(slot)
@t.window_cget(@index, slot)
end
- def cget_strict(slot)
- @t.window_cget_strict(@index, slot)
- end
def configure(slot, value=None)
if slot.kind_of?(Hash)
@@ -150,5 +147,3 @@ class TkTextWindow<TkObject
value
end
end
-
-TktWindow = TkTextWindow
diff --git a/ext/tk/lib/tk/timer.rb b/ext/tk/lib/tk/timer.rb
index 91840d0575..49b7f1b06a 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$
+# $Id: timer.rb,v 1.1.2.15 2005/05/08 14:20:53 nagai Exp $
#
require 'tk'
@@ -11,12 +11,7 @@ class TkTimer
TkCommandNames = ['after'.freeze].freeze
- (Tk_CBID = ['a'.freeze, '00000'.taint]).instance_eval{
- @mutex = Mutex.new
- def mutex; @mutex; end
- freeze
- }
-
+ Tk_CBID = ['a'.freeze, '00000'.taint].freeze
Tk_CBTBL = {}.taint
TkCore::INTERP.add_tk_procs('rb_after', 'id', <<-'EOL')
@@ -101,9 +96,9 @@ class TkTimer
return self
end
@after_script = "rb_after #{@id}"
+ @after_id = tk_call_without_enc('after', sleep, @after_script)
@current_args = args
@current_script = [sleep, @after_script]
- @after_id = tk_call_without_enc('after', sleep, @after_script)
self
end
@@ -111,8 +106,7 @@ class TkTimer
if @running == false || @proc_max == 0 || @do_loop == 0
Tk_CBTBL.delete(@id) ;# for GC
@running = false
- # @wait_var.value = 0
- __at_end__
+ @wait_var.value = 0
return
end
if @current_pos >= @proc_max
@@ -121,8 +115,7 @@ class TkTimer
else
Tk_CBTBL.delete(@id) ;# for GC
@running = false
- # @wait_var.value = 0
- __at_end__
+ @wait_var.value = 0
return
end
end
@@ -145,16 +138,12 @@ class TkTimer
end
def initialize(*args, &b)
- Tk_CBID.mutex.synchronize{
- # @id = Tk_CBID.join('')
- @id = Tk_CBID.join(TkCore::INTERP._ip_id_)
- Tk_CBID[1].succ!
- }
+ # @id = Tk_CBID.join('')
+ @id = Tk_CBID.join(TkCore::INTERP._ip_id_)
+ Tk_CBID[1].succ!
@wait_var = TkVariable.new(0)
- @at_end_proc = nil
-
@cb_cmd = TkCore::INTERP.get_cb_entry(self.method(:do_callback))
@set_next = true
@@ -214,12 +203,6 @@ class TkTimer
attr_accessor :loop_exec
- def __at_end__
- @at_end_proc.call(self) if @at_end_proc
- @wait_var.value = 0 # for wait
- end
- private :__at_end__
-
def cb_call
@cb_cmd.call
end
@@ -437,8 +420,7 @@ class TkTimer
def cancel
@running = false
- # @wait_var.value = 0
- __at_end__
+ @wait_var.value = 0
tk_call 'after', 'cancel', @after_id if @after_id
@after_id = nil
@@ -482,21 +464,6 @@ class TkTimer
end
end
- def at_end(*arg, &b)
- if arg.empty?
- if b
- @at_end_proc = b
- else
- # no proc
- return @at_end_proc
- end
- else
- fail ArgumentError, "wrong number of arguments" if arg.length != 1 || b
- @at_end_proc = arg[0]
- end
- self
- end
-
def wait(on_thread = true, check_root = false)
if $SAFE >= 4
fail SecurityError, "can't wait timer at $SAFE >= 4"
@@ -595,8 +562,7 @@ class TkRTTimer < TkTimer
if @running == false || @proc_max == 0 || @do_loop == 0
Tk_CBTBL.delete(@id) ;# for GC
@running = false
- # @wait_var.value = 0
- __at_end__
+ @wait_var.value = 0
return
end
if @current_pos >= @proc_max
@@ -605,8 +571,7 @@ class TkRTTimer < TkTimer
else
Tk_CBTBL.delete(@id) ;# for GC
@running = false
- # @wait_var.value = 0
- __at_end__
+ @wait_var.value = 0
return
end
end
diff --git a/ext/tk/lib/tk/toplevel.rb b/ext/tk/lib/tk/toplevel.rb
index bd6e8307f5..5e199e1330 100644
--- a/ext/tk/lib/tk/toplevel.rb
+++ b/ext/tk/lib/tk/toplevel.rb
@@ -5,7 +5,7 @@ require 'tk'
require 'tk/wm'
require 'tk/menuspec'
-class Tk::Toplevel<TkWindow
+class TkToplevel<TkWindow
include Wm
include TkMenuSpec
@@ -72,7 +72,7 @@ class Tk::Toplevel<TkWindow
conf_methods = _symbolkey2str(__methodcall_optkeys())
- keys.each{|k,v| # k is a String
+ keys.each{|k,v|
if conf_methods.key?(k)
wm_cmds[conf_methods[k]] = v
elsif Wm.method_defined?(k)
@@ -117,10 +117,9 @@ class Tk::Toplevel<TkWindow
end
if @classname.kind_of? TkBindTag
@db_class = @classname
- keys['class'] = @classname = @classname.id
+ @classname = @classname.id
elsif @classname
@db_class = TkDatabaseClass.new(@classname)
- keys['class'] = @classname
else
@db_class = self.class
@classname = @db_class::WidgetClassName
@@ -166,10 +165,9 @@ class Tk::Toplevel<TkWindow
end
if @classname.kind_of? TkBindTag
@db_class = @classname
- keys['class'] = @classname = @classname.id
+ @classname = @classname.id
elsif @classname
@db_class = TkDatabaseClass.new(@classname)
- keys['class'] = @classname
else
@db_class = self.class
@classname = @db_class::WidgetClassName
@@ -257,6 +255,3 @@ class Tk::Toplevel<TkWindow
end
end
end
-
-#TkToplevel = Tk::Toplevel unless Object.const_defined? :TkToplevel
-Tk.__set_toplevel_aliases__(:Tk, Tk::Toplevel, :TkToplevel)
diff --git a/ext/tk/lib/tk/ttk_selector.rb b/ext/tk/lib/tk/ttk_selector.rb
deleted file mode 100644
index 72ed637a38..0000000000
--- a/ext/tk/lib/tk/ttk_selector.rb
+++ /dev/null
@@ -1,76 +0,0 @@
-#
-# ttk_selector
-#
-######################################
-# toplevel classes/modules
-module Tk
- @TOPLEVEL_ALIAS_TABLE[:Ttk] = {
- :TkButton => 'tkextlib/tile/tbutton',
-
- :TkCheckbutton => 'tkextlib/tile/tcheckbutton',
- :TkCheckButton => 'tkextlib/tile/tcheckbutton',
-
- # :TkDialog => 'tkextlib/tile/dialog',
-
- :TkEntry => 'tkextlib/tile/tentry',
-
- :TkCombobox => 'tkextlib/tile/tcombobox',
-
- :TkFrame => 'tkextlib/tile/tframe',
-
- :TkLabel => 'tkextlib/tile/tlabel',
-
- :TkLabelframe => 'tkextlib/tile/tlabelframe',
- :TkLabelFrame => 'tkextlib/tile/tlabelframe',
-
- :TkMenubutton => 'tkextlib/tile/tmenubutton',
- :TkMenuButton => 'tkextlib/tile/tmenubutton',
-
- :TkNotebook => 'tkextlib/tile/tnotebook',
-
- # :TkPaned => 'tkextlib/tile/tpaned',
- :TkPanedwindow => 'tkextlib/tile/tpaned',
- :TkPanedWindow => 'tkextlib/tile/tpaned',
-
- :TkProgressbar => 'tkextlib/tile/tprogressbar',
-
- :TkRadiobutton => 'tkextlib/tile/tradiobutton',
- :TkRadioButton => 'tkextlib/tile/tradiobutton',
-
- :TkScale => 'tkextlib/tile/tscale',
- # :TkProgress => 'tkextlib/tile/tscale',
-
- :TkScrollbar => 'tkextlib/tile/tscrollbar',
- :TkXScrollbar => 'tkextlib/tile/tscrollbar',
- :TkYScrollbar => 'tkextlib/tile/tscrollbar',
-
- :TkSeparator => 'tkextlib/tile/tseparator',
-
- :TkSizeGrip => 'tkextlib/tile/sizegrip',
- :TkSizegrip => 'tkextlib/tile/sizegrip',
-
- # :TkSquare => 'tkextlib/tile/tsquare',
-
- :TkTreeview => 'tkextlib/tile/treeview',
- }
- @TOPLEVEL_ALIAS_TABLE[:Tile] = @TOPLEVEL_ALIAS_TABLE[:Ttk]
-
- ################################################
- # register some Ttk widgets as default
- # (Ttk is a standard library on Tcl/Tk8.5+)
- @TOPLEVEL_ALIAS_TABLE[:Ttk].each{|sym, file|
- unless Object.autoload?(sym) || Object.const_defined?(sym)
- Object.autoload(sym, file)
- end
- }
-
- ################################################
-
- @TOPLEVEL_ALIAS_SETUP_PROC[:Tile] =
- @TOPLEVEL_ALIAS_SETUP_PROC[:Ttk] = proc{|mod|
- unless Tk.autoload?(:Tile) || Tk.const_defined?(:Tile)
- Object.autoload :Ttk, 'tkextlib/tile'
- Tk.autoload :Tile, 'tkextlib/tile'
- end
- }
-end
diff --git a/ext/tk/lib/tk/txtwin_abst.rb b/ext/tk/lib/tk/txtwin_abst.rb
index 540f806d17..5520360eab 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
- TkCommandNames = [].freeze
+ TkCommnadNames = [].freeze
#def create_self
# fail RuntimeError, "TkTextWin is an abstract class"
#end
diff --git a/ext/tk/lib/tk/validation.rb b/ext/tk/lib/tk/validation.rb
index 60bd433cdc..0c5b5c61b9 100644
--- a/ext/tk/lib/tk/validation.rb
+++ b/ext/tk/lib/tk/validation.rb
@@ -50,8 +50,7 @@ module Tk
key2class.each{|key, klass|
if keys[key].kind_of?(Array)
cmd, *args = keys[key]
- #keys[key] = klass.new(cmd, args.join(' '))
- keys[key] = klass.new(cmd, *args)
+ keys[key] = klass.new(cmd, args.join(' '))
# elsif keys[key].kind_of?(Proc) || keys[key].kind_of?(Method)
elsif TkComm._callback_entry?(keys[key])
keys[key] = klass.new(keys[key])
@@ -152,8 +151,7 @@ module Tk
key2class.each{|key, klass|
if keys[key].kind_of?(Array)
cmd, *args = keys[key]
- #keys[key] = klass.new(cmd, args.join(' '))
- keys[key] = klass.new(cmd, *args)
+ keys[key] = klass.new(cmd, args.join(' '))
# elsif keys[key].kind_of?(Proc) || keys[key].kind_of?(Method)
elsif TkComm._callback_entry?(keys[key])
keys[key] = klass.new(keys[key])
@@ -251,24 +249,6 @@ class TkValidateCommand
nil
]
-=begin
- # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
- KEY_TBL.map!{|inf|
- if inf.kind_of?(Array)
- inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
- inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
- end
- inf
- }
-
- PROC_TBL.map!{|inf|
- if inf.kind_of?(Array)
- inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
- end
- inf
- }
-=end
-
_setup_subst_table(KEY_TBL, PROC_TBL);
#
@@ -297,7 +277,6 @@ class TkValidateCommand
extra_args_tbl = klass._get_extra_args_tbl
if args.compact.size > 0
- args.map!{|arg| klass._sym2subst(arg)}
args = args.join(' ')
keys = klass._get_subst_key(args)
if cmd.kind_of?(String)
diff --git a/ext/tk/lib/tk/variable.rb b/ext/tk/lib/tk/variable.rb
index f738a96ee7..e5cacadc1a 100644
--- a/ext/tk/lib/tk/variable.rb
+++ b/ext/tk/lib/tk/variable.rb
@@ -16,22 +16,11 @@ class TkVariable
#TkVar_ID_TBL = {}
TkVar_CB_TBL = TkCore::INTERP.create_table
TkVar_ID_TBL = TkCore::INTERP.create_table
- (Tk_VARIABLE_ID = ["v".freeze, "00000".taint]).instance_eval{
- @mutex = Mutex.new
- def mutex; @mutex; end
- freeze
- }
- TkCore::INTERP.init_ip_env{
- TkVar_CB_TBL.mutex.synchronize{ TkVar_CB_TBL.clear }
- TkVar_ID_TBL.mutex.synchronize{ TkVar_ID_TBL.clear }
- }
-
- major, minor, type, type_name, patchlevel = TclTkLib.get_version
- USE_OLD_TRACE_OPTION_STYLE = (major < 8) || (major == 8 && minor < 4)
+ Tk_VARIABLE_ID = ["v".freeze, "00000".taint].freeze
#TkCore::INTERP.add_tk_procs('rb_var', 'args',
# "ruby [format \"TkVariable.callback %%Q!%s!\" $args]")
- TkCore::INTERP.add_tk_procs('rb_var', 'args', <<-'EOL')
+TkCore::INTERP.add_tk_procs('rb_var', 'args', <<-'EOL')
if {[set st [catch {eval {ruby_cmd TkVariable callback} $args} ret]] != 0} {
set idx [string first "\n\n" $ret]
if {$idx > 0} {
@@ -55,10 +44,10 @@ class TkVariable
def TkVariable.callback(id, name1, name2, op)
#name1,name2,op = tk_split_list(args)
#name1,name2,op = tk_split_simplelist(args)
- if cb_obj = TkVar_CB_TBL[id]
+ if TkVar_CB_TBL[id]
#_get_eval_string(TkVar_CB_TBL[name1].trace_callback(name2,op))
begin
- _get_eval_string(cb_obj.trace_callback(name2, op))
+ _get_eval_string(TkVar_CB_TBL[id].trace_callback(name2, op))
rescue SystemExit
exit(0)
rescue Interrupt
@@ -70,11 +59,7 @@ class TkVariable
"\n---< backtrace of Ruby side >-----\n" +
_toUTF8(e.backtrace.join("\n")) +
"\n---< backtrace of Tk side >-------"
- if TkCore::WITH_ENCODING
- msg.force_encoding('utf-8')
- else
- msg.instance_variable_set(:@encoding, 'utf-8')
- end
+ msg.instance_variable_set(:@encoding, 'utf-8')
rescue Exception
msg = e.class.inspect + ': ' + e.message + "\n" +
"\n---< backtrace of Ruby side >-----\n" +
@@ -282,15 +267,11 @@ class TkVariable
def initialize(val="", type=nil)
# @id = Tk_VARIABLE_ID.join('')
begin
- Tk_VARIABLE_ID.mutex.synchronize{
- @id = Tk_VARIABLE_ID.join(TkCore::INTERP._ip_id_)
- Tk_VARIABLE_ID[1].succ!
- }
+ @id = Tk_VARIABLE_ID.join(TkCore::INTERP._ip_id_)
+ Tk_VARIABLE_ID[1].succ!
end until INTERP._invoke_without_enc('info', 'globals', @id).empty?
- TkVar_ID_TBL.mutex.synchronize{
- TkVar_ID_TBL[@id] = self
- }
+ TkVar_ID_TBL[@id] = self
@var = @id
@elem = nil
@@ -1282,101 +1263,56 @@ end
end
end
- def _check_trace_opt(opts)
- if opts.kind_of?(Array)
- opt_str = opts.map{|s| s.to_s}.join(' ')
- else
- opt_str = opts.to_s
- end
-
- fail ArgumentError, 'null trace option' if opt_str.empty?
-
- if opt_str =~ /[^arwu\s]/
- # new format (Tcl/Tk8.4+?)
- if opts.kind_of?(Array)
- opt_ary = opts.map{|opt| opt.to_s.strip}
- else
- opt_ary = opt_str.split(/\s+|\|/)
- opt_ary.delete('')
- end
- if USE_OLD_TRACE_OPTION_STYLE
- opt_ary.uniq.map{|opt|
- case opt
- when 'array'
- 'a'
- when 'read'
- 'r'
- when 'write'
- 'w'
- when 'unset'
- 'u'
- else
- fail ArgumentError, "unsupported trace option '#{opt}' on Tcl/Tk#{Tk::TCL_PATCHLEVEL}"
- end
- }.join
- else
- opt_ary
- end
- else
- # old format
- opt_ary = opt_str.delete('^arwu').split(//).uniq
- if USE_OLD_TRACE_OPTION_STYLE
- opt_ary.join
- else
- opt_ary.map{|c|
- case c
- when 'a'
- 'array'
- when 'r'
- 'read'
- when 'w'
- 'write'
- when 'u'
- 'unset'
- end
- }
- end
- end
- end
- private :_check_trace_opt
-
def trace(opts, cmd = Proc.new)
- opts = _check_trace_opt(opts)
- (@trace_var ||= []).unshift([opts,cmd])
-
+ @trace_var = [] if @trace_var == nil
+ #opts = ['r','w','u'].find_all{|c| opts.index(c)}.join('')
+ opts = opts.to_s
+ opts = ['r','w','u'].find_all{|c| opts.index(c)}.join('')
+ @trace_var.unshift([opts,cmd])
if @trace_opts == nil
TkVar_CB_TBL[@id] = self
- @trace_opts = opts
- if USE_OLD_TRACE_OPTION_STYLE
- Tk.tk_call_without_enc('trace', 'variable',
- @id, @trace_opts, 'rb_var ' << @id)
- else
+ @trace_opts = opts.dup
+ Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts,
+ 'rb_var ' << @id)
+=begin
+ if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION
+ # TCL_VERSION >= 8.4
Tk.tk_call_without_enc('trace', 'add', 'variable',
- @id, @trace_opts, 'rb_var ' << @id)
+ @id, @trace_opts, 'rb_var')
+ else
+ # TCL_VERSION <= 8.3
+ Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts, 'rb_var')
end
+=end
else
newopts = @trace_opts.dup
- if USE_OLD_TRACE_OPTION_STYLE
- opts.each_byte{|c| newopts.concat(c.chr) unless newopts.index(c.chr)}
- if newopts != @trace_opts
- Tk.tk_call_without_enc('trace', 'vdelete',
- @id, @trace_opts, 'rb_var ' << @id)
- @trace_opts.replace(newopts)
- Tk.tk_call_without_enc('trace', 'variable',
- @id, @trace_opts, 'rb_var ' << @id)
- end
- else
- newopts |= opts
- unless (newopts - @trace_opts).empty?
+ #opts.each_byte{|c| newopts += c.chr unless newopts.index(c)}
+ opts.each_byte{|c| newopts.concat(c.chr) unless newopts.index(c)}
+ if newopts != @trace_opts
+ Tk.tk_call_without_enc('trace', 'vdelete', @id, @trace_opts,
+ 'rb_var ' << @id)
+ @trace_opts.replace(newopts)
+ Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts,
+ 'rb_var ' << @id)
+=begin
+ if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION
+ # TCL_VERSION >= 8.4
Tk.tk_call_without_enc('trace', 'remove', 'variable',
- @id, @trace_opts, 'rb_var ' << @id)
+ @id, @trace_opts, 'rb_var')
@trace_opts.replace(newopts)
Tk.tk_call_without_enc('trace', 'add', 'variable',
- @id, @trace_opts, 'rb_var ' << @id)
+ @id, @trace_opts, 'rb_var')
+ else
+ # TCL_VERSION <= 8.3
+ Tk.tk_call_without_enc('trace', 'vdelete',
+ @id, @trace_opts, 'rb_var')
+ @trace_opts.replace(newopts)
+ Tk.tk_call_without_enc('trace', 'variable',
+ @id, @trace_opts, 'rb_var')
end
+=end
end
end
-
self
end
@@ -1385,54 +1321,65 @@ end
fail(RuntimeError,
"invalid for a TkVariable which denotes an element of Tcl's array")
end
-
- opts = _check_trace_opt(opts)
-
- ((@trace_elem ||= {})[elem] ||= []).unshift([opts,cmd])
-
+ @trace_elem = {} if @trace_elem == nil
+ @trace_elem[elem] = [] if @trace_elem[elem] == nil
+ opts = opts.to_s
+ opts = ['r','w','u'].find_all{|c| opts.index(c)}.join('')
+ @trace_elem[elem].unshift([opts,cmd])
if @trace_opts == nil
TkVar_CB_TBL[@id] = self
- @trace_opts = opts
- if USE_OLD_TRACE_OPTION_STYLE
+ @trace_opts = opts.dup
+ Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts,
+ 'rb_var ' << @id)
+=begin
+ if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION
+ # TCL_VERSION >= 8.4
Tk.tk_call_without_enc('trace', 'add', 'variable',
- @id, @trace_opts, 'rb_var ' << @id)
+ @id, @trace_opts, 'rb_var')
else
+ # TCL_VERSION <= 8.3
Tk.tk_call_without_enc('trace', 'variable',
- @id, @trace_opts, 'rb_var ' << @id)
+ @id, @trace_opts, 'rb_var')
end
+=end
else
newopts = @trace_opts.dup
- if USE_OLD_TRACE_OPTION_STYLE
- opts.each_byte{|c| newopts.concat(c.chr) unless newopts.index(c.chr)}
- if newopts != @trace_opts
- Tk.tk_call_without_enc('trace', 'vdelete',
- @id, @trace_opts, 'rb_var ' << @id)
- @trace_opts.replace(newopts)
- Tk.tk_call_without_enc('trace', 'variable',
- @id, @trace_opts, 'rb_var ' << @id)
- end
- else
- newopts |= opts
- unless (newopts - @trace_opts).empty?
+ # opts.each_byte{|c| newopts += c.chr unless newopts.index(c)}
+ opts.each_byte{|c| newopts.concat(c.chr) unless newopts.index(c)}
+ if newopts != @trace_opts
+ Tk.tk_call_without_enc('trace', 'vdelete', @id, @trace_opts,
+ 'rb_var ' << @id)
+ @trace_opts.replace(newopts)
+ Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts,
+ 'rb_var ' << @id)
+=begin
+ if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION
+ # TCL_VERSION >= 8.4
Tk.tk_call_without_enc('trace', 'remove', 'variable',
- @id, @trace_opts, 'rb_var ' << @id)
+ @id, @trace_opts, 'rb_var')
@trace_opts.replace(newopts)
Tk.tk_call_without_enc('trace', 'add', 'variable',
- @id, @trace_opts, 'rb_var ' << @id)
+ @id, @trace_opts, 'rb_var')
+ else
+ # TCL_VERSION <= 8.3
+ Tk.tk_call_without_enc('trace', 'vdelete',
+ @id, @trace_opts, 'rb_var')
+ @trace_opts.replace(newopts)
+ Tk.tk_call_without_enc('trace', 'variable',
+ @id, @trace_opts, 'rb_var')
end
+=end
end
end
-
self
end
- def trace_info
+ def trace_vinfo
return [] unless @trace_var
@trace_var.dup
end
- alias trace_vinfo trace_info
- def trace_info_for_element(elem)
+ def _trace_vinfo_for_element(elem)
if @elem
fail(RuntimeError,
"invalid for a TkVariable which denotes an element of Tcl's array")
@@ -1441,180 +1388,141 @@ end
return [] unless @trace_elem[elem]
@trace_elem[elem].dup
end
- alias trace_vinfo_for_element trace_info_for_element
- def trace_remove(opts,cmd)
+ def trace_vdelete(opts,cmd)
return self unless @trace_var.kind_of? Array
-
- opts = _check_trace_opt(opts)
-
+ opts = opts.to_s
+ opts = ['r','w','u'].find_all{|c| opts.index(c)}.join('')
idx = -1
- if USE_OLD_TRACE_OPTION_STYLE
- newopts = ''
- @trace_var.each_with_index{|e, i|
- if idx < 0 && e[1] == cmd
- diff = false
- ['a', 'r', 'w', 'u'].each{|c|
- break if (diff = e[0].index(c) ^ opts.index(c))
- }
- unless diff
- #find
- idx = i
- next
- end
- end
- e[0].each_byte{|c| newopts.concat(c.chr) unless newopts.index(c.chr)}
- }
- else
- newopts = []
- @trace_var.each_with_index{|e, i|
- if idx < 0 && e[1] == cmd &&
- e[0].size == opts.size && (e[0] - opts).empty?
- # find
- idx = i
- next
- end
- newopts |= e[0]
- }
- end
-
+ newopts = ''
+ @trace_var.each_with_index{|e,i|
+ if idx < 0 && e[0] == opts && e[1] == cmd
+ idx = i
+ next
+ end
+ # e[0].each_byte{|c| newopts += c.chr unless newopts.index(c)}
+ e[0].each_byte{|c| newopts.concat(c.chr) unless newopts.index(c)}
+ }
if idx >= 0
@trace_var.delete_at(idx)
else
return self
end
- (@trace_elem ||= {}).each{|elem|
+ @trace_elem.each{|elem|
@trace_elem[elem].each{|e|
- if USE_OLD_TRACE_OPTION_STYLE
- e[0].each_byte{|c| newopts.concat(c.chr) unless newopts.index(c.chr)}
- else
- newopts |= e[0]
- end
+ # e[0].each_byte{|c| newopts += c.chr unless newopts.index(c)}
+ e[0].each_byte{|c| newopts.concat(c.chr) unless newopts.index(c)}
}
}
- if USE_OLD_TRACE_OPTION_STYLE
- diff = false
- @trace_opts.each_byte{|c| break if (diff = ! newopts.index(c))}
- if diff
+ newopts = newopts.to_s
+ newopts = ['r','w','u'].find_all{|c| newopts.index(c)}.join('')
+ if newopts != @trace_opts
+ Tk.tk_call_without_enc('trace', 'vdelete', @id, @trace_opts,
+ 'rb_var ' << @id)
+=begin
+ if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION
+ # TCL_VERSION >= 8.4
+ Tk.tk_call_without_enc('trace', 'remove', 'variable',
+ @id, @trace_opts, 'rb_var')
+ else
+ # TCL_VERSION <= 8.3
Tk.tk_call_without_enc('trace', 'vdelete',
- @id, @trace_opts, 'rb_var ' << @id)
- @trace_opts.replace(newopts)
- unless @trace_opts.empty?
- Tk.tk_call_without_enc('trace', 'variable',
- @id, @trace_opts, 'rb_var ' << @id)
- end
+ @id, @trace_opts, 'rb_var')
end
- else
- unless (@trace_opts - newopts).empty?
- Tk.tk_call_without_enc('trace', 'remove', 'variable',
- @id, @trace_opts, 'rb_var ' << @id)
- @trace_opts.replace(newopts)
- unless @trace_opts.empty?
+=end
+ @trace_opts.replace(newopts)
+ if @trace_opts != ''
+ Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts,
+ 'rb_var ' << @id)
+=begin
+ if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION
+ # TCL_VERSION >= 8.4
Tk.tk_call_without_enc('trace', 'add', 'variable',
- @id, @trace_opts, 'rb_var ' << @id)
+ @id, @trace_opts, 'rb_var')
+ else
+ # TCL_VERSION <= 8.3
+ Tk.tk_call_without_enc('trace', 'variable',
+ @id, @trace_opts, 'rb_var')
end
+=end
end
end
self
end
- alias trace_delete trace_remove
- alias trace_vdelete trace_remove
- def trace_remove_for_element(elem,opts,cmd)
+ def trace_vdelete_for_element(elem,opts,cmd)
if @elem
fail(RuntimeError,
"invalid for a TkVariable which denotes an element of Tcl's array")
end
return self unless @trace_elem.kind_of? Hash
return self unless @trace_elem[elem].kind_of? Array
-
- opts = _check_trace_opt(opts)
-
+ opts = opts.to_s
+ opts = ['r','w','u'].find_all{|c| opts.index(c)}.join('')
idx = -1
- if USE_OLD_TRACE_OPTION_STYLE
- @trace_elem[elem].each_with_index{|e, i|
- if idx < 0 && e[1] == cmd
- diff = false
- ['a', 'r', 'w', 'u'].each{|c|
- break if (diff = e[0].index(c) ^ opts.index(c))
- }
- unless diff
- #find
- idx = i
- next
- end
- end
- }
- else
- @trace_elem[elem].each_with_index{|e, i|
- if idx < 0 && e[1] == cmd &&
- e[0].size == opts.size && (e[0] - opts).empty?
- # find
- idx = i
- next
- end
- }
- end
-
+ @trace_elem[elem].each_with_index{|e,i|
+ if idx < 0 && e[0] == opts && e[1] == cmd
+ idx = i
+ next
+ end
+ }
if idx >= 0
@trace_elem[elem].delete_at(idx)
else
return self
end
- if USE_OLD_TRACE_OPTION_STYLE
- newopts = ''
- @trace_var.each{|e|
- e[0].each_byte{|c| newopts.concat(c.chr) unless newopts.index(c.chr)}
- }
- @trace_elem.each{|elem|
- @trace_elem[elem].each{|e|
- e[0].each_byte{|c| newopts.concat(c.chr) unless newopts.index(c.chr)}
- }
- }
- else
- newopts = []
- @trace_var.each{|e|
- newopts |= e[0]
- }
- @trace_elem.each{|elem|
- @trace_elem[elem].each{|e|
- e[0].each_byte{|c| newopts.concat(c.chr) unless newopts.index(c.chr)}
- }
+ newopts = ''
+ @trace_var.each{|e|
+ # e[0].each_byte{|c| newopts += c.chr unless newopts.index(c)}
+ e[0].each_byte{|c| newopts.concat(c.chr) unless newopts.index(c)}
+ }
+ @trace_elem.each{|elem|
+ @trace_elem[elem].each{|e|
+ # e[0].each_byte{|c| newopts += c.chr unless newopts.index(c)}
+ e[0].each_byte{|c| newopts.concat(c.chr) unless newopts.index(c)}
}
- end
+ }
- if USE_OLD_TRACE_OPTION_STYLE
- diff = false
- @trace_opts.each_byte{|c| break if (diff = ! newopts.index(c))}
- if diff
+ newopts = newopts.to_s
+ newopts = ['r','w','u'].find_all{|c| newopts.index(c)}.join('')
+ if newopts != @trace_opts
+ Tk.tk_call_without_enc('trace', 'vdelete', @id, @trace_opts,
+ 'rb_var ' << @id)
+=begin
+ if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION
+ # TCL_VERSION >= 8.4
+ Tk.tk_call_without_enc('trace', 'remove', 'variable',
+ @id, @trace_opts, 'rb_var')
+ else
+ # TCL_VERSION <= 8.3
Tk.tk_call_without_enc('trace', 'vdelete',
- @id, @trace_opts, 'rb_var ' << @id)
- @trace_opts.replace(newopts)
- unless @trace_opts.empty?
- Tk.tk_call_without_enc('trace', 'variable',
- @id, @trace_opts, 'rb_var ' << @id)
- end
+ @id, @trace_opts, 'rb_var')
end
- else
- unless (@trace_opts - newopts).empty?
- Tk.tk_call_without_enc('trace', 'remove', 'variable',
- @id, @trace_opts, 'rb_var ' << @id)
- @trace_opts.replace(newopts)
- unless @trace_opts.empty?
+=end
+ @trace_opts.replace(newopts)
+ if @trace_opts != ''
+ Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts,
+ 'rb_var ' << @id)
+=begin
+ if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION
+ # TCL_VERSION >= 8.4
Tk.tk_call_without_enc('trace', 'add', 'variable',
- @id, @trace_opts, 'rb_var ' << @id)
+ @id, @trace_opts, 'rb_var')
+ else
+ # TCL_VERSION <= 8.3
+ Tk.tk_call_without_enc('trace', 'variable', @id,
+ @trace_opts, 'rb_var')
end
+=end
end
end
self
end
- alias trace_delete_for_element trace_remove_for_element
- alias trace_vdelete_for_element trace_remove_for_element
end
class TkVarAccess<TkVariable
@@ -1624,23 +1532,12 @@ class TkVarAccess<TkVariable
return name
end
- name = name.to_s
- v = nil
- TkVar_ID_TBL.mutex.synchronize{
- if v = TkVar_ID_TBL[name]
- v.value = args[0] unless args.empty?
- return v
- else
- (v = self.allocate).instance_eval{
- @id = name
- TkVar_ID_TBL[@id] = self
- @var = @id
- }
- end
- }
+ if v = TkVar_ID_TBL[name]
+ v.value = args[0] unless args.empty?
+ return v
+ end
- v.instance_eval{ initialize(name, *args) }
- v
+ super(name, *args)
end
def self.new_hash(name, *args)
@@ -1652,38 +1549,27 @@ class TkVarAccess<TkVariable
return name
end
- name = name.to_s
- v = nil
- TkVar_ID_TBL.mutex.synchronize{
- if v = TkVar_ID_TBL[name]
- unless v.is_hash?
- fail ArgumentError, "already exist as a scalar variable"
- end
- v.value = args[0] unless args.empty?
- return v
- else
- (v = self.allocate).instance_eval{
- @id = name
- TkVar_ID_TBL[@id] = self
- @var = @id
- }
+ if v = TkVar_ID_TBL[name]
+ unless v.is_hash?
+ fail ArgumentError, "already exist as a scalar variable"
end
- }
+ v.value = args[0] unless args.empty?
+ return v
+ end
INTERP._invoke_without_enc('global', name)
if args.empty? && INTERP._invoke_without_enc('array', 'exist', name) == '0'
- v.instance_eval{ initialize(name, {}) } # force creating
+ self.new(name, {}) # force creating
else
- v.instance_eval{ initialize(name, *args) }
+ self.new(name, *args)
end
- v
end
def initialize(varname, val=nil)
- # @id = varname
- # TkVar_ID_TBL[@id] = self
+ @id = varname
+ TkVar_ID_TBL[@id] = self
- # @var = @id
+ @var = @id
@elem = nil
@def_default = false
diff --git a/ext/tk/lib/tk/virtevent.rb b/ext/tk/lib/tk/virtevent.rb
index ae31ac1f8f..d47e80aecd 100644
--- a/ext/tk/lib/tk/virtevent.rb
+++ b/ext/tk/lib/tk/virtevent.rb
@@ -9,17 +9,10 @@ class TkVirtualEvent<TkObject
TkCommandNames = ['event'.freeze].freeze
- (TkVirtualEventID = ["VirtEvent".freeze, "00000".taint]).instance_eval{
- @mutex = Mutex.new
- def mutex; @mutex; end
- freeze
- }
-
+ TkVirtualEventID = ["VirtEvent".freeze, "00000".taint].freeze
TkVirtualEventTBL = TkCore::INTERP.create_table
- TkCore::INTERP.init_ip_env{
- TkVirtualEventTBL.mutex.synchronize{ TkVirtualEventTBL.clear }
- }
+ TkCore::INTERP.init_ip_env{ TkVirtualEventTBL.clear }
class PreDefVirtEvent<self
def self.new(event, *sequences)
@@ -28,30 +21,22 @@ class TkVirtualEvent<TkObject
elsif event !~ /^<.*>$/
event = '<' + event + '>'
end
- TkVirtualEvent::TkVirtualEventTBL.mutex.synchronize{
- if TkVirtualEvent::TkVirtualEventTBL.has_key?(event)
- TkVirtualEvent::TkVirtualEventTBL[event]
- else
- # super(event, *sequences)
- (obj = self.allocate).instance_eval{
- initialize(event, *sequences)
- TkVirtualEvent::TkVirtualEventTBL[@id] = self
- }
- end
- }
+ if TkVirtualEvent::TkVirtualEventTBL.has_key?(event)
+ TkVirtualEvent::TkVirtualEventTBL[event]
+ else
+ super(event, *sequences)
+ end
end
def initialize(event, *sequences)
@path = @id = event
- _add_sequences(sequences)
+ TkVirtualEvent::TkVirtualEventTBL[@id] = self
+ add(*sequences)
end
end
def TkVirtualEvent.getobj(event)
- obj = nil
- TkVirtualEventTBL.mutex.synchronize{
- obj = TkVirtualEventTBL[event]
- }
+ obj = TkVirtualEventTBL[event]
if obj
obj
else
@@ -70,31 +55,19 @@ class TkVirtualEvent<TkObject
end
def initialize(*sequences)
- TkVirtualEventID.mutex.synchronize{
- # @path = @id = '<' + TkVirtualEventID.join('') + '>'
- @path = @id = '<' + TkVirtualEventID.join(TkCore::INTERP._ip_id_) + '>'
- TkVirtualEventID[1].succ!
- }
- _add_sequences(sequences)
+ # @path = @id = '<' + TkVirtualEventID.join('') + '>'
+ @path = @id = '<' + TkVirtualEventID.join(TkCore::INTERP._ip_id_) + '>'
+ TkVirtualEventID[1].succ!
+ add(*sequences)
end
- def _add_sequences(seq_ary)
- unless seq_ary.empty?
+ def add(*sequences)
+ if sequences != []
tk_call_without_enc('event', 'add', "<#{@id}>",
- *(seq_ary.collect{|seq|
+ *(sequences.collect{|seq|
"<#{tk_event_sequence(seq)}>"
}) )
- end
- self
- end
- private :_add_sequences
-
- def add(*sequences)
- if sequences != []
- _add_sequences(sequences)
- TkVirtualEventTBL.mutex.synchronize{
- TkVirtualEventTBL[@id] = self
- }
+ TkVirtualEventTBL[@id] = self
end
self
end
@@ -102,26 +75,20 @@ class TkVirtualEvent<TkObject
def delete(*sequences)
if sequences == []
tk_call_without_enc('event', 'delete', "<#{@id}>")
- TkVirtualEventTBL.mutex.synchronize{
- TkVirtualEventTBL.delete(@id)
- }
+ TkVirtualEventTBL.delete(@id)
else
tk_call_without_enc('event', 'delete', "<#{@id}>",
*(sequences.collect{|seq|
"<#{tk_event_sequence(seq)}>"
}) )
- if tk_call_without_enc('event','info',"<#{@id}>").empty?
- TkVirtualEventTBL.mutex.synchronize{
- TkVirtualEventTBL.delete(@id)
- }
- end
+ TkVirtualEventTBL.delete(@id) if info == []
end
self
end
def info
tk_call_without_enc('event','info',"<#{@id}>").split(/\s+/).collect!{|seq|
- lst = seq.scan(/<*[^<>]+>*/).collect!{|subseq|
+ l = seq.scan(/<*[^<>]+>*/).collect!{|subseq|
case (subseq)
when /^<<[^<>]+>>$/
TkVirtualEvent.getobj(subseq[1..-2])
@@ -131,7 +98,7 @@ class TkVirtualEvent<TkObject
subseq.split('')
end
}.flatten
- (lst.size == 1) ? lst[0] : lst
+ (l.size == 1) ? l[0] : l
}
end
end
diff --git a/ext/tk/lib/tk/winpkg.rb b/ext/tk/lib/tk/winpkg.rb
index 89fb391c77..737fb959b5 100644
--- a/ext/tk/lib/tk/winpkg.rb
+++ b/ext/tk/lib/tk/winpkg.rb
@@ -7,14 +7,9 @@
#
require 'tk'
-module Tk::WinDDE
-end
-#TkWinDDE = Tk::WinDDE
-Tk.__set_toplevel_aliases__(:Tk, Tk::WinDDE, :TkWinDDE)
-
-module Tk::WinDDE
+module TkWinDDE
extend Tk
- extend Tk::WinDDE
+ extend TkWinDDE
TkCommandNames = ['dde'.freeze].freeze
@@ -90,14 +85,9 @@ module Tk::WinDDE
:poke, :request, :services, :eval
end
-module Tk::WinRegistry
-end
-#TkWinRegistry = Tk::WinRegistry
-Tk.__set_toplevel_aliases__(:Tk, Tk::WinRegistry, :TkWinRegistry)
-
-module Tk::WinRegistry
+module TkWinRegistry
extend Tk
- extend Tk::WinRegistry
+ extend TkWinRegistry
TkCommandNames = ['registry'.freeze].freeze
diff --git a/ext/tk/lib/tk/wm.rb b/ext/tk/lib/tk/wm.rb
index 0394296189..1f432a3848 100644
--- a/ext/tk/lib/tk/wm.rb
+++ b/ext/tk/lib/tk/wm.rb
@@ -5,407 +5,273 @@ require 'tk'
module Tk
module Wm
- #include TkComm
- extend TkCore
+ include TkComm
TkCommandNames = ['wm'.freeze].freeze
TOPLEVEL_METHODCALL_OPTKEYS = {}
- def Wm.aspect(win, *args)
+ def aspect(*args)
if args.length == 0
- list(tk_call_without_enc('wm', 'aspect', win.epath))
+ list(tk_call_without_enc('wm', 'aspect', path))
else
args = args[0] if args.length == 1 && args[0].kind_of?(Array)
- tk_call('wm', 'aspect', win.epath, *args)
- win
+ tk_call('wm', 'aspect', path, *args)
+ self
end
end
- def aspect(*args)
- Wm.aspect(self, *args)
- end
- alias wm_aspect aspect
TOPLEVEL_METHODCALL_OPTKEYS['aspect'] = 'aspect'
- def Wm.attributes(win, slot=nil,value=TkComm::None)
+ def attributes(slot=nil,value=None)
if slot == nil
- lst = tk_split_list(tk_call('wm', 'attributes', win.epath))
+ lst = tk_split_list(tk_call('wm', 'attributes', path))
info = {}
while key = lst.shift
info[key[1..-1]] = lst.shift
end
info
elsif slot.kind_of? Hash
- tk_call('wm', 'attributes', win.epath, *hash_kv(slot))
- win
- elsif value == TkComm::None
- tk_call('wm', 'attributes', win.epath, "-#{slot}")
+ tk_call('wm', 'attributes', path, *hash_kv(slot))
+ self
+ elsif value == None
+ tk_call('wm', 'attributes', path, "-#{slot}")
else
- tk_call('wm', 'attributes', win.epath, "-#{slot}", value)
- win
+ tk_call('wm', 'attributes', path, "-#{slot}", value)
+ self
end
end
- def attributes(slot=nil,value=TkComm::None)
- Wm.attributes(self, slot, value)
- end
- alias wm_attributes attributes
TOPLEVEL_METHODCALL_OPTKEYS['attributes'] = 'attributes'
- def Wm.client(win, name=TkComm::None)
- if name == TkComm::None
- tk_call('wm', 'client', win.epath)
+ def client(name=None)
+ if name == None
+ tk_call('wm', 'client', path)
else
name = '' if name == nil
- tk_call('wm', 'client', win.epath, name)
- win
+ tk_call('wm', 'client', path, name)
+ self
end
end
- def client(name=TkComm::None)
- Wm.client(self, name)
- end
- alias wm_client client
TOPLEVEL_METHODCALL_OPTKEYS['client'] = 'client'
- def Wm.colormapwindows(win, *args)
+ def colormapwindows(*args)
if args.size == 0
- list(tk_call_without_enc('wm', 'colormapwindows', win.epath))
+ list(tk_call_without_enc('wm', 'colormapwindows', path))
else
args = args[0] if args.length == 1 && args[0].kind_of?(Array)
- tk_call_without_enc('wm', 'colormapwindows', win.epath, *args)
- win
+ tk_call_without_enc('wm', 'colormapwindows', path, *args)
+ self
end
end
- def colormapwindows(*args)
- Wm.colormapwindows(self, *args)
- end
- alias wm_colormapwindows colormapwindows
TOPLEVEL_METHODCALL_OPTKEYS['colormapwindows'] = 'colormapwindows'
- def Wm.command(win, value=nil)
+ def wm_command(value=nil)
if value
- tk_call('wm', 'command', epath, value)
- win
+ tk_call('wm', 'command', path, value)
+ self
else
- #procedure(tk_call('wm', 'command', epath))
- tk_call('wm', 'command', epath)
+ #procedure(tk_call('wm', 'command', path))
+ tk_call('wm', 'command', path)
end
end
- def wm_command(value=nil)
- Wm.command(self, value)
- end
TOPLEVEL_METHODCALL_OPTKEYS['wm_command'] = 'wm_command'
- def Wm.deiconify(win, ex = true)
+ def deiconify(ex = true)
if ex
- tk_call_without_enc('wm', 'deiconify', win.epath)
+ tk_call_without_enc('wm', 'deiconify', path)
else
- Wm.iconify(win)
+ self.iconify
end
- win
+ self
end
- def deiconify(ex = true)
- Wm.deiconify(self, ex)
- end
- alias wm_deiconify deiconify
- def Wm.focusmodel(win, mode = nil)
+ def focusmodel(mode = nil)
if mode
- tk_call_without_enc('wm', 'focusmodel', win.epath, mode)
- win
+ tk_call_without_enc('wm', 'focusmodel', path, mode)
+ self
else
- tk_call_without_enc('wm', 'focusmodel', win.epath)
+ tk_call_without_enc('wm', 'focusmodel', path)
end
end
- def focusmodel(mode = nil)
- Wm.focusmodel(self, mode)
- end
- alias wm_focusmodel focusmodel
TOPLEVEL_METHODCALL_OPTKEYS['focusmodel'] = 'focusmodel'
- def Wm.forget(win)
- # Tcl/Tk 8.5+
- # work with dockable frames
- tk_call_without_enc('wm', 'forget', win.epath)
- win
- end
- def wm_forget
- Wm.forget(self)
- end
-
- def Wm.frame(win)
- tk_call_without_enc('wm', 'frame', win.epath)
- end
def frame
- Wm.frame(self)
+ tk_call_without_enc('wm', 'frame', path)
end
- alias wm_frame frame
- def Wm.geometry(win, geom=nil)
+ def geometry(geom=nil)
if geom
- tk_call_without_enc('wm', 'geometry', win.epath, geom)
- win
+ tk_call_without_enc('wm', 'geometry', path, geom)
+ self
else
- tk_call_without_enc('wm', 'geometry', win.epath)
+ tk_call_without_enc('wm', 'geometry', path)
end
end
- def geometry(geom=nil)
- Wm.geometry(self, geom)
- end
- alias wm_geometry geometry
TOPLEVEL_METHODCALL_OPTKEYS['geometry'] = 'geometry'
- def Wm.grid(win, *args)
+ def wm_grid(*args)
if args.size == 0
- list(tk_call_without_enc('wm', 'grid', win.epath))
+ list(tk_call_without_enc('wm', 'grid', path))
else
args = args[0] if args.length == 1 && args[0].kind_of?(Array)
- tk_call_without_enc('wm', 'grid', win.epath, *args)
- win
+ tk_call_without_enc('wm', 'grid', path, *args)
+ self
end
end
- def wm_grid(*args)
- Wm.grid(self, *args)
- end
TOPLEVEL_METHODCALL_OPTKEYS['wm_grid'] = 'wm_grid'
- def Wm.group(win, leader = nil)
+ def group(leader = nil)
if leader
- tk_call('wm', 'group', win.epath, leader)
- win
+ tk_call('wm', 'group', path, leader)
+ self
else
- window(tk_call('wm', 'group', win.epath))
+ window(tk_call('wm', 'group', path))
end
end
- def group(leader = nil)
- Wm.group(self, leader)
- end
- alias wm_group group
TOPLEVEL_METHODCALL_OPTKEYS['group'] = 'group'
- def Wm.iconbitmap(win, bmp=nil)
+ def iconbitmap(bmp=nil)
if bmp
- tk_call_without_enc('wm', 'iconbitmap', win.epath, bmp)
- win
+ tk_call_without_enc('wm', 'iconbitmap', path, bmp)
+ self
else
- image_obj(tk_call_without_enc('wm', 'iconbitmap', win.epath))
+ image_obj(tk_call_without_enc('wm', 'iconbitmap', path))
end
end
- def iconbitmap(bmp=nil)
- Wm.iconbitmap(self, bmp)
- end
- alias wm_iconbitmap iconbitmap
TOPLEVEL_METHODCALL_OPTKEYS['iconbitmap'] = 'iconbitmap'
- def Wm.iconphoto(win, *imgs)
+ def iconphoto(*imgs)
if imgs.empty?
- win.instance_eval{
- @wm_iconphoto = nil unless defined? @wm_iconphoto
- return @wm_iconphoto
- }
+ @wm_iconphoto = nil unless defined? @wm_iconphoto
+ return @wm_iconphoto
end
imgs = imgs[0] if imgs.length == 1 && imgs[0].kind_of?(Array)
- tk_call_without_enc('wm', 'iconphoto', win.epath, *imgs)
- win.instance_eval{ @wm_iconphoto = imgs }
- win
- end
- def iconphoto(*imgs)
- Wm.iconphoto(self, *imgs)
+ tk_call_without_enc('wm', 'iconphoto', path, *imgs)
+ @wm_iconphoto = imgs
+ self
end
- alias wm_iconphoto iconphoto
TOPLEVEL_METHODCALL_OPTKEYS['iconphoto'] = 'iconphoto'
- def Wm.iconphoto_default(win, *imgs)
- imgs = imgs[0] if imgs.length == 1 && imgs[0].kind_of?(Array)
- tk_call_without_enc('wm', 'iconphoto', win.epath, '-default', *imgs)
- win
- end
def iconphoto_default(*imgs)
- Wm.iconphoto_default(self, *imgs)
+ imgs = imgs[0] if imgs.length == 1 && imgs[0].kind_of?(Array)
+ tk_call_without_enc('wm', 'iconphoto', path, '-default', *imgs)
+ self
end
- alias wm_iconphoto_default iconphoto_default
- def Wm.iconify(win, ex = true)
+ def iconify(ex = true)
if ex
- tk_call_without_enc('wm', 'iconify', win.epath)
+ tk_call_without_enc('wm', 'iconify', path)
else
- Wm.deiconify(win)
+ self.deiconify
end
- win
- end
- def iconify(ex = true)
- Wm.iconify(self, ex)
+ self
end
- alias wm_iconify iconify
- def Wm.iconmask(win, bmp=nil)
+ def iconmask(bmp=nil)
if bmp
- tk_call_without_enc('wm', 'iconmask', win.epath, bmp)
- win
+ tk_call_without_enc('wm', 'iconmask', path, bmp)
+ self
else
- image_obj(tk_call_without_enc('wm', 'iconmask', win.epath))
+ image_obj(tk_call_without_enc('wm', 'iconmask', path))
end
end
- def iconmask(bmp=nil)
- Wm.iconmask(self, bmp)
- end
- alias wm_iconmask iconmask
TOPLEVEL_METHODCALL_OPTKEYS['iconmask'] = 'iconmask'
- def Wm.iconname(win, name=nil)
+ def iconname(name=nil)
if name
- tk_call('wm', 'iconname', win.epath, name)
- win
+ tk_call('wm', 'iconname', path, name)
+ self
else
- tk_call('wm', 'iconname', win.epath)
+ tk_call('wm', 'iconname', path)
end
end
- def iconname(name=nil)
- Wm.iconname(self, name)
- end
- alias wm_iconname iconname
TOPLEVEL_METHODCALL_OPTKEYS['iconname'] = 'iconname'
- def Wm.iconposition(win, *args)
+ def iconposition(*args)
if args.size == 0
- list(tk_call_without_enc('wm', 'iconposition', win.epath))
+ list(tk_call_without_enc('wm', 'iconposition', path))
else
args = args[0] if args.length == 1 && args[0].kind_of?(Array)
- tk_call_without_enc('wm', 'iconposition', win.epath, *args)
- win
+ tk_call_without_enc('wm', 'iconposition', path, *args)
+ self
end
end
- def iconposition(*args)
- Wm.iconposition(self, *args)
- end
- alias wm_iconposition iconposition
TOPLEVEL_METHODCALL_OPTKEYS['iconposition'] = 'iconposition'
- def Wm.iconwindow(win, iconwin = nil)
- if iconwin
- tk_call_without_enc('wm', 'iconwindow', win.epath, iconwin)
- win
+ def iconwindow(win = nil)
+ if win
+ tk_call_without_enc('wm', 'iconwindow', path, win)
+ self
else
- w = tk_call_without_enc('wm', 'iconwindow', win.epath)
+ w = tk_call_without_enc('wm', 'iconwindow', path)
(w == '')? nil: window(w)
end
end
- def iconwindow(iconwin = nil)
- Wm.iconwindow(self, iconwin)
- end
- alias wm_iconwindow iconwindow
TOPLEVEL_METHODCALL_OPTKEYS['iconwindow'] = 'iconwindow'
- def Wm.manage(win)
- # Tcl/Tk 8.5+ feature
- tk_call_without_enc('wm', 'manage', win.epath)
- win
- end
- def wm_manage
- Wm.manage(self)
- end
-=begin
- def Wm.manage(win, use_id = nil)
- # Tcl/Tk 8.5+ feature
- # --------------------------------------------------------------
- # In the future release, I want to support to embed the 'win'
- # into the container which has window-id 'use-id'.
- # It may give users frexibility on controlling their GUI.
- # However, it may be difficult for current Tcl/Tk (Tcl/Tk8.5.1),
- # because it seems to require to modify Tcl/Tk's source code.
- # --------------------------------------------------------------
- if use_id
- tk_call_without_enc('wm', 'manage', win.epath, '-use', use_id)
- else
- tk_call_without_enc('wm', 'manage', win.epath)
- end
- win
- end
-=end
-
- def Wm.maxsize(win, *args)
+ def maxsize(*args)
if args.size == 0
- list(tk_call_without_enc('wm', 'maxsize', win.epath))
+ list(tk_call_without_enc('wm', 'maxsize', path))
else
args = args[0] if args.length == 1 && args[0].kind_of?(Array)
- tk_call_without_enc('wm', 'maxsize', win.epath, *args)
- win
+ tk_call_without_enc('wm', 'maxsize', path, *args)
+ self
end
end
- def maxsize(*args)
- Wm.maxsize(self, *args)
- end
- alias wm_maxsize maxsize
TOPLEVEL_METHODCALL_OPTKEYS['maxsize'] = 'maxsize'
- def Wm.minsize(win, *args)
+ def minsize(*args)
if args.size == 0
- list(tk_call_without_enc('wm', 'minsize', win.epath))
+ list(tk_call_without_enc('wm', 'minsize', path))
else
args = args[0] if args.length == 1 && args[0].kind_of?(Array)
- tk_call_without_enc('wm', 'minsize', win.path, *args)
- win
+ tk_call_without_enc('wm', 'minsize', path, *args)
+ self
end
end
- def minsize(*args)
- Wm.minsize(self, *args)
- end
- alias wm_minsize minsize
TOPLEVEL_METHODCALL_OPTKEYS['minsize'] = 'minsize'
- def Wm.overrideredirect(win, mode=TkComm::None)
- if mode == TkComm::None
- bool(tk_call_without_enc('wm', 'overrideredirect', win.epath))
+ def overrideredirect(mode=None)
+ if mode == None
+ bool(tk_call_without_enc('wm', 'overrideredirect', path))
else
- tk_call_without_enc('wm', 'overrideredirect', win.epath, mode)
- win
+ tk_call_without_enc('wm', 'overrideredirect', path, mode)
+ self
end
end
- def overrideredirect(mode=TkComm::None)
- Wm.overrideredirect(self, mode)
- end
- alias wm_overrideredirect overrideredirect
TOPLEVEL_METHODCALL_OPTKEYS['overrideredirect'] = 'overrideredirect'
- def Wm.positionfrom(win, who=TkComm::None)
- if who == TkComm::None
- r = tk_call_without_enc('wm', 'positionfrom', win.epath)
+ def positionfrom(who=None)
+ if who == None
+ r = tk_call_without_enc('wm', 'positionfrom', path)
(r == "")? nil: r
else
- tk_call_without_enc('wm', 'positionfrom', win.epath, who)
- win
+ tk_call_without_enc('wm', 'positionfrom', path, who)
+ self
end
end
- def positionfrom(who=TkComm::None)
- Wm.positionfrom(self, who)
- end
- alias wm_positionfrom positionfrom
TOPLEVEL_METHODCALL_OPTKEYS['positionfrom'] = 'positionfrom'
- def Wm.protocol(win, name=nil, cmd=nil, &b)
+ def protocol(name=nil, cmd=nil, &b)
if cmd
- tk_call_without_enc('wm', 'protocol', win.epath, name, cmd)
- win
+ tk_call_without_enc('wm', 'protocol', path, name, cmd)
+ self
elsif b
- tk_call_without_enc('wm', 'protocol', win.epath, name, proc(&b))
- win
+ tk_call_without_enc('wm', 'protocol', path, name, proc(&b))
+ self
elsif name
- result = tk_call_without_enc('wm', 'protocol', win.epath, name)
+ result = tk_call_without_enc('wm', 'protocol', path, name)
(result == "")? nil : tk_tcl2ruby(result)
else
- tk_split_simplelist(tk_call_without_enc('wm', 'protocol', win.epath))
+ tk_split_simplelist(tk_call_without_enc('wm', 'protocol', path))
end
end
- def protocol(name=nil, cmd=nil, &b)
- Wm.protocol(self, name, cmd, &b)
- end
- alias wm_protocol protocol
- def Wm.protocols(win, kv=nil)
+ def protocols(kv=nil)
unless kv
ret = {}
- Wm.protocol(win).each{|name|
- ret[name] = Wm.protocol(win, name)
+ self.protocol.each{|name|
+ ret[name] = self.protocol(name)
}
return ret
end
@@ -413,140 +279,82 @@ module Tk
unless kv.kind_of?(Hash)
fail ArgumentError, 'expect a hash of protocol=>command'
end
- kv.each{|k, v| Wm.protocol(win, k, v)}
- win
+ kv.each{|k, v| self.protocol(k, v)}
+ self
end
- def protocols(kv=nil)
- Wm.protocols(self, kv)
- end
- alias wm_protocols protocols
TOPLEVEL_METHODCALL_OPTKEYS['protocols'] = 'protocols'
- def Wm.resizable(win, *args)
+ def resizable(*args)
if args.length == 0
- list(tk_call_without_enc('wm', 'resizable', win.epath)).map!{|e| bool(e)}
+ list(tk_call_without_enc('wm', 'resizable', path)).collect{|e| bool(e)}
else
args = args[0] if args.length == 1 && args[0].kind_of?(Array)
- tk_call_without_enc('wm', 'resizable', win.epath, *args)
- win
+ tk_call_without_enc('wm', 'resizable', path, *args)
+ self
end
end
- def resizable(*args)
- Wm.resizable(self, *args)
- end
- alias wm_resizable resizable
TOPLEVEL_METHODCALL_OPTKEYS['resizable'] = 'resizable'
- def Wm.sizefrom(win, who=TkComm::None)
- if who == TkComm::None
- r = tk_call_without_enc('wm', 'sizefrom', win.epath)
+ def sizefrom(who=None)
+ if who == None
+ r = tk_call_without_enc('wm', 'sizefrom', path)
(r == "")? nil: r
else
- tk_call_without_enc('wm', 'sizefrom', win.epath, who)
- win
+ tk_call_without_enc('wm', 'sizefrom', path, who)
+ self
end
end
- def sizefrom(who=TkComm::None)
- Wm.sizefrom(self, who)
- end
- alias wm_sizefrom sizefrom
TOPLEVEL_METHODCALL_OPTKEYS['sizefrom'] = 'sizefrom'
- def Wm.stackorder(win)
- list(tk_call('wm', 'stackorder', win.epath))
- end
def stackorder
- Wm.stackorder(self)
+ list(tk_call('wm', 'stackorder', path))
end
- alias wm_stackorder stackorder
- def Wm.stackorder_isabove(win, target)
- bool(tk_call('wm', 'stackorder', win.epath, 'isabove', target))
- end
- def Wm.stackorder_is_above(win, target)
- Wm.stackorder_isabove(win, target)
- end
- def stackorder_isabove(target)
- Wm.stackorder_isabove(self, target)
+ def stackorder_isabove(win)
+ bool(tk_call('wm', 'stackorder', path, 'isabove', win))
end
- alias stackorder_is_above stackorder_isabove
- alias wm_stackorder_isabove stackorder_isabove
- alias wm_stackorder_is_above stackorder_isabove
- def Wm.stackorder_isbelow(win, target)
- bool(tk_call('wm', 'stackorder', win.epath, 'isbelow', target))
+ def stackorder_isbelow(win)
+ bool(tk_call('wm', 'stackorder', path, 'isbelow', win))
end
- def Wm.stackorder_is_below(win, target)
- Wm.stackorder_isbelow(win, target)
- end
- def stackorder_isbelow(target)
- Wm.stackorder_isbelow(self, target)
- end
- alias stackorder_is_below stackorder_isbelow
- alias wm_stackorder_isbelow stackorder_isbelow
- alias wm_stackorder_is_below stackorder_isbelow
- def Wm.state(win, st=nil)
+ def state(st=nil)
if st
- tk_call_without_enc('wm', 'state', win.epath, st)
- win
+ tk_call_without_enc('wm', 'state', path, st)
+ self
else
- tk_call_without_enc('wm', 'state', win.epath)
+ tk_call_without_enc('wm', 'state', path)
end
end
- def state(st=nil)
- Wm.state(self, st)
- end
- alias wm_state state
TOPLEVEL_METHODCALL_OPTKEYS['state'] = 'state'
- def Wm.title(win, str=nil)
+ def title(str=nil)
if str
- tk_call('wm', 'title', win.epath, str)
- win
+ tk_call('wm', 'title', path, str)
+ self
else
- tk_call('wm', 'title', win.epath)
+ tk_call('wm', 'title', path)
end
end
- def title(str=nil)
- Wm.title(self, str)
- end
- alias wm_title title
TOPLEVEL_METHODCALL_OPTKEYS['title'] = 'title'
- def Wm.transient(win, master=nil)
+ def transient(master=nil)
if master
- tk_call_without_enc('wm', 'transient', win.epath, master)
- win
+ tk_call_without_enc('wm', 'transient', path, master)
+ self
else
- window(tk_call_without_enc('wm', 'transient', win.epath))
+ window(tk_call_without_enc('wm', 'transient', path))
end
end
- def transient(master=nil)
- Wm.transient(self, master)
- end
- alias wm_transient transient
TOPLEVEL_METHODCALL_OPTKEYS['transient'] = 'transient'
- def Wm.withdraw(win, ex = true)
+ def withdraw(ex = true)
if ex
- tk_call_without_enc('wm', 'withdraw', win.epath)
+ tk_call_without_enc('wm', 'withdraw', path)
else
- Wm.deiconify(win)
+ self.deiconify
end
- win
+ self
end
- def withdraw(ex = true)
- Wm.withdraw(self, ex)
- end
- alias wm_withdraw withdraw
- end
-
- module Wm_for_General
- Wm.instance_methods.each{|m|
- if (m = m.to_s) =~ /^wm_(.*)$/
- eval "def #{m}(*args, &b); Tk::Wm.#{$1}(self, *args, &b); end"
- end
- }
end
end
diff --git a/ext/tk/lib/tkclass.rb b/ext/tk/lib/tkclass.rb
index 87f5acc453..355b1a1b1d 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$
+# $Id: tkclass.rb,v 1.6.2.1 2004/10/11 04:51:06 nagai Exp $
require "tk"
diff --git a/ext/tk/lib/tkextlib/SUPPORT_STATUS b/ext/tk/lib/tkextlib/SUPPORT_STATUS
index cfbe274c86..8d7b6fc44a 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 => see 'tkextlib/version.rb' ***
+ *******<<< RELEASE_DATE of the libraries : 2005/12/11 >>>*******
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://sourceforge.net/projects/tcllib ==> tcllib
+Tklib 0.4.1 http://sf.net/projects/tcllib ==> tcllib
-IWidgets 4.0.2 http://sourceforge.net/projects/incrtcl ==> iwidgets
+IWidgets 4.0.2 http://sf.net/projects/incrTcl ==> iwidgets
-BWidgets 1.7 http://sourceforge.net/projects/tcllib ==> bwidget
+BWidgets 1.7 http://sf.net/projects/tcllib ==> bwidget
-TkTable 2.9 http://sourceforge.net/projects/tktable ==> tktable
+TkTable 2.9 http://sf.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://sourceforge.net/projects/tktable ==> vu
+vu 2.3.0 http://tktable.sourceforge.net ==> vu
-TkHTML 2.0 http://www.hwaci.com/sw/tkhtml/ ==> tkHTML
+TkHTML 2.0 http://www.hwaci.com/sw/tkhtml/index.html ==> tkHTML
ICONS 1.0 http://www.satisoft.com/tcltk/icons/ ==> ICONS
-TkImg 1.3 http://sourceforge.net/projects/tkimg ==> tkimg
+TkImg 1.3 http://sf.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://sourceforge.net/projects/tktreectrl ==> treectrl
+ http://tktreectrl.sourceforge.net/ ==> treectrl
-Tile 0.8.0/8.5.1
- http://sourceforge.net/projects/tktable ==> tile
+Tile CVS/Hd(2005-12-07)
+ http://tktable.sourceforge.net/tile/ ==> tile
===< support (may be alpha or beta quality) >=================================
IncrTcl CVS/Hd(2005-02-14)
- http://sourceforge.net/projects/incrtcl ==> itcl, itk
+ http://sf.net/projects/incrTcl ==> itcl, itk
TclX CVS/Hd(2005-02-07)
- http://sourceforge.net/projects/tclx
+ http://sf.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://sourceforge.net/projects/tktable
+ http://tktable.sourceforge.net
==> 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://sourceforge.net/projects/tkcon
+TkCon *** http://sf.net/projects/tkcon
-Expect *** http://sourceforge.net/projects/expect
+Expect *** http://sf.net/projects/expect
-TclXML *** http://sourceforge.net/projects/tclxml
+TclXML *** http://sf.net/projects/tclxml
-TclXSLT *** http://sourceforge.net/projects/tclxml
+TclXSLT *** http://sf.net/projects/tclxml
-TclDOM *** http://sourceforge.net/projects/tclxml
+TclDOM *** http://sf.net/projects/tclxml
-TclSOAP *** http://sourceforge.net/projects/tclsoap
+TclSOAP *** http://sf.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://sourceforge.net/projects/memchan
+Memchan *** http://memchan.sourceforge.net/
XOTcl *** http://www.xotcl.org/
diff --git a/ext/tk/lib/tkextlib/blt.rb b/ext/tk/lib/tkextlib/blt.rb
index 8d58c1f1bc..8ac8605513 100644
--- a/ext/tk/lib/tkextlib/blt.rb
+++ b/ext/tk/lib/tkextlib/blt.rb
@@ -26,14 +26,14 @@ module Tk
PATCH_LEVEL = tk_call('set', 'blt_patchLevel')
begin
- lib = TkCore::INTERP._invoke('set', 'blt_library')
+ lib = INTERP._invoke('set', 'blt_library')
rescue
lib = ''
end
LIBRARY = TkVarAccess.new('blt_library', lib)
begin
- lib = TkCore::INTERP._invoke('set', 'blt_libPath')
+ lib = INTERP._invoke('set', 'blt_libPath')
rescue
lib = ''
end
@@ -68,7 +68,7 @@ module Tk
params.concat(hash_kv(args.shift, true)) if args[0].kind_of?(Hash)
- params << '--' if args[0] =~ /^\s*-[^-]/
+ params << '--'
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 << '--' if args[0] =~ /^\s*-[^-]/
+ params << '--'
params.concat(args)
params << '&'
diff --git a/ext/tk/lib/tkextlib/blt/bitmap.rb b/ext/tk/lib/tkextlib/blt/bitmap.rb
index 23c6d2d064..31cf8d4229 100644
--- a/ext/tk/lib/tkextlib/blt/bitmap.rb
+++ b/ext/tk/lib/tkextlib/blt/bitmap.rb
@@ -13,16 +13,7 @@ module Tk::BLT
TkCommandNames = ['::blt::bitmap'.freeze].freeze
BITMAP_ID_TBL = TkCore::INTERP.create_table
-
- (BITMAP_ID = ['blt_bitmap_id'.freeze, '00000'.taint]).instance_eval{
- @mutex = Mutex.new
- def mutex; @mutex; end
- freeze
- }
-
- TkCore::INTERP.init_ip_env{
- BITMAP_ID_TBL.mutex.synchronize{ BITMAP_ID_TBL.clear }
- }
+ BITMAP_ID = ['blt_bitmap_id'.freeze, '00000'.taint].freeze
def self.data(name)
dat = tk_simple_list(tk_call('::blt::bitmap', 'data', name))
@@ -73,13 +64,9 @@ module Tk::BLT
if name
@id = name
else
- BITMAP_ID.mutex.synchronize{
- @id = BITMAP_ID.join(TkCore::INTERP._ip_id_)
- BITMAP_ID[1].succ!
- }
- BITMAP_ID_TBL.mutex.synchronize{
- BITMAP_ID_TBL[@id] = self
- }
+ @id = BITMAP_ID.join(TkCore::INTERP._ip_id_)
+ BITMAP_ID[1].succ!
+ BITMAP_ID_TBL[@id] = self
end
@path = @id
diff --git a/ext/tk/lib/tkextlib/blt/busy.rb b/ext/tk/lib/tkextlib/blt/busy.rb
index 2f807fcd9c..4726e466f4 100644
--- a/ext/tk/lib/tkextlib/blt/busy.rb
+++ b/ext/tk/lib/tkextlib/blt/busy.rb
@@ -19,7 +19,7 @@ module Tk::BLT
class Shield < TkWindow
def self.shield_path(win)
win = window(win) unless win.kind_of?(TkWindow)
- if win.kind_of?(Tk::Toplevel)
+ if win.kind_of?(TkToplevel)
win.path + '._Busy'
else
win.path + '_Busy'
diff --git a/ext/tk/lib/tkextlib/blt/component.rb b/ext/tk/lib/tkextlib/blt/component.rb
index b2005b2f2b..ad78a5430b 100644
--- a/ext/tk/lib/tkextlib/blt/component.rb
+++ b/ext/tk/lib/tkextlib/blt/component.rb
@@ -85,9 +85,6 @@ module Tk::BLT
def axis_cget(id, option)
ret = itemcget(['axis', tagid(id)], option)
end
- def axis_cget_strict(id, option)
- ret = itemcget_strict(['axis', tagid(id)], option)
- end
def axis_configure(*args)
slot = args.pop
if slot.kind_of?(Hash)
@@ -121,9 +118,6 @@ module Tk::BLT
def crosshairs_cget(option)
itemcget('crosshairs', option)
end
- def crosshairs_cget_strict(option)
- itemcget_strict('crosshairs', option)
- end
def crosshairs_configure(slot, value=None)
itemconfigure('crosshairs', slot, value)
end
@@ -137,9 +131,6 @@ module Tk::BLT
def element_cget(id, option)
itemcget(['element', tagid(id)], option)
end
- def element_cget_strict(id, option)
- itemcget_strict(['element', tagid(id)], option)
- end
def element_configure(*args)
slot = args.pop
if slot.kind_of?(Hash)
@@ -161,9 +152,6 @@ module Tk::BLT
def bar_cget(id, option)
itemcget(['bar', tagid(id)], option)
end
- def bar_cget_strict(id, option)
- itemcget_strict(['bar', tagid(id)], option)
- end
def bar_configure(*args)
slot = args.pop
if slot.kind_of?(Hash)
@@ -185,9 +173,6 @@ module Tk::BLT
def line_cget(id, option)
itemcget(['line', tagid(id)], option)
end
- def line_cget_strict(id, option)
- itemcget_strict(['line', tagid(id)], option)
- end
def line_configure(*args)
slot = args.pop
if slot.kind_of?(Hash)
@@ -209,9 +194,6 @@ module Tk::BLT
def gridline_cget(option)
itemcget('grid', option)
end
- def gridline_cget_strict(option)
- itemcget_strict('grid', option)
- end
def gridline_configure(slot, value=None)
itemconfigure('grid', slot, value)
end
@@ -225,9 +207,6 @@ module Tk::BLT
def legend_cget(option)
itemcget('legend', option)
end
- def legend_cget_strict(option)
- itemcget_strict('legend', option)
- end
def legend_configure(slot, value=None)
itemconfigure('legend', slot, value)
end
@@ -241,9 +220,6 @@ module Tk::BLT
def pen_cget(id, option)
itemcget(['pen', tagid(id)], option)
end
- def pen_cget_strict(id, option)
- itemcget_strict(['pen', tagid(id)], option)
- end
def pen_configure(*args)
slot = args.pop
if slot.kind_of?(Hash)
@@ -265,9 +241,6 @@ module Tk::BLT
def postscript_cget(option)
itemcget('postscript', option)
end
- def postscript_cget_strict(option)
- itemcget_strict('postscript', option)
- end
def postscript_configure(slot, value=None)
itemconfigure('postscript', slot, value)
end
@@ -281,9 +254,6 @@ module Tk::BLT
def marker_cget(id, option)
itemcget(['marker', tagid(id)], option)
end
- def marker_cget_strict(id, option)
- itemcget_strict(['marker', tagid(id)], option)
- end
def marker_configure(*args)
slot = args.pop
if slot.kind_of?(Hash)
@@ -303,12 +273,11 @@ module Tk::BLT
end
alias __itemcget itemcget
- alias __itemcget_strict itemcget_strict
alias __itemconfiginfo itemconfiginfo
alias __current_itemconfiginfo current_itemconfiginfo
private :__itemcget, :__itemconfiginfo, :__current_itemconfiginfo
- def itemcget_strict(tagOrId, option)
+ def itemcget(tagOrId, option)
ret = __itemcget(tagid(tagOrId), option)
if option == 'bindtags' || option == :bindtags
ret.collect{|tag| TkBindTag.id2obj(tag)}
@@ -316,27 +285,6 @@ module Tk::BLT
ret
end
end
- def itemcget(tagOrId, option)
- unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
- itemcget_strict(tagOrId, option)
- else
- begin
- itemcget_strict(tagOrId, option)
- rescue => e
- begin
- if current_itemconfiginfo(tagOrId).has_key?(option.to_s)
- # error on known option
- fail e
- else
- # unknown option
- nil
- end
- rescue
- fail e # tag error
- end
- end
- end
- end
def itemconfiginfo(tagOrId, slot = nil)
ret = __itemconfiginfo(tagid(tagOrId), slot)
@@ -373,30 +321,19 @@ module Tk::BLT
ret
end
- private :itemcget, :itemcget_strict
- private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+ private :itemcget, :itemconfigure
+ private :itemconfiginfo, :current_itemconfiginfo
#################
class Axis < TkObject
- (OBJ_ID = ['blt_chart_axis'.freeze, '00000'.taint]).instance_eval{
- @mutex = Mutex.new
- def mutex; @mutex; end
- freeze
- }
-
- AxisID_TBL = TkCore::INTERP.create_table
-
- TkCore::INTERP.init_ip_env{
- AxisID_TBL.mutex.synchronize{ AxisID_TBL.clear }
- }
+ OBJ_ID = ['blt_chart_axis'.freeze, '00000'.taint].freeze
+ OBJ_TBL={}
def self.id2obj(chart, id)
cpath = chart.path
- AxisID_TBL.mutex.synchronize{
- return id unless AxisID_TBL[cpath]
- AxisID_TBL[cpath][id]? AxisID_TBL[cpath][id]: id
- }
+ return id unless OBJ_TBL[cpath]
+ OBJ_TBL[cpath][id]? OBJ_TBL[cpath][id]: id
end
def self.new(chart, axis=nil, keys={})
@@ -404,48 +341,12 @@ module Tk::BLT
keys = axis
axis = nil
end
- if keys
- keys = _symbolkey2str(keys)
- not_create = keys.delete('without_creating')
- else
- not_create = false
- end
-
- obj = nil
- AxisID_TBL.mutex.synchronize{
- chart_path = chart.path
- AxisID_TBL[chart_path] ||= {}
- if axis && AxisID_TBL[chart_path][axis]
- obj = AxisID_TBL[chart_path][axis]
- else
- (obj = self.allocate).instance_eval{
- if axis
- @axis = @id = axis.to_s
- else
- OBJ_ID.mutex.synchronize{
- @axis = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze
- OBJ_ID[1].succ!
- }
- end
- @path = @id
- @parent = @chart = chart
- @cpath = @chart.path
- Axis::AxisID_TBL[@cpath][@axis] = self
- unless not_create
- tk_call(@chart, 'axis', 'create', @axis, keys)
- return obj
- end
- }
- end
- }
-
- obj.configure(keys) if obj && ! keys.empty?
- obj
+ OBJ_TBL[chart.path] = {} unless OBJ_TBL[chart.path]
+ return OBJ_TBL[chart.path][axis] if axis && OBJ_TBL[chart.path][axis]
+ super(chart, axis, keys)
end
def initialize(chart, axis=nil, keys={})
- # dummy:: not called by 'new' method
-
if axis.kind_of?(Hash)
keys = axis
axis = nil
@@ -453,15 +354,13 @@ module Tk::BLT
if axis
@axis = @id = axis.to_s
else
- OBJ_ID.mutex.synchronize{
- @axis = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze
- OBJ_ID[1].succ!
- }
+ @axis = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze
+ OBJ_ID[1].succ!
end
@path = @id
@parent = @chart = chart
@cpath = @chart.path
- # Axis::AxisID_TBL[@cpath][@axis] = self
+ Axis::OBJ_TBL[@cpath][@axis] = self
keys = _symbolkey2str(keys)
unless keys.delete('without_creating')
# @chart.axis_create(@axis, keys)
@@ -480,9 +379,6 @@ module Tk::BLT
def cget(option)
@chart.axis_cget(@id, option)
end
- def cget_strict(option)
- @chart.axis_cget_strict(@id, option)
- end
def configure(key, value=None)
@chart.axis_configure(@id, key, value)
self
@@ -542,34 +438,17 @@ module Tk::BLT
#################
class Crosshairs < TkObject
- CrosshairsID_TBL = TkCore::INTERP.create_table
-
- TkCore::INTERP.init_ip_env{
- CrosshairsID_TBL.mutex.synchronize{ CrosshairsID_TBL.clear }
- }
+ OBJ_TBL={}
def self.new(chart, keys={})
- obj = nil
- CrosshairsID_TBL.mutex.synchronize{
- unless (obj = CrosshairsID_TBL[chart.path])
- (obj = self.allocate).instance_eval{
- @parent = @chart = chart
- @cpath = @chart.path
- @path = @id = 'crosshairs'
- Crosshairs::CrosshairsID_TBL[@cpath] = self
- }
- end
- }
- chart.crosshair_configure(keys) if obj && ! keys.empty?
- obj
+ return OBJ_TBL[chart.path] if OBJ_TBL[chart.path]
+ super(chart, keys)
end
def initialize(chart, keys={})
- # dummy:: not called by 'new' method
-
@parent = @chart = chart
@cpath = @chart.path
- # Crosshairs::CrosshairsID_TBL[@cpath] = self
+ Crosshairs::OBJ_TBL[@cpath] = self
@chart.crosshair_configure(keys) unless keys.empty?
@path = @id = 'crosshairs'
end
@@ -585,9 +464,6 @@ module Tk::BLT
def cget(option)
@chart.crosshair_cget(option)
end
- def cget_strict(option)
- @chart.crosshair_cget_strict(option)
- end
def configure(key, value=None)
@chart.crosshair_configure(key, value)
self
@@ -624,18 +500,12 @@ module Tk::BLT
ElementTypeName = 'element'
ElementTypeToClass = { ElementTypeName=>self }
-
ElementID_TBL = TkCore::INTERP.create_table
- TkCore::INTERP.init_ip_env{
- ElementID_TBL.mutex.synchronize{ ElementID_TBL.clear }
- }
+ TkCore::INTERP.init_ip_env{ ElementID_TBL.clear }
- (OBJ_ID = ['blt_chart_element'.freeze, '00000'.taint]).instance_eval{
- @mutex = Mutex.new
- def mutex; @mutex; end
- freeze
- }
+ OBJ_ID = ['blt_chart_element'.freeze, '00000'.taint].freeze
+ OBJ_TBL={}
def Element.type2class(type)
ElementTypeToClass[type]
@@ -643,10 +513,8 @@ module Tk::BLT
def Element.id2obj(chart, id)
cpath = chart.path
- ElementID_TBL.mutex.synchronize{
- return id unless ElementID_TBL[cpath]
- ElementID_TBL[cpath][id]? ElementID_TBL[cpath][id]: id
- }
+ return id unless OBJ_TBL[cpath]
+ OBJ_TBL[cpath][id]? OBJ_TBL[cpath][id]: id
end
def self.new(chart, element=nil, keys={})
@@ -654,49 +522,14 @@ module Tk::BLT
keys = element
element = nil
end
- if keys
- keys = _symbolkey2str(keys)
- not_create = keys.delete('without_creating')
- else
- not_create = false
+ OBJ_TBL[chart.path] = {} unless OBJ_TBL[chart.path]
+ if element && OBJ_TBL[chart.path][element]
+ return OBJ_TBL[chart.path][element]
end
-
- obj = nil
- ElementID_TBL.mutex.synchronize{
- chart_path = chart.path
- ElementID_TBL[chart_path] ||= {}
- if element && ElementID_TBL[chart_path][element]
- obj = ElementID_TBL[chart_path][element]
- else
- (obj = self.allocate).instance_eval{
- if element
- @element = @id = element.to_s
- else
- OBJ_ID.mutex.synchronize{
- @element = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze
- OBJ_ID[1].succ!
- }
- end
- @path = @id
- @parent = @chart = chart
- @cpath = @chart.path
- @typename = self.class::ElementTypeName
- Element::ElementID_TBL[@cpath][@element] = self
- unless not_create
- tk_call(@chart, @typename, 'create', @element, keys)
- return obj
- end
- }
- end
- }
-
- obj.configure(keys) if obj && ! keys.empty?
- obj
+ super(chart, element, keys)
end
def initialize(chart, element=nil, keys={})
- # dummy:: not called by 'new' method
-
if element.kind_of?(Hash)
keys = element
element = nil
@@ -704,16 +537,14 @@ module Tk::BLT
if element
@element = @id = element.to_s
else
- OBJ_ID.mutex.synchronize{
- @element = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze
- OBJ_ID[1].succ!
- }
+ @element = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze
+ OBJ_ID[1].succ!
end
@path = @id
@parent = @chart = chart
@cpath = @chart.path
@typename = self.class::ElementTypeName
- # Element::ElementID_TBL[@cpath][@element] = self
+ Element::OBJ_TBL[@cpath][@element] = self
keys = _symbolkey2str(keys)
unless keys.delete('without_creating')
# @chart.element_create(@element, keys)
@@ -733,9 +564,6 @@ module Tk::BLT
# @chart.element_cget(@id, option)
@chart.__send__(@typename + '_cget', @id, option)
end
- def cget_strict(option)
- @chart.__send__(@typename + '_cget_strict', @id, option)
- end
def configure(key, value=None)
# @chart.element_configure(@id, key, value)
@chart.__send__(@typename + '_configure', @id, key, value)
@@ -794,33 +622,17 @@ module Tk::BLT
#################
class GridLine < TkObject
- GridLineID_TBL = TkCore::INTERP.create_table
- TkCore::INTERP.init_ip_env{
- GridLineID_TBL.mutex.synchronize{ GridLineID_TBL.clear }
- }
+ OBJ_TBL={}
def self.new(chart, keys={})
- obj = nil
- GridLineID_TBL.mutex.synchronize{
- unless (obj = GridLineID_TBL[chart.path])
- (obj = self.allocate).instance_eval{
- @parent = @chart = chart
- @cpath = @chart.path
- @path = @id = 'grid'
- GridLine::GridLineID_TBL[@cpath] = self
- }
- end
- }
- chart.gridline_configure(keys) if obj && ! keys.empty?
- obj
+ return OBJ_TBL[chart.path] if OBJ_TBL[chart.path]
+ super(chart, keys)
end
def initialize(chart, keys={})
- # dummy:: not called by 'new' method
-
@parent = @chart = chart
@cpath = @chart.path
- # GridLine::GridLineID_TBL[@cpath] = self
+ GridLine::OBJ_TBL[@cpath] = self
@chart.gridline_configure(keys) unless keys.empty?
@path = @id = 'grid'
end
@@ -836,9 +648,6 @@ module Tk::BLT
def cget(option)
@chart.gridline_cget(option)
end
- def cget_strict(option)
- @chart.gridline_cget_strict(option)
- end
def configure(key, value=None)
@chart.gridline_configure(key, value)
self
@@ -867,35 +676,18 @@ module Tk::BLT
#################
class Legend < TkObject
- LegendID_TBL = TkCore::INTERP.create_table
-
- TkCore::INTERP.init_ip_env{
- LegendID_TBL.mutex.synchronize{ LegendID_TBL.clear }
- }
+ OBJ_TBL={}
def self.new(chart, keys={})
- obj = nil
- LegenedID_TBL.mutex.synchronize{
- unless (obj = LegenedID_TBL[chart.path])
- (obj = self.allocate).instance_eval{
- @parent = @chart = chart
- @cpath = @chart.path
- @path = @id = 'crosshairs'
- Legend::LegenedID_TBL[@cpath] = self
- }
- end
- }
- chart.legend_configure(keys) if obj && ! keys.empty?
- obj
+ return OBJ_TBL[chart.path] if OBJ_TBL[chart.path]
+ super(chart, keys)
end
def initialize(chart, keys={})
- # dummy:: not called by 'new' method
-
@parent = @chart = chart
@cpath = @chart.path
- # Legend::LegendID_TBL[@cpath] = self
- @chart.legend_configure(keys) unless keys.empty?
+ Crosshairs::OBJ_TBL[@cpath] = self
+ @chart.crosshair_configure(keys) unless keys.empty?
@path = @id = 'legend'
end
@@ -910,9 +702,6 @@ module Tk::BLT
def cget(option)
@chart.legend_cget(option)
end
- def cget_strict(option)
- @chart.legend_cget_strict(option)
- end
def configure(key, value=None)
@chart.legend_configure(key, value)
self
@@ -940,24 +729,13 @@ module Tk::BLT
#################
class Pen < TkObject
- (OBJ_ID = ['blt_chart_pen'.freeze, '00000'.taint]).instance_eval{
- @mutex = Mutex.new
- def mutex; @mutex; end
- freeze
- }
-
- PenID_TBL = TkCore::INTERP.create_table
-
- TkCore::INTERP.init_ip_env{
- PenID_TBL.mutex.synchronize{ PenID_TBL.clear }
- }
+ OBJ_ID = ['blt_chart_pen'.freeze, '00000'.taint].freeze
+ OBJ_TBL={}
def self.id2obj(chart, id)
cpath = chart.path
- PenID_TBL.mutex.synchronize{
- return id unless PenID_TBL[cpath]
- PenID_TBL[cpath][id]? PenID_TBL[cpath][id]: id
- }
+ return id unless OBJ_TBL[cpath]
+ OBJ_TBL[cpath][id]? OBJ_TBL[cpath][id]: id
end
def self.new(chart, pen=nil, keys={})
@@ -965,43 +743,9 @@ module Tk::BLT
keys = pen
pen = nil
end
- if keys
- keys = _symbolkey2str(keys)
- not_create = keys.delete('without_creating')
- else
- not_create = false
- end
-
- obj = nil
- PenID_TBL.mutex.synchronize{
- chart_path = chart.path
- PenID_TBL[chart_path] ||= {}
- if pen && PenID_TBL[chart_path][pen]
- obj = PenID_TBL[chart_path][pen]
- else
- (obj = self.allocate).instance_eval{
- if pen
- @pen = @id = pen.to_s
- else
- OBJ_ID.mutex.synchronize{
- @pen = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze
- OBJ_ID[1].succ!
- }
- end
- @path = @id
- @parent = @chart = chart
- @cpath = @chart.path
- Pen::PenID_TBL[@cpath][@pen] = self
- unless not_create
- tk_call(@chart, 'pen', 'create', @pen, keys)
- return obj
- end
- }
- end
- }
-
- obj.configure(keys) if obj && ! keys.empty?
- obj
+ OBJ_TBL[chart.path] = {} unless OBJ_TBL[chart.path]
+ return OBJ_TBL[chart.path][pen] if pen && OBJ_TBL[chart.path][pen]
+ super(chart, pen, keys)
end
def initialize(chart, pen=nil, keys={})
@@ -1012,15 +756,13 @@ module Tk::BLT
if pen
@pen = @id = pen.to_s
else
- OBJ_ID.mutex.synchronize{
- @pen = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze
- OBJ_ID[1].succ!
- }
+ @pen = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze
+ OBJ_ID[1].succ!
end
@path = @id
@parent = @chart = chart
@cpath = @chart.path
- Pen::PenID_TBL[@cpath][@pen] = self
+ Pen::OBJ_TBL[@cpath][@pen] = self
keys = _symbolkey2str(keys)
unless keys.delete('without_creating')
# @chart.pen_create(@pen, keys)
@@ -1039,9 +781,6 @@ module Tk::BLT
def cget(option)
@chart.pen_cget(@id, option)
end
- def cget_strict(option)
- @chart.pen_cget_strict(@id, option)
- end
def configure(key, value=None)
@chart.pen_configure(@id, key, value)
self
@@ -1066,34 +805,17 @@ module Tk::BLT
#################
class Postscript < TkObject
- PostscriptID_TBL = TkCore::INTERP.create_table
-
- TkCore::INTERP.init_ip_env{
- PostscriptID_TBL.mutex.synchronize{ PostscriptID_TBL.clear }
- }
+ OBJ_TBL={}
def self.new(chart, keys={})
- obj = nil
- PostscriptID_TBL.mutex.synchronize{
- unless (obj = PostscriptID_TBL[chart.path])
- (obj = self.allocate).instance_eval{
- @parent = @chart = chart
- @cpath = @chart.path
- @path = @id = 'postscript'
- Postscript::PostscriptID_TBL[@cpath] = self
- }
- end
- }
- chart.postscript_configure(keys) if obj && ! keys.empty?
- obj
+ return OBJ_TBL[chart.path] if OBJ_TBL[chart.path]
+ super(chart, keys)
end
def initialize(chart, keys={})
- # dummy:: not called by 'new' method
-
@parent = @chart = chart
@cpath = @chart.path
- # Postscript::PostscriptID_TBL[@cpath] = self
+ Postscript::OBJ_TBL[@cpath] = self
@chart.postscript_configure(keys) unless keys.empty?
@path = @id = 'postscript'
end
@@ -1109,9 +831,6 @@ module Tk::BLT
def cget(option)
@chart.postscript_cget(option)
end
- def cget_strict(option)
- @chart.postscript_cget_strict(option)
- end
def configure(key, value=None)
@chart.postscript_configure(key, value)
self
@@ -1151,9 +870,7 @@ module Tk::BLT
MarkerTypeToClass = {}
MarkerID_TBL = TkCore::INTERP.create_table
- TkCore::INTERP.init_ip_env{
- MarkerID_TBL.mutex.synchronize{ MarkerID_TBL.clear }
- }
+ TkCore::INTERP.init_ip_env{ MarkerID_TBL.clear }
def Marker.type2class(type)
MarkerTypeToClass[type]
@@ -1161,13 +878,8 @@ module Tk::BLT
def Marker.id2obj(chart, id)
cpath = chart.path
- MarkerID_TBL.mutex.synchronize{
- if MarkerID_TBL[cpath]
- MarkerID_TBL[cpath][id]? MarkerID_TBL[cpath][id]: id
- else
- id
- end
- }
+ return id unless MarkerID_TBL[cpath]
+ MarkerID_TBL[cpath][id]? MarkerID_TBL[cpath][id]: id
end
def self._parse_create_args(keys)
@@ -1190,13 +902,6 @@ module Tk::BLT
fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
}
- __item_optkey_aliases(nil).each{|alias_name, real_name|
- alias_name = alias_name.to_s
- if keys.has_key?(alias_name)
- keys[real_name.to_s] = keys.delete(alias_name)
- end
- }
-
__item_methodcall_optkeys(nil).each{|key|
key = key.to_s
methodkeys[key] = keys.delete(key) if keys.key?(key)
@@ -1238,10 +943,10 @@ module Tk::BLT
@parent = @chart = chart
@cpath = chart.path
@id = id
- Tk::BLT::PlotComponent::Marker::MarkerID_TBL.mutex.synchronize{
- Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath] ||= {}
- Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath][@id] = self
- }
+ unless Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath]
+ Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath] = {}
+ end
+ Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath][@id] = self
}
obj
end
@@ -1251,10 +956,10 @@ module Tk::BLT
@cpath = parent.path
@path = @id = create_self(*args) # an integer number as 'item id'
- Tk::BLT::PlotComponent::Marker::MarkerID_TBL.mutex.synchronize{
- Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath] ||= {}
- Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath][@id] = self
- }
+ unless Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath]
+ Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath] = {}
+ end
+ Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath][@id] = self
end
def create_self(*args)
self.class.create(@chart, *args) # return an integer as 'item id'
@@ -1272,9 +977,6 @@ module Tk::BLT
def cget(option)
@chart.marker_cget(@id, option)
end
- def cget_strict(option)
- @chart.marker_cget_strict(@id, option)
- end
def configure(key, value=None)
@chart.marker_configure(@id, key, value)
self
@@ -1335,14 +1037,14 @@ module Tk::BLT
#################
def __destroy_hook__
- Axis::AxisID_TBL.delete(@path)
- Crosshairs::CrosshairsID_TBL.delete(@path)
- Element::ElementID_TBL.delete(@path)
- GridLine::GridLineID_TBL.delete(@path)
- Legend::LegendID_TBL.delete(@path)
- Pen::PenID_TBL.delete(@path)
- Postscript::PostscriptID_TBL.delete(@path)
- Marker::MarkerID_TBL.delete(@path)
+ Axis::OBJ_TBL.delete(@path)
+ Crosshairs::OBJ_TBL.delete(@path)
+ Element::OBJ_TBL.delete(@path)
+ GridLine::OBJ_TBL.delete(@path)
+ Legend::OBJ_TBL.delete(@path)
+ Pen::OBJ_TBL.delete(@path)
+ Postscript::OBJ_TBL.delete(@path)
+ Marker::OBJ_TBL.delete(@path)
super()
end
@@ -1857,9 +1559,6 @@ module Tk::BLT
def xaxis_cget(option)
itemcget('xaxis', option)
end
- def xaxis_cget_strict(option)
- itemcget_strict('xaxis', option)
- end
def xaxis_configure(slot, value=None)
if slot.kind_of?(Hash)
slot = _symbolkey2str(slot)
@@ -1929,9 +1628,6 @@ module Tk::BLT
def x2axis_cget(option)
itemcget('x2axis', option)
end
- def x2axis_cget_strict(option)
- itemcget_strict('x2axis', option)
- end
def x2axis_configure(slot, value=None)
if slot.kind_of?(Hash)
slot = _symbolkey2str(slot)
@@ -2001,9 +1697,6 @@ module Tk::BLT
def yaxis_cget(option)
itemcget('yaxis', option)
end
- def yaxis_cget_strict(option)
- itemcget_strict('yaxis', option)
- end
def yaxis_configure(slot, value=None)
if slot.kind_of?(Hash)
slot = _symbolkey2str(slot)
@@ -2073,9 +1766,6 @@ module Tk::BLT
def y2axis_cget(option)
itemcget('y2axis', option)
end
- def y2axis_cget_strict(option)
- itemcget_strict('y2axis', option)
- end
def y2axis_configure(slot, value=None)
if slot.kind_of?(Hash)
slot = _symbolkey2str(slot)
diff --git a/ext/tk/lib/tkextlib/blt/container.rb b/ext/tk/lib/tkextlib/blt/container.rb
index cdbec21f25..60ba1dec1e 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)
- Hash[*simplelist(tk_send_without_enc('find', '-command', pat))]
- end
+ def find_command(pat)
+ list(tk_send_without_enc(tk_call(self.path, 'find', '-command', pat)))
+ end
- def find_name(pat)
- Hash[*simplelist(tk_send_without_enc('find', '-name', pat))]
- end
+ def find_name(pat)
+ list(tk_send_without_enc(tk_call(self.path, 'find', '-name', pat)))
end
end
diff --git a/ext/tk/lib/tkextlib/blt/dragdrop.rb b/ext/tk/lib/tkextlib/blt/dragdrop.rb
index 201548504a..68fb9e591a 100644
--- a/ext/tk/lib/tkextlib/blt/dragdrop.rb
+++ b/ext/tk/lib/tkextlib/blt/dragdrop.rb
@@ -81,24 +81,6 @@ module Tk::BLT
nil
]
-=begin
- # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
- KEY_TBL.map!{|inf|
- if inf.kind_of?(Array)
- inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
- inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
- end
- inf
- }
-
- PROC_TBL.map!{|inf|
- if inf.kind_of?(Array)
- inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
- end
- inf
- }
-=end
-
_setup_subst_table(KEY_TBL, PROC_TBL)
def self.ret_val(val)
@@ -125,24 +107,6 @@ module Tk::BLT
nil
]
-=begin
- # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
- KEY_TBL.map!{|inf|
- if inf.kind_of?(Array)
- inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
- inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
- end
- inf
- }
-
- PROC_TBL.map!{|inf|
- if inf.kind_of?(Array)
- inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
- end
- inf
- }
-=end
-
_setup_subst_table(KEY_TBL, PROC_TBL)
def self.ret_val(val)
@@ -181,24 +145,6 @@ module Tk::BLT
nil
]
-=begin
- # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
- KEY_TBL.map!{|inf|
- if inf.kind_of?(Array)
- inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
- inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
- end
- inf
- }
-
- PROC_TBL.map!{|inf|
- if inf.kind_of?(Array)
- inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
- end
- inf
- }
-=end
-
_setup_subst_table(KEY_TBL, PROC_TBL)
end
diff --git a/ext/tk/lib/tkextlib/blt/eps.rb b/ext/tk/lib/tkextlib/blt/eps.rb
index 0dba87a7cc..586a42470c 100644
--- a/ext/tk/lib/tkextlib/blt/eps.rb
+++ b/ext/tk/lib/tkextlib/blt/eps.rb
@@ -14,7 +14,7 @@ module Tk::BLT
end
end
-class Tk::Canvas
+class TkCanvas
alias __BLT_EPS_item_strval_optkeys __item_strval_optkeys
def __item_strval_optkeys(id)
__BLT_EPS_item_strval_optkeys(id) + [
diff --git a/ext/tk/lib/tkextlib/blt/htext.rb b/ext/tk/lib/tkextlib/blt/htext.rb
index 0d9cb30185..a0cf3dc036 100644
--- a/ext/tk/lib/tkextlib/blt/htext.rb
+++ b/ext/tk/lib/tkextlib/blt/htext.rb
@@ -22,7 +22,6 @@ module Tk::BLT
WidgetClassNames[WidgetClassName] = self
alias window_cget itemcget
- alias window_cget_strict itemcget_strict
alias window_configure itemconfigure
alias window_configuinfo itemconfiginfo
alias current_window_configuinfo current_itemconfiginfo
diff --git a/ext/tk/lib/tkextlib/blt/table.rb b/ext/tk/lib/tkextlib/blt/table.rb
index dfa10269ed..fc1bf54e65 100644
--- a/ext/tk/lib/tkextlib/blt/table.rb
+++ b/ext/tk/lib/tkextlib/blt/table.rb
@@ -17,103 +17,97 @@ module Tk::BLT
module TableContainer
def blt_table_add(*args)
- Tk::BLT::Table.add(self, *args)
+ Tk::BLT::Table.add(@path, *args)
self
end
def blt_table_arrange()
- Tk::BLT::Table.arrange(self)
+ Tk::BLT::Table.arrange(@path)
self
end
def blt_table_cget(*args)
- Tk::BLT::Table.cget(self, *args)
- end
- def blt_table_cget_strict(*args)
- Tk::BLT::Table.cget_strict(self, *args)
+ Tk::BLT::Table.cget(@path, *args)
end
def blt_table_configure(*args)
- Tk::BLT::Table.configure(self, *args)
+ Tk::BLT::Table.configure(@path, *args)
self
end
def blt_table_configinfo(*args)
- Tk::BLT::Table.configinfo(self, *args)
+ Tk::BLT::Table.configinfo(@path, *args)
end
def blt_table_current_configinfo(*args)
- Tk::BLT::Table.current_configinfo(self, *args)
+ Tk::BLT::Table.current_configinfo(@path, *args)
end
def blt_table_locate(x, y)
- Tk::BLT::Table.locate(self, x, y)
+ Tk::BLT::Table.locate(@path, x, y)
end
def blt_table_delete(*args)
- Tk::BLT::Table.delete(self, *args)
+ Tk::BLT::Table.delete(@path, *args)
self
end
def blt_table_extents(item)
- Tk::BLT::Table.extents(self, item)
+ Tk::BLT::Table.extents(@path, item)
end
def blt_table_insert(*args)
- Tk::BLT::Table.insert(self, *args)
+ Tk::BLT::Table.insert(@path, *args)
self
end
def blt_table_insert_before(*args)
- Tk::BLT::Table.insert_before(self, *args)
+ Tk::BLT::Table.insert_before(@path, *args)
self
end
def blt_table_insert_after(*args)
- Tk::BLT::Table.insert_after(self, *args)
+ Tk::BLT::Table.insert_after(@path, *args)
self
end
def blt_table_join(first, last)
- Tk::BLT::Table.join(self, first, last)
+ Tk::BLT::Table.join(@path, first, last)
self
end
def blt_table_save()
- Tk::BLT::Table.save(self)
+ Tk::BLT::Table.save(@path)
end
def blt_table_search(*args)
- Tk::BLT::Table.search(self, *args)
+ Tk::BLT::Table.search(@path, *args)
end
def blt_table_split(*args)
- Tk::BLT::Table.split(self, *args)
+ Tk::BLT::Table.split(@path, *args)
self
end
def blt_table_itemcget(*args)
- Tk::BLT::Table.itemcget(self, *args)
- end
- def blt_table_itemcget_strict(*args)
- Tk::BLT::Table.itemcget_strict(self, *args)
+ Tk::BLT::Table.itemcget(@path, *args)
end
def blt_table_itemconfigure(*args)
- Tk::BLT::Table.itemconfigure(self, *args)
+ Tk::BLT::Table.itemconfigure(@path, *args)
self
end
def blt_table_itemconfiginfo(*args)
- Tk::BLT::Table.itemconfiginfo(self, *args)
+ Tk::BLT::Table.itemconfiginfo(@path, *args)
end
def blt_table_current_itemconfiginfo(*args)
- Tk::BLT::Table.current_itemconfiginfo(self, *args)
+ Tk::BLT::Table.current_itemconfiginfo(@path, *args)
end
def blt_table_iteminfo(item)
- Tk::BLT::Table.iteminfo(self, item)
+ Tk::BLT::Table.iteminfo(@path, item)
end
end
end
@@ -123,32 +117,28 @@ end
############################################
class << Tk::BLT::Table
def __item_cget_cmd(id) # id := [ container, item ]
- win = (id[0].kind_of?(TkWindow))? id[0].path: id[0].to_s
- ['::blt::table', 'cget', win, id[1]]
+ ['::blt::table', 'cget', id[0].path, id[1]]
end
private :__item_cget_cmd
def __item_config_cmd(id) # id := [ container, item, ... ]
container, *items = id
- win = (container.kind_of?(TkWindow))? container.path: container.to_s
- ['::blt::table', 'configure', win, *items]
+ ['::blt::table', 'configure', container.path, *items]
end
private :__item_config_cmd
def __item_pathname(id)
- win = (id[0].kind_of?(TkWindow))? id[0].path: id[0].to_s
- win + ';'
+ id[0].path + ';'
end
private :__item_pathname
alias __itemcget itemcget
- alias __itemcget_strict itemcget_strict
alias __itemconfigure itemconfigure
alias __itemconfiginfo itemconfiginfo
alias __current_itemconfiginfo current_itemconfiginfo
- private :__itemcget, :__itemcget_strict
- private :__itemconfigure, :__itemconfiginfo, :__current_itemconfiginfo
+ private :__itemcget, :__itemconfigure
+ private :__itemconfiginfo, :__current_itemconfiginfo
def __boolval_optkeys
super() << 'propagate'
@@ -183,9 +173,6 @@ class << Tk::BLT::Table
def cget(container, option)
__itemcget([container], option)
end
- def cget_strict(container, option)
- __itemcget_strict([container], option)
- end
def configure(container, *args)
__itemconfigure([container], *args)
@@ -202,15 +189,11 @@ class << Tk::BLT::Table
def itemcget(container, item, option)
__itemcget([container, tagid(item)], option)
end
- def itemcget_strict(container, item, option)
- __itemcget_strict([container, tagid(item)], option)
- end
def itemconfigure(container, *args)
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)
@@ -218,12 +201,10 @@ 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)
@@ -241,35 +222,11 @@ 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))
@@ -281,22 +238,12 @@ class << Tk::BLT::Table
end
def iteminfo(container, item)
- 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
+ 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]
end
-
ret
end
@@ -306,7 +253,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?)')
@@ -329,12 +276,10 @@ 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/tabset.rb b/ext/tk/lib/tkextlib/blt/tabset.rb
index ca81ad8f95..c26b6ee001 100644
--- a/ext/tk/lib/tkextlib/blt/tabset.rb
+++ b/ext/tk/lib/tkextlib/blt/tabset.rb
@@ -12,26 +12,14 @@ module Tk::BLT
include TkTreatItemFont
TabID_TBL = TkCore::INTERP.create_table
+ TabsetTab_ID = ['blt_tabset_tab'.freeze, '00000'.taint].freeze
- (TabsetTab_ID = ['blt_tabset_tab'.freeze, '00000'.taint]).instance_eval{
- @mutex = Mutex.new
- def mutex; @mutex; end
- freeze
- }
-
- TkCore::INTERP.init_ip_env{
- TabID_TBL.mutex.synchronize{ TabID_TBL.clear }
- }
+ TkCore::INTERP.init_ip_env{ TabID_TBL.clear }
def self.id2obj(tabset, id)
tpath = tabset.path
- TabID_TBL.mutex.synchronize{
- if TabID_TBL[tpath]
- TabID_TBL[tpath][id]? TabID_TBL[tpath]: id
- else
- id
- end
- }
+ return id unless TabID_TBL[tpath]
+ TabID_TBL[tpath][id]? TabID_TBL[tpath]: id
end
def self.new(parent, pos=nil, name=nil, keys={})
@@ -44,20 +32,12 @@ module Tk::BLT
keys = name
name = nil
end
- obj = nil
- TabID_TBL.mutex.synchronize{
- if name && TabID_TBL[parent.path] && TabID_TBL[parent.path][name]
- obj = TabID_TBL[parent.path][name]
- obj.configure if keys && ! keys.empty?
- else
- (obj = self.allocate).instance_eval{
- initialize(parent, pos, name, keys)
- TabID_TBL[@tpath] = {} unless TabID_TBL[@tpath]
- TabID_TBL[@tpath][@id] = self
- }
- end
- }
- obj
+
+ if name && TabID_TBL[parent.path] && TabID_TBL[parent.path][name]
+ TabID_TBL[parent.path][name]
+ else
+ super(parent, pos, name, keys)
+ end
end
def initialize(parent, pos, name, keys)
@@ -65,6 +45,9 @@ module Tk::BLT
@tpath = parent.path
if name
@path = @id = name
+ TabID_TBL[@tpath] = {} unless TabID_TBL[@tpath]
+ TabID_TBL[@tpath][@id] = self
+
unless (list(tk_call(@tpath, 'tab', 'names', @id)).empty?)
if pos
idx = tk_call(@tpath, 'index', '-name', @id)
@@ -75,18 +58,18 @@ module Tk::BLT
end
end
tk_call(@tpath, 'tab', 'configure', @id, keys)
- else
- pos = 'end' unless pos
- tk_call(@tpath, 'insert', pos, @id, keys)
+ return
end
+
else
- TabsetTab_ID.mutex.synchronize{
- @path = @id = TabsetTab_ID.join(TkCore::INTERP._ip_id_)
- TabsetTab_ID[1].succ!
- }
- pos = 'end' unless pos
- tk_call(@tpath, 'insert', pos, @id, keys)
+ @path = @id = TabsetTab_ID.join(TkCore::INTERP._ip_id_)
+ TabID_TBL[@tpath] = {} unless TabID_TBL[@tpath]
+ TabID_TBL[@tpath][@id] = self
+ TabsetTab_ID[1].succ!
end
+
+ pos = 'end' unless pos
+ tk_call(@tpath, 'insert', pos, @id, keys)
end
#def bind(context, cmd=Proc.new, *args)
@@ -128,9 +111,6 @@ module Tk::BLT
def cget(*args)
@t.tab_cget(@id, *args)
end
- def cget_strict(*args)
- @t.tab_cget_strict(@id, *args)
- end
def configure(*args)
@t.tab_configure(@id, *args)
end
@@ -143,9 +123,7 @@ module Tk::BLT
def delete()
@t.delete(@id)
- TabID_TBL.mutex.synchronize{
- TabID_TBL[@tpath].delete(@id)
- }
+ TabID_TBL[@tpath].delete(@id)
self
end
@@ -206,9 +184,7 @@ module Tk::BLT
WidgetClassNames[WidgetClassName] = self
def __destroy_hook__
- Tk::BLT::Tabset::Tab::TabID_TBL.mutex.synchronize{
- Tk::BLT::Tabset::Tab::TabID_TBL.delete(@path)
- }
+ Tk::BLT::Tabset::Tab::TabID_TBL.delete(@path)
end
########################################
@@ -243,7 +219,6 @@ module Tk::BLT
private :__item_pathname
alias tab_cget itemcget
- alias tab_cget_strict itemcget_strict
alias tab_configure itemconfigure
alias tab_configinfo itemconfiginfo
alias current_tab_configinfo current_itemconfiginfo
@@ -316,15 +291,11 @@ module Tk::BLT
def delete(first, last=None)
tk_send('delete', tagindex(first), tagindex(last))
if first.kind_of?(Tk::BLT::Tabset::Tab)
- TabID_TBL.mutex.synchronize{
- TabID_TBL[@path].delete(first.id)
- }
+ TabID_TBL[@path].delete(first.id)
end
# middle tabs of the range are unknown
if last.kind_of?(Tk::BLT::Tabset::Tab)
- TabID_TBL.mutex.synchronize{
- TabID_TBL[@path].delete(last.id)
- }
+ TabID_TBL[@path].delete(last.id)
end
self
end
diff --git a/ext/tk/lib/tkextlib/blt/ted.rb b/ext/tk/lib/tkextlib/blt/ted.rb
index 670265fc78..39495842b4 100644
--- a/ext/tk/lib/tkextlib/blt/ted.rb
+++ b/ext/tk/lib/tkextlib/blt/ted.rb
@@ -30,14 +30,11 @@ module Tk::BLT
end
private :__item_config_cmd
- private :itemcget, :itemcget_strict
- private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+ private :itemcget, :itemconfigure
+ private :itemconfiginfo, :current_itemconfiginfo
def cget(master, option)
- itemcget(master, option)
- end
- def cget_strict(master, option)
- itemcget_strict(master, option)
+ itemconfigure(master, slot, value)
end
def configure(master, slot, value=None)
itemconfigure(master, slot, value)
diff --git a/ext/tk/lib/tkextlib/blt/tile/button.rb b/ext/tk/lib/tkextlib/blt/tile/button.rb
index 2e0863cfbe..dd715c8b98 100644
--- a/ext/tk/lib/tkextlib/blt/tile/button.rb
+++ b/ext/tk/lib/tkextlib/blt/tile/button.rb
@@ -9,7 +9,7 @@ require 'tkextlib/blt/tile.rb'
module Tk::BLT
module Tile
- class Button < Tk::Button
+ class Button < TkButton
TkCommandNames = ['::blt::tile::button'.freeze].freeze
end
end
diff --git a/ext/tk/lib/tkextlib/blt/tile/checkbutton.rb b/ext/tk/lib/tkextlib/blt/tile/checkbutton.rb
index da230b5925..ebe79179a5 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 < Tk::CheckButton
+ 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/frame.rb b/ext/tk/lib/tkextlib/blt/tile/frame.rb
index 5434af4b72..10469fd35f 100644
--- a/ext/tk/lib/tkextlib/blt/tile/frame.rb
+++ b/ext/tk/lib/tkextlib/blt/tile/frame.rb
@@ -9,7 +9,7 @@ require 'tkextlib/blt/tile.rb'
module Tk::BLT
module Tile
- class Frame < Tk::Frame
+ class Frame < TkFrame
TkCommandNames = ['::blt::tile::frame'.freeze].freeze
end
end
diff --git a/ext/tk/lib/tkextlib/blt/tile/label.rb b/ext/tk/lib/tkextlib/blt/tile/label.rb
index f370c1403b..ec67babd58 100644
--- a/ext/tk/lib/tkextlib/blt/tile/label.rb
+++ b/ext/tk/lib/tkextlib/blt/tile/label.rb
@@ -9,7 +9,7 @@ require 'tkextlib/blt/tile.rb'
module Tk::BLT
module Tile
- class Label < Tk::Label
+ class Label < TkLabel
TkCommandNames = ['::blt::tile::label'.freeze].freeze
end
end
diff --git a/ext/tk/lib/tkextlib/blt/tile/radiobutton.rb b/ext/tk/lib/tkextlib/blt/tile/radiobutton.rb
index 814f9a5cc4..7573aa08d6 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 < Tk::RadioButton
+ class Radiobutton < TkRadiobutton
TkCommandNames = ['::blt::tile::radiobutton'.freeze].freeze
end
- Radiobutton = RadioButton
+ RadioButton = Radiobutton
end
end
diff --git a/ext/tk/lib/tkextlib/blt/tile/scrollbar.rb b/ext/tk/lib/tkextlib/blt/tile/scrollbar.rb
index 2ae871d518..ba3bf316f0 100644
--- a/ext/tk/lib/tkextlib/blt/tile/scrollbar.rb
+++ b/ext/tk/lib/tkextlib/blt/tile/scrollbar.rb
@@ -9,7 +9,7 @@ require 'tkextlib/blt/tile.rb'
module Tk::BLT
module Tile
- class Scrollbar < Tk::Scrollbar
+ class Scrollbar < TkScrollbar
TkCommandNames = ['::blt::tile::scrollbar'.freeze].freeze
end
end
diff --git a/ext/tk/lib/tkextlib/blt/tile/toplevel.rb b/ext/tk/lib/tkextlib/blt/tile/toplevel.rb
index 76d5f86b1b..6cc2c91415 100644
--- a/ext/tk/lib/tkextlib/blt/tile/toplevel.rb
+++ b/ext/tk/lib/tkextlib/blt/tile/toplevel.rb
@@ -9,7 +9,7 @@ require 'tkextlib/blt/tile.rb'
module Tk::BLT
module Tile
- class Toplevel < Tk::Toplevel
+ class Toplevel < TkToplevel
TkCommandNames = ['::blt::tile::toplevel'.freeze].freeze
end
end
diff --git a/ext/tk/lib/tkextlib/blt/tree.rb b/ext/tk/lib/tkextlib/blt/tree.rb
index 77b85f1717..07dc7ef7e8 100644
--- a/ext/tk/lib/tkextlib/blt/tree.rb
+++ b/ext/tk/lib/tkextlib/blt/tree.rb
@@ -12,77 +12,53 @@ module Tk::BLT
###################################
- class Node < TkObject
+ class Node < TkObject
TreeNodeID_TBL = TkCore::INTERP.create_table
-
- TkCore::INTERP.init_ip_env{
- TreeNodeID_TBL.mutex.synchronize{ TreeNodeID_TBL.clear }
- }
+ TkCore::INTERP.init_ip_env{ TreeNodeID_TBL.clear }
def self.id2obj(tree, id)
tpath = tree.path
- TreeNodeID_TBL.mutex.synchronize{
- if TreeNodeID_TBL[tpath]
- if TreeNodeID_TBL[tpath][id]
- TreeNodeID_TBL[tpath][id]
- else
- begin
- # self.new(tree, nil, 'node'=>Integer(id))
- id = Integer(id)
- if bool(tk_call(@tpath, 'exists', id))
- (obj = self.allocate).instance_eval{
- @parent = @tree = tree
- @tpath = tpath
- @path = @id = id
- TreeNodeID_TBL[@tpath] = {} unless TreeNodeID_TBL[@tpath]
- TreeNodeID_TBL[@tpath][@id] = self
- }
- obj
- else
- id
- end
- rescue
- id
- end
- end
- else
+ return id unless TreeNodeID_TBL[tpath]
+ if TreeNodeID_TBL[tpath][id]
+ TreeNodeID_TBL[tpath][id]
+ else
+ begin
+ self.new(tree, nil, 'node'=>Integer(id))
+ rescue
id
end
- }
+ end
end
def self.new(tree, parent, keys={})
keys = _symbolkey2str(keys)
tpath = tree.path
- TreeNodeID_TBL.mutex.synchronize{
- TreeNodeID_TBL[tpath] ||= {}
- if (id = keys['node']) && (obj = TreeNodeID_TBL[tpath][id])
- keys.delete('node')
- tk_call(tree.path, 'move', id, parent, keys) if parent
- return obj
- end
+ if (id = keys['node']) && (obj = TreeNodeID_TBL[tpath][id])
+ keys.delete('node')
+ tk_call(tree.path, 'move', id, parent, keys) if parent
+ return obj
+ end
- (obj = self.allocate).instance_eval{
- initialize(tree, parent, keys)
- TreeNodeID_TBL[tpath][@id] = self
- }
- obj
- }
+ super(tree, parent, keys)
end
def initialize(tree, parent, keys={})
@parent = @tree = tree
@tpath = @parent.path
+ parent = tk_call(@tpath, 'root') unless parent
+
if (id = keys['node']) && bool(tk_call(@tpath, 'exists', id))
@path = @id = id
keys.delete('node')
tk_call(@tpath, 'move', @id, parent, keys) if parent
else
- parent = tk_call(@tpath, 'root') unless parent
@path = @id = tk_call(@tpath, 'insert', parent, keys)
end
+
+ TreeNodeID_TBL[@tpath] = {} unless TreeNodeID_TBL[@tpath]
+ TreeNodeID_TBL[@tpath][@id] = self
end
def id
@@ -267,42 +243,17 @@ module Tk::BLT
class Tag < TkObject
TreeTagID_TBL = TkCore::INTERP.create_table
-
- TkCore::INTERP.init_ip_env{
- TreeTagID_TBL.mutex.synchronize{ TreeTagID_TBL.clear }
- }
-
- (TreeTag_ID = ['blt_tree_tag'.freeze, '00000'.taint]).instance_eval{
- @mutex = Mutex.new
- def mutex; @mutex; end
- freeze
- }
+ TkCore::INTERP.init_ip_env{ TreeTagID_TBL.clear }
+ TreeTag_ID = ['blt_tree_tag'.freeze, '00000'.taint].freeze
def self.id2obj(tree, id)
tpath = tree.path
- TreeTagID_TBL.mutex.synchronize{
- if TreeTagID_TBL[tpath]
- if TreeTagID_TBL[tpath][id]
- TreeTagID_TBL[tpath][id]
- else
- begin
- # self.new(tree, id)
- (obj = self.allocate).instance_eval{
- @parent = @tree = tree
- @tpath = @parent.path
- @path = @id = id.dup.freeze if id
- TreeTagID_TBL[@tpath] = {} unless TreeTagID_TBL[@tpath]
- TreeTagID_TBL[@tpath][@id] = self
- }
- obj
- rescue
- id
- end
- end
- else
- id
- end
- }
+ return id unless TreeTagID_TBL[tpath]
+ if TreeTagID_TBL[tpath][id]
+ TreeTagID_TBL[tpath][id]
+ else
+ self.new(tree, id)
+ end
end
def initialize(tree, tag_str = nil)
@@ -312,15 +263,12 @@ module Tk::BLT
if tag_str
@path = @id = tag_str.dup.freeze
else
- TreeTag_ID.mutex.synchronize{
- @path = @id = TreeTag_ID.join(TkCore::INTERP._ip_id_)
- TreeTag_ID[1].succ!
- }
+ @path = @id = TreeTag_ID.join(TkCore::INTERP._ip_id_)
+ TreeTagID_TBL[@id] = self
+ TreeTag_ID[1].succ!
end
- TreeTagID_TBL.mutex.synchronize{
- TreeTagID_TBL[@tpath] = {} unless TreeTagID_TBL[@tpath]
- TreeTagID_TBL[@tpath][@id] = self
- }
+ TreeTagID_TBL[@tpath] = {} unless TreeTagID_TBL[@tpath]
+ TreeTagID_TBL[@tpath][@id] = self
end
def id
@@ -339,9 +287,7 @@ module Tk::BLT
def forget()
tk_call(@tpath, 'tag', 'forget', @id)
- TreeTagID_TBL.mutex.synchronize{
- TreeTagID_TBL[@tpath].delete(@id)
- }
+ TreeTagID_TBL[@tpath].delete(@id)
self
end
@@ -366,63 +312,44 @@ module Tk::BLT
class Notify < TkObject
NotifyID_TBL = TkCore::INTERP.create_table
-
- TkCore::INTERP.init_ip_env{
- NotifyID_TBL.mutex.synchronize{ NotifyID_TBL.clear }
- }
+ TkCore::INTERP.init_ip_env{ NotifyID_TBL.clear }
def self.id2obj(tree, id)
tpath = tree.path
- NotifyID_TBL.mutex.synchronize{
- if NotifyID_TBL[tpath]
- if NotifyID_TBL[tpath][id]
- NotifyID_TBL[tpath][id]
- else
- (obj = self.allocate).instance_eval{
- @parent = @tree = tree
- @tpath = @parent.path
- @path = @id = id
- NotifyID_TBL[@tpath] ||= {}
- NotifyID_TBL[@tpath][@id] = self
- }
- obj
- end
- else
- return id
+ return id unless NotifyID_TBL[tpath]
+ if NotifyID_TBL[tpath][id]
+ NotifyID_TBL[tpath][id]
+ else
+ begin
+ self.new([tree, id])
+ rescue
+ id
end
- }
+ end
end
def self.new(tree, *args, &b)
- NotifyID_TBL.mutex.synchronize{
- if tree.kind_of?(Array)
- # not create
- tpath = tree[0].path
- NotifyID_TBL[tpath] ||= {}
- unless (obj = NotifyID_TBL[tpath][tree[1]])
- (NotifyID_TBL[tpath][tree[1]] =
- obj = self.allocate).instance_eval{
- @parent = @tree = tree[0]
- @tpath = @parent.path
- @path = @id = tree[1]
- }
- end
+ if tree.kind_of?(Array)
+ # not create
+ if obj = NotifyID_TBL[tree[0].path][tree[1]]
return obj
+ else
+ return super(false, tree[0], tree[1])
end
+ end
- (obj = self.allocate).instance_eval{
- initialize(tree, *args, &b)
- NotifyID_TBL[@tpath] ||= {}
- NotifyID_TBL[@tpath][@id] = self
- }
- return obj
- }
+ super(true, tree, *args, &b)
end
- def initialize(tree, *args, &b)
+ def initialize(create, tree, *args, &b)
@parent = @tree = tree
@tpath = @parent.path
+ unless create
+ @path = @id = args[0]
+ return
+ end
+
# if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
if TkComm._callback_entry?(args[0])
cmd = args.shift
@@ -451,9 +378,7 @@ module Tk::BLT
def delete()
tk_call(@tpath, 'notify', 'delete', @id)
- NotifyID_TBL.mutex.synchronize{
- NotifyID_TBL[@tpath].delete(@id)
- }
+ NotifyID_TBL[tpath].delete(@id)
self
end
@@ -470,69 +395,44 @@ module Tk::BLT
class Trace < TkObject
TraceID_TBL = TkCore::INTERP.create_table
-
- TkCore::INTERP.init_ip_env{
- TraceID_TBL.mutex.synchronize{ TraceID_TBL.clear }
- }
+ TkCore::INTERP.init_ip_env{ TraceID_TBL.clear }
def self.id2obj(tree, id)
tpath = tree.path
- TraceID_TBL.mutex.synchronize{
- if TraceID_TBL[tpath]
- if TraceID_TBL[tpath][id]
- TraceID_TBL[tpath][id]
- else
- begin
- # self.new([tree, id])
- (obj = self.allocate).instance_eval{
- @parent = @tree = tree
- @tpath = @parent.path
- @path = @id = node # == traceID
- TraceID_TBL[@tpath] ||= {}
- TraceID_TBL[@tpath][@id] = self
- }
- obj
- rescue
- id
- end
- end
- else
+ return id unless TraceID_TBL[tpath]
+ if TraceID_TBL[tpath][id]
+ TraceID_TBL[tpath][id]
+ else
+ begin
+ self.new([tree, id])
+ rescue
id
end
- }
+ end
end
def self.new(tree, *args, &b)
- TraceID_TBL.mutex.synchronize{
- if tree.kind_of?(Array)
- # not create
- tpath = tree[0].path
- TraceID_TBL[tpath] ||= {}
- unless (obj = TraceID_TBL[tpath][tree[1]])
- (TraceID_TBL[tpath][tree[1]] =
- obj = self.allocate).instance_eval{
- @parent = @tree = tree
- @tpath = @parent.path
- @path = @id = tree[1] # == traceID
- }
- end
+ if tree.kind_of?(Array)
+ # not create
+ if obj = TraceID_TBL[tree[0].path][tree[1]]
return obj
+ else
+ return super(false, tree[0], tree[1])
end
+ end
- # super(true, tree, *args, &b)
- (obj = self.allocate).instance_eval{
- initialize(tree, *args, &b)
- TraceID_TBL[@tpath] ||= {}
- TraceID_TBL[@tpath][@id] = self
- }
- return obj
- }
+ super(true, tree, *args, &b)
end
- def initialize(tree, node, key, opts, cmd=nil, &b)
+ def initialize(create, tree, node, key, opts, cmd=nil, &b)
@parent = @tree = tree
@tpath = @parent.path
+ unless create
+ @path = @id = node # == traceID
+ return
+ end
+
if !cmd
if b
cmd = Proc.new(&b)
@@ -559,9 +459,7 @@ module Tk::BLT
def delete()
tk_call(@tpath, 'trace', 'delete', @id)
- TraceID_TBL.mutex.synchronize{
- TraceID_TBL[tpath].delete(@id)
- }
+ TraceID_TBL[tpath].delete(@id)
self
end
@@ -577,12 +475,7 @@ module Tk::BLT
###################################
TreeID_TBL = TkCore::INTERP.create_table
-
- (Tree_ID = ['blt_tree'.freeze, '00000'.taint]).instance_eval{
- @mutex = Mutex.new
- def mutex; @mutex; end
- freeze
- }
+ Tree_ID = ['blt_tree'.freeze, '00000'.taint].freeze
def __keyonly_optkeys
{
@@ -605,9 +498,7 @@ module Tk::BLT
end
def self.id2obj(id)
- TreeID_TBL.mutex.synchronize{
- TreeID_TBL[id]? TreeID_TBL[id]: id
- }
+ TreeID_TBL[id]? TreeID_TBL[id]: id
end
def self.names(pat = None)
@@ -622,45 +513,27 @@ module Tk::BLT
end
def self.new(name = nil)
- TreeID_TBL.mutex.synchronize{
- if name && TreeID_TBL[name]
- TreeID_TBL[name]
- else
- (obj = self.allocate).instance_eval{
- initialize(name)
- TreeID_TBL[@id] = self
- }
- obj
- end
- }
+ return TreeID_TBL[name] if name && TreeID_TBL[name]
+ super(name)
end
def initialzie(name = nil)
if name
@path = @id = name
else
- Tree_ID.mutex.synchronize{
- @path = @id = Tree_ID.join(TkCore::INTERP._ip_id_)
- Tree_ID[1].succ!
- }
+ @path = @id = Tree_ID.join(TkCore::INTERP._ip_id_)
+ TreeID_TBL[@id] = self
+ Tree_ID[1].succ!
end
-
+ TreeID_TBL[@id] = self
tk_call('::blt::tree', 'create', @id)
end
def __destroy_hook__
- Tk::BLT::Tree::Node::TreeNodeID_TBL.mutex.synchronize{
- Tk::BLT::Tree::Node::TreeNodeID_TBL.delete(@path)
- }
- Tk::BLT::Tree::Tag::TreeTagID_TBL.mutex.synchronize{
- Tk::BLT::Tree::Tag::TreeTagID_TBL.delete(@path)
- }
- Tk::BLT::Tree::Notify::NotifyID_TBL.mutex.synchronize{
- Tk::BLT::Tree::Notify::NotifyID_TBL.delete(@path)
- }
- Tk::BLT::Tree::Trace::TraceID_TBL.mutex.synchronize{
- Tk::BLT::Tree::Trace::TraceID_TBL.delete(@path)
- }
+ Tk::BLT::Tree::Node::TreeNodeID_TBL.delete(@path)
+ Tk::BLT::Tree::Tag::TreeTagID_TBL.delete(@path)
+ Tk::BLT::Tree::Notify::NotifyID_TBL.delete(@path)
+ Tk::BLT::Tree::Trace::TraceID_TBL.delete(@path)
end
def tagid(tag)
@@ -719,14 +592,12 @@ module Tk::BLT
def delete(*nodes)
tk_call('::blt::tree', 'delete', *(nodes.collect{|node| tagid(node)}))
- Tk::BLT::Tree::Node::TreeNodeID_TBL.mutex.synchronize{
- nodes.each{|node|
- if node.kind_of?(Tk::BLT::Tree::Node)
- Tk::BLT::Tree::Node::TreeNodeID_TBL[@path].delete(node.id)
- else
- Tk::BLT::Tree::Node::TreeNodeID_TBL[@path].delete(node.to_s)
- end
- }
+ nodes.each{|node|
+ if node.kind_of?(Tk::BLT::Tree::Node)
+ Tk::BLT::Tree::Node::TreeNodeID_TBL[@path].delete(node.id)
+ else
+ Tk::BLT::Tree::Node::TreeNodeID_TBL[@path].delete(node.to_s)
+ end
}
self
end
@@ -857,9 +728,7 @@ module Tk::BLT
id.delete
else
tk_call(@path, 'notify', 'delete', id)
- Tk::BLT::Tree::Notify::NotifyID_TBL.mutex.synchronize{
- Tk::BLT::Tree::Notify::NotifyID_TBL[@path].delete(id.to_s)
- }
+ Tk::BLT::Tree::Notify::NotifyID_TBL[@path].delete(id.to_s)
end
self
end
@@ -966,9 +835,7 @@ module Tk::BLT
def tag_forget(tag)
tag = tag.id if tag.kind_of?(Tk::BLT::Tree::Tag)
tk_call(@path, 'tag', 'forget', tag)
- TreeTagID_TBL.mutex.synchronize{
- TreeTagID_TBL[@path].delete(tag)
- }
+ TreeTagID_TBL[@path].delete(tag)
self
end
@@ -1022,9 +889,7 @@ module Tk::BLT
def trace_delete(*args)
args = args.collect{|id| tagid(id)}
tk_call(@path, 'trace', 'delete', *args)
- Tk::BLT::Tree::Trace::TraceID_TBL.mutex.synchronize{
- args.each{|id| Tk::BLT::Tree::Trace::TraceID_TBL[@path].delete(id.to_s)}
- }
+ args.each{|id| Tk::BLT::Tree::Trace::TraceID_TBL[@path].delete(id.to_s)}
self
end
diff --git a/ext/tk/lib/tkextlib/blt/treeview.rb b/ext/tk/lib/tkextlib/blt/treeview.rb
index c5a5697186..0343d28b9c 100644
--- a/ext/tk/lib/tkextlib/blt/treeview.rb
+++ b/ext/tk/lib/tkextlib/blt/treeview.rb
@@ -98,9 +98,6 @@ module Tk::BLT::Treeview::ConfigMethod
def column_cget(name, option)
itemcget(['column', name], option)
end
- def column_cget_strict(name, option)
- itemcget_strict(['column', name], option)
- end
def column_configure(name, slot, value=None)
itemconfigure(['column', name], slot, value)
end
@@ -114,9 +111,6 @@ module Tk::BLT::Treeview::ConfigMethod
def button_cget(option)
itemcget('button', option)
end
- def button_cget_strict(option)
- itemcget_strict('button', option)
- end
def button_configure(slot, value=None)
itemconfigure('button', slot, value)
end
@@ -135,14 +129,6 @@ module Tk::BLT::Treeview::ConfigMethod
ret
end
end
- def entry_cget_strict(option)
- ret = itemcget_strict('entry', option)
- if option == 'bindtags' || option == :bindtags
- ret.collect{|tag| TkBindTag.id2obj(tag)}
- else
- ret
- end
- end
def entry_configure(slot, value=None)
itemconfigure('entry', slot, value)
end
@@ -184,9 +170,6 @@ module Tk::BLT::Treeview::ConfigMethod
def sort_cget(option)
itemcget('sort', option)
end
- def sort_cget_strict(option)
- itemcget_strict('sort', option)
- end
def sort_configure(slot, value=None)
itemconfigure('sort', slot, value)
end
@@ -200,9 +183,6 @@ module Tk::BLT::Treeview::ConfigMethod
def text_cget(option)
itemcget('text', option)
end
- def text_cget_strict(option)
- itemcget_strict('text', option)
- end
def text_configure(slot, value=None)
itemconfigure('text', slot, value)
end
@@ -213,8 +193,8 @@ module Tk::BLT::Treeview::ConfigMethod
current_itemconfiginfo('text', slot)
end
- private :itemcget, :itemcget_strict
- private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+ private :itemcget, :itemconfigure
+ private :itemconfiginfo, :current_itemconfiginfo
end
class Tk::BLT::Treeview
@@ -259,24 +239,6 @@ class Tk::BLT::Treeview
nil
]
-=begin
- # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
- KEY_TBL.map!{|inf|
- if inf.kind_of?(Array)
- inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
- inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
- end
- inf
- }
-
- PROC_TBL.map!{|inf|
- if inf.kind_of?(Array)
- inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
- end
- inf
- }
-=end
-
_setup_subst_table(KEY_TBL, PROC_TBL);
def self.ret_val(val)
@@ -311,12 +273,8 @@ class Tk::BLT::Treeview
########################
def __destroy_hook__
- Tk::BLT::Treeview::Node::TreeNodeID_TBL.mutex.synchronize{
- Tk::BLT::Treeview::Node::TreeNodeID_TBL.delete(@path)
- }
- Tk::BLT::Treeview::Tag::TreeTagID_TBL.mutex.synchronize{
- Tk::BLT::Treeview::Tag::TreeTagID_TBL.delete(@path)
- }
+ Tk::BLT::Treeview::Node::TreeNodeID_TBL.delete(@path)
+ Tk::BLT::Treeview::Tag::TreeTagID_TBL.delete(@path)
end
def tagid(tag)
@@ -514,24 +472,6 @@ class Tk::BLT::Treeview
nil
]
-=begin
- # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
- KEY_TBL.map!{|inf|
- if inf.kind_of?(Array)
- inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
- inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
- end
- inf
- }
-
- PROC_TBL.map!{|inf|
- if inf.kind_of?(Array)
- inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
- end
- inf
- }
-=end
-
_setup_subst_table(KEY_TBL, PROC_TBL);
def self.ret_val(val)
@@ -547,8 +487,7 @@ class Tk::BLT::Treeview
def _find_exec_flag_value(val)
if val.kind_of?(Array)
cmd, *args = val
- #FindExecFlagValue.new(cmd, args.join(' '))
- FindExecFlagValue.new(cmd, *args)
+ FindExecFlagValue.new(cmd, args.join(' '))
elsif TkComm._callback_entry?(val)
FindExecFlagValue.new(val)
else
@@ -1028,47 +967,22 @@ class Tk::BLT::Treeview::Node < TkObject
include Tk::BLT::Treeview::TagOrID_Methods
TreeNodeID_TBL = TkCore::INTERP.create_table
+ TreeNode_ID = ['blt_treeview_node'.freeze, '00000'.taint].freeze
- (TreeNode_ID = ['blt_treeview_node'.freeze, '00000'.taint]).instance_eval{
- @mutex = Mutex.new
- def mutex; @mutex; end
- freeze
- }
-
- TkCore::INTERP.init_ip_env{
- TreeNodeID_TBL.mutex.synchronize{ TreeNodeID_TBL.clear }
- }
+ TkCore::INTERP.init_ip_env{ TreeNodeID_TBL.clear }
def self.id2obj(tree, id)
tpath = tree.path
- TreeNodeID_TBL.mutex.synchronize{
- if TreeNodeID_TBL[tpath]
- if TreeNodeID_TBL[tpath][id]
- TreeNodeID_TBL[tpath][id]
- else
- begin
- # self.new(tree, nil, nil, 'node'=>Integer(id))
- unless (tk_call(@tpath, 'get', id)).empty?
- id = Integer(id)
- (obj = self.allocate).instance_eval{
- @parent = @tree = tree
- @tpath = @parent.path
- @path = @id = id
- TreeNodeID_TBL[@tpath] ||= {}
- TreeNodeID_TBL[@tpath][@id] = self
- }
- obj
- else
- id
- end
- rescue
- id
- end
- end
- else
+ return id unless TreeNodeID_TBL[tpath]
+ if TreeNodeID_TBL[tpath][id]
+ TreeNodeID_TBL[tpath][id]
+ else
+ begin
+ self.new(tree, nil, nil, 'node'=>Integer(id))
+ rescue
id
end
- }
+ end
end
def self.new(tree, pos, parent=nil, keys={})
@@ -1080,21 +994,13 @@ class Tk::BLT::Treeview::Node < TkObject
keys = _symbolkey2str(keys)
tpath = tree.path
- TreeNodeID_TBL.mutex.synchronize{
- TreeNodeID_TBL[tpath] ||= {}
- if (id = keys['node']) && (obj = TreeNodeID_TBL[tpath][id])
- keys.delete('node')
- tk_call(tree.path, 'move', id, pos, parent) if parent
- return obj
- end
+ if (id = keys['node']) && (obj = TreeNodeID_TBL[tpath][id])
+ keys.delete('node')
+ tk_call(tree.path, 'move', id, pos, parent) if parent
+ return obj
+ end
- #super(tree, pos, parent, keys)
- (obj = self.allocate).instance_eval{
- initialize(tree, pos, parent, keys)
- TreeNodeID_TBL[tpath][@id] = self
- }
- obj
- }
+ super(tree, pos, parent, keys)
end
def initialize(tree, pos, parent, keys)
@@ -1102,18 +1008,11 @@ class Tk::BLT::Treeview::Node < TkObject
@tpath = @parent.path
if (id = keys['node'])
- # if tk_call(@tpath, 'get', id).empty?
- # fail RuntimeError, "not exist the node '#{id}'"
- # end
@path = @id = id
tk_call(@tpath, 'move', @id, pos, tagid(parent)) if parent
- configure(keys) if keys && ! keys.empty?
else
- name = nil
- TreeNode_ID.mutex.synchronize{
- name = TreeNode_ID.join(TkCore::INTERP._ip_id_).freeze
- TreeNode_ID[1].succ!
- }
+ name = TreeNode_ID.join(TkCore::INTERP._ip_id_).freeze
+ TreeNode_ID[1].succ!
at = keys.delete['at']
@@ -1136,6 +1035,9 @@ class Tk::BLT::Treeview::Node < TkObject
end
@path = @id
end
+
+ TreeNodeID_TBL[@tpath] = {} unless TreeNodeID_TBL[@tpath]
+ TreeNodeID_TBL[@tpath][@id] = self
end
def id
@@ -1149,66 +1051,37 @@ class Tk::BLT::Treeview::Tag < TkObject
include Tk::BLT::Treeview::TagOrID_Methods
TreeTagID_TBL = TkCore::INTERP.create_table
+ TreeTag_ID = ['blt_treeview_tag'.freeze, '00000'.taint].freeze
- (TreeTag_ID = ['blt_treeview_tag'.freeze, '00000'.taint]).instance_eval{
- @mutex = Mutex.new
- def mutex; @mutex; end
- freeze
- }
-
- TkCore::INTERP.init_ip_env{
- TreeTagID_TBL.mutex.synchronize{ TreeTagID_TBL.clear }
- }
+ TkCore::INTERP.init_ip_env{ TreeTagID_TBL.clear }
- def self.id2obj(tree, name)
+ def self.id2obj(tree, id)
tpath = tree.path
- TreeTagID_TBL.mutex.synchronize{
- if TreeTagID_TBL[tpath]
- if TreeTagID_TBL[tpath][name]
- TreeTagID_TBL[tpath][name]
- else
- #self.new(tree, name)
- (obj = self.allocate).instance_eval{
- @parent = @tree = tree
- @tpath = @parent.path
- @path = @id = name
- TreeTagID_TBL[@tpath] = {} unless TreeTagID_TBL[@tpath]
- TreeTagID_TBL[@tpath][@id] = self
- }
- obj
- end
- else
+ return id unless TreeTagID_TBL[tpath]
+ if TreeTagID_TBL[tpath][id]
+ TreeTagID_TBL[tpath][id]
+ else
+ begin
+ self.new(tree, nil, nil, 'name'=>Integer(id))
+ rescue
id
end
- }
+ end
end
def self.new_by_name(tree, name, *ids)
- TreeTagID_TBL.mutex.synchronize{
- unless (obj = TreeTagID_TBL[tree.path][name])
- (obj = self.allocate).instance_eval{
- initialize(tree, name, ids)
- TreeTagID_TBL[@tpath] = {} unless TreeTagID_TBL[@tpath]
- TreeTagID_TBL[@tpath][@id] = self
- }
- end
- obj
- }
+ if (obj = TreeTagID_TBL[tree.path][name])
+ return obj
+ end
+ new([tree, name], ids)
end
def self.new(tree, *ids)
- TreeTagID_TBL.mutex.synchronize{
- (obj = self.allocate).instance_eval{
- if tree.kind_of?(Array)
- initialize(tree[0], tree[1], ids)
- else
- initialize(tree, nil, ids)
- end
- TreeTagID_TBL[@tpath] = {} unless TreeTagID_TBL[@tpath]
- TreeTagID_TBL[@tpath][@id] = self
- }
- obj
- }
+ if tree.kind_of?(Array)
+ super(tree[0], tree[1], ids)
+ else
+ super(tree, nil, ids)
+ end
end
def initialize(tree, name, ids)
@@ -1218,12 +1091,13 @@ class Tk::BLT::Treeview::Tag < TkObject
if name
@path = @id = name
else
- TreeTag_ID.mutex.synchronize{
- @path = @id = TreeTag_ID.join(TkCore::INTERP._ip_id_).freeze
- TreeTag_ID[1].succ!
- }
+ @path = @id = TreeTag_ID.join(TkCore::INTERP._ip_id_).freeze
+ TreeTag_ID[1].succ!
end
+ TreeTagID_TBL[@tpath] = {} unless TreeTagID_TBL[@tpath]
+ TreeTagID_TBL[@tpath][@id] = self
+
unless ids.empty?
tk_call(@tpath, 'tag', 'add', @id, *(ids.collect{|id| tagid(id)}))
end
diff --git a/ext/tk/lib/tkextlib/blt/unix_dnd.rb b/ext/tk/lib/tkextlib/blt/unix_dnd.rb
index 445002d7a5..3130c1e56f 100644
--- a/ext/tk/lib/tkextlib/blt/unix_dnd.rb
+++ b/ext/tk/lib/tkextlib/blt/unix_dnd.rb
@@ -30,14 +30,11 @@ module Tk::BLT
end
private :__item_config_cmd
- private :itemcget, :itemcget_strict
- private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+ private :itemcget, :itemconfigure
+ private :itemconfiginfo, :current_itemconfiginfo
def cget(win, option)
- itemcget(['cget', win], option)
- end
- def cget_strict(win, option)
- itemcget_strict(['cget', win], option)
+ itemconfigure(['cget', win], slot, value)
end
def configure(win, slot, value=None)
itemconfigure(['configure', win], slot, value)
@@ -49,11 +46,8 @@ module Tk::BLT
current_itemconfiginfo(['configure', win], slot)
end
- def token_cget(win, option)
- itemcget(['token', 'cget', win], option)
- end
- def token_cget_strict(win, option)
- itemcget_strict(['token', 'cget', win], option)
+ def tokwn_cget(win, option)
+ itemconfigure(['token', 'cget', win], slot, value)
end
def token_configure(win, slot, value=None)
itemconfigure(['token', 'configure', win], slot, value)
diff --git a/ext/tk/lib/tkextlib/blt/vector.rb b/ext/tk/lib/tkextlib/blt/vector.rb
index 97fb1b96ff..540b6b9102 100644
--- a/ext/tk/lib/tkextlib/blt/vector.rb
+++ b/ext/tk/lib/tkextlib/blt/vector.rb
@@ -23,17 +23,14 @@ module Tk::BLT
end
def self.names(pat=None)
- list = simplelist(tk_call('::blt::vector', 'names', pat))
- TkVar_ID_TBL.mutex.synchronize{
- list.collect{|name|
- if TkVar_ID_TBL[name]
- TkVar_ID_TBL[name]
- elsif name[0..1] == '::' && TkVar_ID_TBL[name[2..-1]]
- TkVar_ID_TBL[name[2..-1]]
- else
- name
- end
- }
+ simplelist(tk_call('::blt::vector', 'names', pat)).collect{|name|
+ if TkVar_ID_TBL[name]
+ TkVar_ID_TBL[name]
+ elsif name[0..1] == '::' && TkVar_ID_TBL[name[2..-1]]
+ TkVar_ID_TBL[name[2..-1]]
+ else
+ name
+ end
}
end
@@ -49,16 +46,14 @@ module Tk::BLT
size = size.join(':')
end
if size
- @id = TkCore::INTERP._invoke('::blt::vector', 'create',
- "#auto(#{size})", *hash_kv(keys))
+ @id = INTERP._invoke('::blt::vector', 'create',
+ "#auto(#{size})", *hash_kv(keys))
else
- @id = TkCore::INTERP._invoke('::blt::vector', 'create',
- "#auto", *hash_kv(keys))
+ @id = INTERP._invoke('::blt::vector', 'create',
+ "#auto", *hash_kv(keys))
end
- TkVar_ID_TBL.mutex.synchronize{
- TkVar_ID_TBL[@id] = self
- }
+ TkVar_ID_TBL[@id] = self
@def_default = false
@default_val = nil
@@ -68,7 +63,7 @@ module Tk::BLT
@trace_opts = nil
# teach Tk-ip that @id is global var
- TkCore::INTERP._invoke_without_enc('global', @id)
+ INTERP._invoke_without_enc('global', @id)
end
def destroy
@@ -226,21 +221,13 @@ module Tk::BLT
class VectorAccess < Vector
def self.new(name)
- TkVar_ID_TBL.mutex.synchronize{
- if TkVar_ID_TBL[name]
- TkVar_ID_TBL[name]
- else
- (obj = self.allocate).instance_eval{
- initialize(name)
- TkVar_ID_TBL[@id] = self
- }
- obj
- end
- }
+ return TkVar_ID_TBL[name] if TkVar_ID_TBL[name]
+ super(name, size=nil, keys={})
end
def initialize(vec_name)
@id = vec_name
+ TkVar_ID_TBL[@id] = self
@def_default = false
@default_val = nil
@@ -250,7 +237,7 @@ module Tk::BLT
@trace_opts = nil
# teach Tk-ip that @id is global var
- TkCore::INTERP._invoke_without_enc('global', @id)
+ INTERP._invoke_without_enc('global', @id)
end
end
end
diff --git a/ext/tk/lib/tkextlib/blt/watch.rb b/ext/tk/lib/tkextlib/blt/watch.rb
index 219ff78e97..ae5e50f126 100644
--- a/ext/tk/lib/tkextlib/blt/watch.rb
+++ b/ext/tk/lib/tkextlib/blt/watch.rb
@@ -13,23 +13,11 @@ module Tk::BLT
TkCommandNames = ['::blt::watch'.freeze].freeze
WATCH_ID_TBL = TkCore::INTERP.create_table
-
- (BLT_WATCH_ID = ['blt_watch_id'.freeze, '00000'.taint]).instance_eval{
- @mutex = Mutex.new
- def mutex; @mutex; end
- freeze
- }
-
- TkCore::INTERP.init_ip_env{
- WATCH_ID_TBL.mutex.synchronize{ WATCH_ID_TBL.clear }
- }
+ BLT_WATCH_ID = ['blt_watch_id'.freeze, '00000'.taint].freeze
def self.names(state = None)
- lst = tk_split_list(tk_call('::blt::watch', 'names', state))
- WATCH_ID_TBL.mutex.synchronize{
- lst.collect{|name|
- WATCH_ID_TBL[name] || name
- }
+ tk_split_list(tk_call('::blt::watch', 'names', state)).collect{|name|
+ WATCH_ID_TBL[name] || name
}
end
@@ -57,17 +45,13 @@ module Tk::BLT
if name
@id = name.to_s
else
- BLT_WATCH_ID.mutex.synchronize{
- @id = BLT_WATCH_ID.join(TkCore::INTERP._ip_id_)
- BLT_WATCH_ID[1].succ!
- }
+ @id = BLT_WATCH_ID.join(TkCore::INTERP._ip_id_)
+ BLT_WATCH_ID[1].succ!
end
@path = @id
- WATCH_ID_TBL.mutex.synchronize{
- WATCH_ID_TBL[@id] = self
- }
+ WATCH_ID_TBL[@id] = self
tk_call('::blt::watch', 'create', @id, *hash_kv(keys))
end
@@ -146,7 +130,7 @@ module Tk::BLT
end
end
end
- def cget_strict(key)
+ def cget(key)
key = key.to_s
begin
info.assoc(key)[1]
@@ -154,22 +138,5 @@ module Tk::BLT
fail ArgumentError, "unknown option '#{key}'"
end
end
- def cget(key)
- unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
- cget_strict(key)
- else
- begin
- cget_strict(key)
- rescue => e
- if current_configinfo.has_key?(key.to_s)
- # error on known option
- fail e
- else
- # unknown option
- nil
- end
- end
- end
- end
end
end
diff --git a/ext/tk/lib/tkextlib/bwidget/button.rb b/ext/tk/lib/tkextlib/bwidget/button.rb
index 8f3087d098..4a9d4a7948 100644
--- a/ext/tk/lib/tkextlib/bwidget/button.rb
+++ b/ext/tk/lib/tkextlib/bwidget/button.rb
@@ -9,7 +9,7 @@ require 'tkextlib/bwidget.rb'
module Tk
module BWidget
- class Button < Tk::Button
+ class Button < TkButton
end
end
end
diff --git a/ext/tk/lib/tkextlib/bwidget/buttonbox.rb b/ext/tk/lib/tkextlib/bwidget/buttonbox.rb
index 8d6d212189..ef999239f9 100644
--- a/ext/tk/lib/tkextlib/bwidget/buttonbox.rb
+++ b/ext/tk/lib/tkextlib/bwidget/buttonbox.rb
@@ -31,7 +31,7 @@ class Tk::BWidget::ButtonBox
name = tagOrId[:name]
return index(name) unless name.empty?
end
- if tagOrId.kind_of?(Tk::Button)
+ if tagOrId.kind_of?(TkButton)
return index(tagOrId[:text])
end
# index(tagOrId.to_s)
@@ -40,13 +40,7 @@ class Tk::BWidget::ButtonBox
def add(keys={}, &b)
win = window(tk_send('add', *hash_kv(keys)))
- if b
- if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
- win.instance_exec(self, &b)
- else
- win.instance_eval(&b)
- end
- end
+ win.instance_eval(&b) if b
win
end
@@ -60,7 +54,7 @@ class Tk::BWidget::ButtonBox
name = idx[:name]
idx = name unless name.empty?
end
- if idx.kind_of?(Tk::Button)
+ if idx.kind_of?(TkButton)
idx = idx[:text]
end
number(tk_send('index', idx.to_s))
@@ -68,13 +62,7 @@ class Tk::BWidget::ButtonBox
def insert(idx, keys={}, &b)
win = window(tk_send('insert', tagid(idx), *hash_kv(keys)))
- if b
- if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
- win.instance_exec(self, &b)
- else
- win.instance_eval(&b)
- end
- end
+ win.instance_eval(&b) if b
win
end
diff --git a/ext/tk/lib/tkextlib/bwidget/combobox.rb b/ext/tk/lib/tkextlib/bwidget/combobox.rb
index 1c58a4ccb0..31f71c3aaf 100644
--- a/ext/tk/lib/tkextlib/bwidget/combobox.rb
+++ b/ext/tk/lib/tkextlib/bwidget/combobox.rb
@@ -25,13 +25,7 @@ class Tk::BWidget::ComboBox
def get_listbox(&b)
win = window(tk_send_without_enc('getlistbox'))
- if b
- if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
- win.instance_exec(self, &b)
- else
- win.instance_eval(&b)
- end
- end
+ win.instance_eval(&b) if b
win
end
diff --git a/ext/tk/lib/tkextlib/bwidget/dialog.rb b/ext/tk/lib/tkextlib/bwidget/dialog.rb
index 291ca4a962..2790d88d24 100644
--- a/ext/tk/lib/tkextlib/bwidget/dialog.rb
+++ b/ext/tk/lib/tkextlib/bwidget/dialog.rb
@@ -59,13 +59,6 @@ class Tk::BWidget::Dialog
end
end
- def cget_strict(slot)
- if slot.to_s == 'relative'
- super('parent')
- else
- super(slot)
- end
- end
def cget(slot)
if slot.to_s == 'relative'
super('parent')
@@ -110,7 +103,7 @@ class Tk::BWidget::Dialog
name = tagOrId[:name]
return index(name) unless name.empty?
end
- if tagOrId.kind_of?(Tk::Button)
+ if tagOrId.kind_of?(TkButton)
return index(tagOrId[:text])
end
# index(tagOrId.to_s)
@@ -119,37 +112,19 @@ class Tk::BWidget::Dialog
def add(keys={}, &b)
win = window(tk_send('add', *hash_kv(keys)))
- if b
- if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
- win.instance_exec(self, &b)
- else
- win.instance_eval(&b)
- end
- end
+ win.instance_eval(&b) if b
win
end
def get_frame(&b)
win = window(tk_send('getframe'))
- if b
- if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
- win.instance_exec(self, &b)
- else
- win.instance_eval(&b)
- end
- end
+ win.instance_eval(&b) if b
win
end
def get_buttonbox(&b)
win = window(@path + '.bbox')
- if b
- if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
- win.instance_exec(self, &b)
- else
- win.instance_eval(&b)
- end
- end
+ win.instance_eval(&b) if b
win
end
diff --git a/ext/tk/lib/tkextlib/bwidget/dynamichelp.rb b/ext/tk/lib/tkextlib/bwidget/dynamichelp.rb
index 846e58062d..224304f2ab 100644
--- a/ext/tk/lib/tkextlib/bwidget/dynamichelp.rb
+++ b/ext/tk/lib/tkextlib/bwidget/dynamichelp.rb
@@ -34,13 +34,6 @@ module Tk::BWidget::DynamicHelp
['DynamicHelp::configure']
end
- def self.cget_strict(slot)
- slot = slot.to_s
- info = {}
- self.current_configinfo.each{|k,v| info[k.to_s] = v if k.to_s == slot}
- fail RuntimeError, "unknown option \"-#{slot}\"" if info.empty?
- info.values[0]
- end
def self.cget(slot)
self.current_configinfo(slot).values[0]
end
diff --git a/ext/tk/lib/tkextlib/bwidget/entry.rb b/ext/tk/lib/tkextlib/bwidget/entry.rb